09 September 2013

Emacs on Mac-OS: Configuration for Alt- and Meta-Key

Oh what a nuisance, having to configure key-bindings so that Emacs becomes usable on Mac-OS...

The Problem

  • You need a proper META-key to use Emacs.
  • With non-US keyboards, you need the ALT-key to type characters like [, ], { or }. 


Command-as-Meta? No way...

People discuss wether to configure the COMMAND-key (aka "apple-key" or CMD) as META. 

Imho impossible, as in *all* other Mac applications, CMD plays a central role (new, open, duplicate, quit, minimize etc.). No way I can unlearn these key combinations.


Escape-as-Meta? Your Fingers Run Marathon...

Some people use ESC as Meta. For every of the numerous Meta-commands in Emacs, send your little pinky finger all the way up north-east to Escape-country… no, that feels like an unhealthy amount of movement to me.


Left-ALT-as-Meta, Right-Alt-for-Special-Characters

Whow - that's clever: Using the left-Alt key for something different than the right-Alt key...

Simple put the following line in your emacs configuration file (~/emacs.d/user.el or similar):

(setq ns-right-alternate-modifier nil)

That works fine for me...


Of course, I have CAPS-Lock mapped to CTRL (in Mac-OS system settings under keyboard)


Some more Emacs Links

@pschirmacher pointed me to  http://www.braveclojure.com/basic-emacs/, which contains both a nice setup and pragmatic introduction.

I use the "vanilla Emacs" - of course the key config from above also works in terminal-Emacs.