1

I am switching from Aquamacs to Emacs on OSX v28.2 and trying to setup my preferred key bindings. I set

'(ns-alternate-modifier 'alt)
'(ns-command-modifier 'meta)
'(ns-control-modifier 'control)
'(ns-function-modifier 'none)
'(ns-right-alternate-modifier 'none)
'(ns-right-command-modifier 'hyper)
'(ns-right-control-modifier 'super)

Then tried setting

  (global-set-key (kbd "M-v") 'cua-paste)

But no matter what I try M-v (cmd-v on Mac) always shows the following when enter F1-k M-v

M-v runs the command delete-selection-repeat-replace-region (found in
cua--cua-keys-keymap), which is an interactive byte-compiled Lisp
function in ‘delsel.el’.

It is bound to M-v.

My other bindings are working fine, just not M-v

  (global-set-key (kbd "M-x") 'clipboard-kill-region)
  (global-set-key "\M-c" 'cua-copy-region)
  (global-set-key (kbd "M-v") 'cua-paste)
  (global-set-key (kbd "M-z") 'undo)
  (global-set-key (kbd "M-s") 'save-buffer)
  (global-set-key (kbd "M-w") 'kill-buffer)
Drew
  • 75,699
  • 9
  • 109
  • 225
tgunr
  • 123
  • 5

1 Answers1

3

The message indicates that a command in cua--cua-keys-keymap overrides your binding for M-v. This overriding binding is created when cua-mode is enabled. cua-mode puts its keymaps in emulation-mode-map-alists which gives them very high priority, see here or this Emacs manual section.

One way to make your binding come through is to disable the M-v binding set by cua-mode (or change it to something else) by putting the following in your init.el:

(add-hook 'cua-mode-hook (lambda () (define-key cua--cua-keys-keymap (kbd "M-v") nil)))
orgtre
  • 1,012
  • 4
  • 15