I was trying to bind(C-M-x) toer/expand-region but I checked the key combination with(C-h k) and noticed that it was binded toeval-defun. So I tried to unbind it with any of the following commands:
(global-set-key (kbd "C-M-x") nil)(global-unset-key (kbd "C-M-x"))But even using any of those won't unbind the key and(C-M-x) still will be runningeval-defun
This is the result after running both commands:
- 2note that you don't need to unset a keybinding before applying a new binding. As long as you set your new keybinding in the appropriate keymap, you can leave any other bindings as they areTyler– Tyler2021-08-08 17:56:13 +00:00CommentedAug 8, 2021 at 17:56
- 1I think this question is a duplicate, but I don't have the time now to search for it.Drew– Drew2021-08-08 18:35:50 +00:00CommentedAug 8, 2021 at 18:35
1 Answer1
eval-defun is bound toC-M-x inlisp-interaction-mode-map whileglobal-set-key and friends operate onglobal-map which has lower priority than any local key-map.
One way to bindC-M-x unconditionally is to use thebind-key package which providesbind-key* for this purpose:
(bind-key* "C-M-x" 'er/expand-region)- Looking at the customoze menu I was surprised that (it seems so) I cannot change the key bindings there.U. Windl– U. Windl2021-08-09 07:05:20 +00:00CommentedAug 9, 2021 at 7:05
Explore related questions
See similar questions with these tags.

