1

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:

Won't unbind the key

askedAug 8, 2021 at 10:53
Fabman's user avatar
2
  • 2
    note 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 areCommentedAug 8, 2021 at 17:56
  • 1
    I think this question is a duplicate, but I don't have the time now to search for it.CommentedAug 8, 2021 at 18:35

1 Answer1

8

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)
answeredAug 8, 2021 at 15:20
Fran Burstall's user avatar
1
  • Looking at the customoze menu I was surprised that (it seems so) I cannot change the key bindings there.CommentedAug 9, 2021 at 7:05

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.