7

I run Emacs on Mac OSX, I'm trying to switch from Emacs for Mac OSX to Emacs Mac Port. I'm having some trouble with my keybindings.

For example, I'm trying to bind command-h to replace-string.

(setq mac-command-modifier 'super)
(define-key key-minor-mode-map (kbd "s-h") 'replace-string)

This didn't work. So I tried binding it as hyper:

(define-hyper-key "h" 'replace-string)

but that didn't work either.

Changing other keybindings does seem to work (s-o, s-p, etc).

This may be related: How to bind "Hide Others" to a key "M-s-h" in railwaycat/emacs-mac-port?

command-h for replace-string works on Emacs for Mac OSX, but on Emacs Mac Port, it just hides/minimizes the application window. Do keybindings work differently in Emacs Mac Port than they do on Emacs for Mac OSX? Are some keybindings hardcoded in to Emacs Mac Port, and if so, how can I override them?

Update: Looks like others are having the same issue. https://github.com/railwaycat/emacs-mac-port/issues/78

  • Do the regular stuff work?: (define-key global-map [?\s-h] 'replace-string) And, I have this for regular Emacs: (setq ns-command-modifier 'super) – lawlist Aug 18 '15 at 2:49
  • No, same result. – incandescentman Aug 18 '15 at 2:50
  • Changing other keybindings does seem to work (s-o, s-p, etc). – incandescentman Aug 18 '15 at 2:54
  • If other keybindings work, then how about trying C-h k s-h and see if it registers, or perhaps the OSX is intercepting it? – lawlist Aug 18 '15 at 3:15
  • That doesn't work either. Looks like it's being intercepted. But it's something about the Emacs Mac Port application and not OSX itself, since with Emacs for Mac OSX it works. – incandescentman Aug 18 '15 at 3:16
14

I found the answer.

In Emacs Mac Port, h bypasses any Emacs keybindings and instead sends a "pass command to system" message to Mac OSX, which then hides the entire application.

This is a vestige of behavior from the old Carbon Emacs. To disable it, use this:

(setq mac-pass-command-to-system nil)

Source:

http://newsgroups.derkeiler.com/Archive/Comp/comp.emacs/2005-11/msg00091.html
http://comp.emacs.xemacs.narkive.com/dBRWEljn/apple-carbon-emacs-disable-cmd-h-hide

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.