18

I'm new to Emacs, and am using a Mac. I want the Mac command key to act as a control key for Emacs.

How do I do that? I tried (setq mac-command-modifier 'control).

Besides, how do I find key variable and local key names in Emacs? For example: how can I find that mac-command-modifier is the command key name?

Dan
  • 32,980
  • 7
  • 102
  • 169
LoranceChen
  • 305
  • 1
  • 2
  • 10
  • It also might be useful to switch your control key and cap lock key to save you fingers all that stretching. Then you can just press cap locks to use emacs commands. – Robert Sep 24 '19 at 17:50

1 Answers1

26

The EmacsWiki node on Emacs for Mac OS will give you advice on a number of OSX-specific issues. More specific to your question, you can adjust the modifier keys as you like:

mac-function-modifier
mac-control-modifier
mac-command-modifier
mac-option-modifier
mac-right-command-modifier
mac-right-control-modifier
mac-right-option-modifier

Aside: you might see these as ns- in place of mac- in some places. The ns-, I believe, is referring to NeXTSTEP, one of the sources for OSX.

You should be fine with your setup to make Emacs interpret the command key as control:

(setq mac-command-modifier 'control)

Put that in your init file and it should take effect the next time you start Emacs.

For keybindings, the first stop is the Emacs manual node on Customizing Key Bindings. Another good resource is Mickey Petersen's Mastering Key Bindings in Emacs.

Dan
  • 32,980
  • 7
  • 102
  • 169