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)

1 Answer 1

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)))
1
  • Sweetness prevails! Thanks!
    – tgunr
    Commented Jan 1, 2023 at 21:54

Your Answer

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

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