1

I'm trying to quit the habit of using s-v, s-c and similar keyboard shortcuts for copy paste in Emacs on mac os/osx. I'd like to turn them off but can't find any information on how to do this.

There's a chance this was turned on at some point and it does not come as a standard as the .elisp file is unwieldy and old. It doesn't seem like there's something doing this in it though.

Of course manually remapping all the keys would be possible if there's no easy way to do this.

2 Answers 2

6

When building the vanilla version of Emacs --with-ns, the default key bindings in ns-win.el are put into place. To disable specific bindings, just set them to nil. If a binding is set outside of Emacs (e.g., System Preferences of OSX), then Emacs would never even get the opportunity to see the keys because they would get intercepted before reaching Emacs.

For example, to disable copy and paste, you would add the following to your emacs configuration file (traditionally, ~/.emacs):

;; Disable Mac keyboard commands.
;; (s is for super)
(define-key global-map [?\s-c] nil) ;; Disable command c (copy)
(define-key global-map [?\s-v] nil)  ;; Disable command v (paste)

Another one you might want to disable is command m (minimize). Very distracting if it's something that you accidentally hit (instead of meta-m).

For a self-contained version of Emacs, e.g., downloaded from https://emacsformacosx.com/ or manually built from source using --with-ns, the ns-win.el library is located in the package archive:

/Applications/Emacs.app/Contents/Resources/lisp/term/ns-win.el

If anyone is interested in seeing the default key bindings, please feel free to inspect the source code of ns-win.el.

1
0

I swap my option and command keys, so that i can use the key to the left of the space bar as Meta by doing:

  1. Open System Preferences
  2. Select Keyboard
  3. Click "Modifier keys..." button in the bottom right of the window.
  4. Swap the values for Option and Command in the popup menus.

In the Terminal application:

  1. Open Preferences
  2. Select Profiles
  3. Click Keyboard
  4. Check the "Use Option as Meta Key" box

BEWARE that the swap takes effect for every application on the Mac, so you'll need to re-train your brain (well, at least your thumb) to use option instead of Command for your Mac key equivalents.

But it is possible to retrain, and then the key to the left of space will always work as Meta in the Terminal application. Plus you will be entertained when people who try to type use Command-Whatever on your computer discover it doesn't work and become confused.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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