views:

218

answers:

4

Maybe it’s a bit weird to ask this question in English because my problem is a rather non-English one. I’m an Mac OS X user and I’m on my way to learning Emacs. I decided to use the Emacs 23.1 Cocoa build that by default uses the Mac keyboard’s alt/option key as the meta key. But because I am German and I’m using a German keyboard, of course, it get’s quite tricky to enter parantheses that are needed for programming extensively: { } [ ]

To get these characters on the German keyboard layout you have to press the following keys:

alt-5 for '['
alt-8 for '{'

which translate according to the situation described above to

M-5
M-8

both running the command digit-argument in Emacs.

I’m not really sure how to get around this issue. I know that you can change the actual key that should be used as the meta key (e.g. I could change the meta key to be the command key). But I think that every choice will come at a cost and have some obvious disadvantages as it “overrides” some predefined OS behaviour that may be needed while editing with a foreign language keyboard.

For now, the best option to me seems to be to use the CAPS LOCK key as the meta key as this choice doesn’t interfere with pre-existing key combinations.

What are your experiences concerning this issue? Do you (non-English) use an English keyboard (layout) while coding? Don’t you get mixed up with such context dependent keyboard layouts? Or do there exists some best practices which key to use as meta key on a German or similar keyboard? Or even some configuration options?

A: 

You can press "Command ;" to change the option key between being the meta key and being the normal option key. I believe you can even do this in the middle of a key sequence. When I need to enter diacritics into Emacs, I just press "Command ;" rather than use the various input modes in Emacs. You can also access the setting through Options -> Option -> Option key is Meta.

The other option is to rebind keys in your .emacs file.

Speaking of switching keyboard layouts, I switch between Dvorak and US Qwerty often enough that it doesn't bother me, and they are much more different than the US and German layouts. (Dvorak reduces hand strain for me).

Dietrich Epp
A: 

With a bit of practice, you can mentally switch back and forth between a US and DE keyboard layout -- even the swapped Y and Z become second nature after a while. I did that for years while working in Germany.

But even with a US keyboard layout, there are still characters that you can't enter without Alt. I personally use Command as Meta for this reason, leaving Alt/Option for the built-in OS X dead-keys, e.g. "alt-shift-2" => €, "alt-e e" => é:

  (setq mac-command-modifier 'meta
        mac-option-modifier 'none
        default-input-method "MacOSX")

Another option would be to relocate "problem" keys like { } using the keyboard-translate function.

sanityinc
A: 

Aquamacs (http://aquamacs.org/) is a mac-friendly version of Emacs. They have a Preview (and nightlies) based on Cocoa and Emacs 23.1.

Aquamacs has the option to rebind option command and meta in various stages between native mac keybindings and native emacs bindings. You should be able to find a stage that suits your fingers.

A: 

I've ruled the German keyboard layout unfit for programming a long time ago. I used the US layout for a while and never had trouble switching contexts for German typing. I'm now using my own layout based on Dvorak, but with (){}<>[] moved around for more convenient access. I suppose the latter is a rather exotic choice ;). I strongly recommend at least the US layout for coding, though.

As for Emacs: I use Command as the meta key. It is easier to reach and matches Linux and Windows environments. (Ahh, finger memory...) I'd also rather lose a few OSX keys than umlaut and unicode input keys.

Whichever you choose, you can always get back those characters or OSX commands that you do need:

(global-set-key "\M-5" "[")
(global-set-key "\M-q" 'save-buffers-kill-terminal)

(goes into your .emacs)

Oh, and do use Caps Lock for something useful. It's too conveniently located to waste on capitalization. ;) Many coders use it for Control.

nschum