Emacs on Mac OS X - To Alt or Command?

Solution 1:

See the options under M-x customize-group ns

There you can adjust the behavior of the modifier keys. I have set the right alt to "No modifier" - that's the same behavior as on PC keyboards with Alt-Gr.

Another setting I like is to unset both alt keys and use the function key instead for alt.

Solution 2:

I have also had this problem for years! Just recently I tried out Emacs in OS X again. I finally fixed the problem by adding the following in my .emacs: (This is with Emacs 24.3)

(when (eq system-type 'darwin)
  (setq mac-right-option-modifier 'none))

Solution 3:

I have the same problem when I came from Linux to macOS, and I resolved it by add following codes to my emacs config file:

;; check OS type
(cond
 ((string-equal system-type "windows-nt") ; Microsoft Windows
  (progn
    (message "Microsoft Windows")))
 ((string-equal system-type "darwin") ; Mac OS X
  (progn
    (setq mac-option-key-is-meta nil)
    (setq mac-command-key-is-meta t)
    (setq mac-command-modifier 'meta)
    (setq mac-option-modifier nil)
    (message "Mac OS X")))
 ((string-equal system-type "gnu/linux") ; linux
  (progn
    (message "Linux"))))

Please notice this part of codes that have commented with 'Mac OS X', it'll swap option key with command key in emacs application, but in the whole view, command is still command, you can use command+tab just like before.

Solution 4:

Some people I know always buy Macs with US keyboards for exactly this reason.

I cursed at Emacs too (in Swedish, as well) and the only solution I've found is to use the US Extended layout, but using my Swedish keyboard. I spent several years with a US keyboard as my main keyboard so I can switch more or less without thinking.

If you're not willing to go the layout-switching route, OS X Emacs in Swedish is just painful.


Edit: Just found a hint for Spanish that might be of help. The idea is to remap the character that gets sent to Emacs to the one you desire. I haven't tried it, but it sounds promising.