A Query for Mac Emacs Users

I was just reading Bozhidar Batsov's latest post on deleting whitespace—nice tip on just-one-space by the way—and noticed that he had to rebind just-one-space from 【Meta+Space】because that key sequence is reserved by the OS X for Spotlight.

I've observed that many Mac users map 【⌘ Cmd】 to【Meta】 but I don't understand why. It causes lots of problems with key conflicts like the one Batsov encountered and it doesn't seem to me to offer any real advantages over using the 【⌥ Opt】 key. I suppose one could argue that the 【⌘ Cmd】 key is easier to reach but I, at least, don't find it easier enough to compensate for the problems that it introduces.

So my query to fellow Mac users who map 【⌘ Cmd】 to【Meta】 is what advantages do you see from the mapping? Why is it a better choice than 【⌥ Opt】? Of course, this is another example of Emacs letting you have it your way and while it probably doesn't make much difference on the scales of the universe, I'm curious.

This entry was posted in General and tagged . Bookmark the permalink.
  • Paul

    I map Cmd to Meta because lots of special characters (~, |, {, }, etc.) use the option key (at least in the German layout).

    • jcs

      Ah. That makes sense.

  • Josh

    The Mac keyboard has Fn-Ctrl-Alt-Cmd whereas the Windows keyboard has Fn-Ctrl-Win-Alt. So, now that I'm actually giving it some thought, I mapped things that way when I was on a Mac because I was lazy. In hindsight, it wasn't a bad move (I'm now on PC keyboards all the time), but I'm pretty ashamed that laziness was the driver there.

  • As a matter of fact `Option-Space` toggles between languages by default in OSX, so it's not usable in this particular scenario as well. One can certainly remap it, but I find this keybinding to be pretty handy. Personally I map `Command` to `Meta` because I've used standard keyboards much longer than Mac keyboards and I guess some day I'll have to use them again. I also find the Option keys a bit harder to press, since they're quite short on a Mac keyboard.

    • jcs

      I see. Like Paul it's a matter of getting at non-English characters. As an American wallowing in my monolingualism, that's not an issue for me so I didn't think about it. Thanks for the input.

  • Damon Haley

    I do it because I can then hit meta with either thumb rather than have to hit OPTION with my pinky. My pinky tends to get strained from lots of use, whereas my thumb never does.

    I haven't run into many conflicts. It's easy to change the shortcut for spotlight, which I hardly use. Other than spotlight, I don't recall many conflicts that weren't easily adressed.

    As a side note, I also strongly recommend the great KeyRemap4MacBook, which makes setting up any other kind of shortcut (not available by default) super easy. There's even an emacs mode to make most of the popular emacs keybinding available for other OS X apps. So I can use (Meta W) - by pressing OPTION w - in all apps and copy to the clipboard.

  • Paul Provost

    Muscle memory for me. I use emacs on Linux and Windoze as well, and the Alt key is where the Command key is. I tried using Option for a while, but my muscle memory kept forgetting and I ended up closing windows instead of copying regions...

    Someone suggested mapping Meta to another combination:

    (global-set-key "\C-x\C-m" 'execute-extended-command)

    which seems like a good idea, but I haven't tried yet. Still using Command for Meta.

    • Remapping execute-extended-command to another binding is definitely a great idea- but increasing the number of strokes required to access this defun is a bit counter-intuitive. I have found that C-' is easy to pick up, and avoids any sort of strain on your littlest piggies.

  • For me it is muscle memory. Have used the key next to space for so long for Meta, and even now have to get on to Windows from time to time.

    I guess there is no clean solution, to align between Emacs and OSX default settings. I have tried to map M-c and M-v to copy and paste for the time being, because I kept on tripping on that in Emacs after spending some time on a std OSX application.

  • I had developed pretty bad RSI in my days before Dvorak (numb hands after about 30 minutes) which prompted me to do a whole lot of things with my layout.

    One was to, in Emacs, swap Super and Meta. This was both to help my RSI and because at the time I was stuck in Windoze land at work and Windoze soft-key remapping is _terrible_. If you don't struggle with RSI you might not understand what a big difference it is to hit the key in the center of your palm with your thumb over and over again vs. the key to the right hand side of your palm. Also, for such an important key as Meta in emacs, it's very difficult to set your muscle memory up to switch between them if you're at home or at work.

    Interestingly enough, the most recent development in my key remapping efforts has been to, in a system wide way, remap ⌘ and ⌥. Many people don't know, but OS X has very good readline support in any standard text input control. It's nice to be able to comfortably slide your thumb over just like you would in Emacs in other apps as well.

    Also, many people here so far are ignoring the fact that pretty much any keybinding in OS X can be overridden by going to System Preferences → Keyboard → Keyboard Shortcuts and either disabling them or overriding them in the application specific mappings. Thus OS X should never take an important and easy to type keyboard shortcut like M- and use it for something like Spotlight. I have Quicksilver bound to that key sequence.

    Finally, if you're a TTY emacs user like me, you can always use ⎋ to activate any key bindings that is being shadowed by the OS. Same with using `C-x @ s` for getting at Super key bindings (which are often shadowed by os x) or things like Hyper which don't have a hard key equivalent on any modern keyboards.

    Just my thoughts. :)

  • me, also, due to ease of pressing the key besides space bar. e.g. Meta+f Meta+b for moving forward/backward word.

    while in emacs, it's a different key world, so i didn't find Mac's Cmd functions useful.

    Though, i haven't used Mac for past 3 years, but was Mac from 1991 to 2009, and Mac+Emacs from 1997 to 2009. Mac+Emacs Default keys from 1997 to 2007. But now, i no longer use emacs default keys, but Meta/Alt is all the more important in ergoemacs keybinding. I'd likely still make Cmd position do Meta if i use Mac now.

    • hi jcs, not related, but do you know how do i make my photo show?

      • jcs

        I think you have to be signed in. After that go to your profile and make the picture your avatar.

  • Chris Wittern

    I am using the option key for switching languages and entering accented characters, so I can't use that as meta key. Comman works pretty well in most cases.

  • bitti

    I also have a german keyboard layout (even on a US-Keyboard) but I still prefer having alt as Meta Key! I just have an alt mapping for some special characters (like {, }, |, @, €) but surprisingly they don't conflict with any important emacs Meta mappings. (And even if they do there's often an alternative mapping. E.g. you can use C-[0-9] for prefix arguments or esc instead of alt.)

    I rather have the command key with it's default Mac-OS bindings available (which are also shorter sometimes, compare ⌘s with C-x s for example) than being able to access some obscure characters I never use. It's also convenient to have a ton of keybindings free for own bindings.

    The only real disadvantage I see it that that cmd and alt keys are switched on a PC keyboard, which will need some readjustments should I ever switch back.