0

I've been using vanilla Emacs on OSX (via MacPorts or from emacsformacosx.com) pretty happily until a bug forced me to try a different version. I was recommended Mituharu's branch, and have been very happy with its mild enhancements over vanilla Emacs.

However, over the years I've grown used to using Alt as my Meta key, and Mituharu's branch defaults to Cmd/⌘. This is easily changed by customizing mac-command-modifier, however it lacks the OS X-style shortcuts that vanilla has (⌘-C/V for copy-paste for one).

What's the easiest way to get those shortcuts? The only thing I found was mac-key-mode, but that's not (yet?) packaged anywhere. Is there a better alternative?

  • How about pressing C-h k and then pressing whatever keyboard shortcut you want -- that will let you see what keys are being registered? Then just bind those keys to things like copy (ns-copy-including-secondary) and paste (yank), or whatever else you want. In other words, don't worry about rewiring and remapping stuff. If you don't like a keyboard shortcut, then disable it or redefine it -- if you need one, create one. – lawlist Nov 29 '16 at 18:44
  • Yeah, I'll probably end up doing that, but I figured this might be a common enough request, and it's included in vanilla Emacs, to already have a complete solution. – John de Largentaye Nov 29 '16 at 18:49
  • Check to see if cua-mode is activated. It sounds like that's what you're actually after. – Dan Nov 29 '16 at 19:04
  • No, cua-mode is inherently tied to the Control- modifier, which is really not what I want, as that conflicts with muscle-memory for all Emacs prefixes. I'm looking for ⌘- shortcuts. – John de Largentaye Nov 29 '16 at 19:25
  • 1
    I use alt for meta and use cmd for mac-style shortcuts. There are only 8 that I use so I just bind them myself; that was easier than trying to find a package that does just what I want. – amitp Nov 30 '16 at 0:46
0

This is hardly ideal, but ns-win.el contains the NS port customizations. Here's the relevant bit (starts at line 103):

;; Here are some Nextstep-like bindings for command key sequences.
(define-key global-map [?\s-,] 'customize)
(define-key global-map [?\s-'] 'next-multiframe-window)
(define-key global-map [?\s-`] 'other-frame)
(define-key global-map [?\s-~] 'ns-prev-frame)
(define-key global-map [?\s--] 'center-line)
(define-key global-map [?\s-:] 'ispell)
(define-key global-map [?\s-?] 'info)
(define-key global-map [?\s-^] 'kill-some-buffers)
(define-key global-map [?\s-&] 'kill-this-buffer)
(define-key global-map [?\s-C] 'ns-popup-color-panel)
(define-key global-map [?\s-D] 'dired)
(define-key global-map [?\s-E] 'edit-abbrevs)
(define-key global-map [?\s-L] 'shell-command)
(define-key global-map [?\s-M] 'manual-entry)
(define-key global-map [?\s-S] 'ns-write-file-using-panel)
(define-key global-map [?\s-a] 'mark-whole-buffer)
(define-key global-map [?\s-c] 'ns-copy-including-secondary)
(define-key global-map [?\s-d] 'isearch-repeat-backward)
(define-key global-map [?\s-e] 'isearch-yank-kill)
(define-key global-map [?\s-f] 'isearch-forward)
(define-key global-map [?\s-g] 'isearch-repeat-forward)
(define-key global-map [?\s-h] 'ns-do-hide-emacs)
(define-key global-map [?\s-H] 'ns-do-hide-others)
(define-key global-map [?\s-j] 'exchange-point-and-mark)
(define-key global-map [?\s-k] 'kill-this-buffer)
(define-key global-map [?\s-l] 'goto-line)
(define-key global-map [?\s-m] 'iconify-frame)
(define-key global-map [?\s-n] 'make-frame)
(define-key global-map [?\s-o] 'ns-open-file-using-panel)
(define-key global-map [?\s-p] 'ns-print-buffer)
(define-key global-map [?\s-q] 'save-buffers-kill-emacs)
(define-key global-map [?\s-s] 'save-buffer)
(define-key global-map [?\s-t] 'ns-popup-font-panel)
(define-key global-map [?\s-u] 'revert-buffer)
(define-key global-map [?\s-v] 'yank)
(define-key global-map [?\s-w] 'delete-frame)
(define-key global-map [?\s-x] 'kill-region)
(define-key global-map [?\s-y] 'ns-paste-secondary)
(define-key global-map [?\s-z] 'undo)
(define-key global-map [?\s-|] 'shell-command-on-region)
(define-key global-map [s-kp-bar] 'shell-command-on-region)
;; (as in Terminal.app)
(define-key global-map [s-right] 'ns-next-frame)
(define-key global-map [s-left] 'ns-prev-frame)

(define-key global-map [home] 'beginning-of-buffer)
(define-key global-map [end] 'end-of-buffer)
(define-key global-map [kp-home] 'beginning-of-buffer)
(define-key global-map [kp-end] 'end-of-buffer)
(define-key global-map [kp-prior] 'scroll-down-command)
(define-key global-map [kp-next] 'scroll-up-command)

;; Allow shift-clicks to work similarly to under Nextstep.
(define-key global-map [S-mouse-1] 'mouse-save-then-kill)
(global-unset-key [S-down-mouse-1])

There are a few NS specific ones in there, but I imagine you should be able to find the Mac port equivalents, if they exist.

You won't be able to just eval the file, though, as it contains a lot of very specific NS stuff that would probably break on the Mac port.

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.