Mac – get Command-H to hide an Emacs window

emacskeyboard

I'm using GNU Emacs 23.4.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-01-29 on bob.porkrind.org on a MacBook Air.

Can I set CommandH to hide Emacs? I currently use M-x customize-group ns and set Command Modifier to no value. I already have a standard key binding to iconify-frame, but that is different from hiding; I'd rather use the native OS X hide capability so I can unhide by clicking on the Emacs icon in the dock.

Best Answer

If emacs is built with Cocoa (e.g via brew install emacs --cocoa), by default s-h (Cmd+h) should be bound to ns-do-hide-emacs

If somehow it is not, you can do this manually with:

(global-set-key [(super h)] 'ns-do-hide-emacs)