Chillar Anand
Chillar Anand

Reputation: 29514

how to find where a key binding is defined in emacs?

Somehow shift + m is got bound to Meta key in emacs. Now I cant type any words that start with M like Mock. I want to find why it is happening or which package is causing this.

There is one question regarding this issue but doesn't solve this problem.

I tried C h k m which showed m runs command self-insert-command

But when when i try C h k M it is activating Meta key and is waiting for another key to input.

The same is happening with C h c M.

Is there any way to find out what is causing this?

Update:

  1. My emacs config https://github.com/ChillarAnand/.emacs.d

  2. The problem is not occuring at OS level. If I start emacs with emacs -Q everything works fine.

Upvotes: 5

Views: 1722

Answers (2)

Edgar
Edgar

Reputation: 37

Adding this at the beginning of my .emacs did the trick for me:

(let ((old-func (symbol-function 'define-key))
      (bindings-buffer (get-buffer-create "*Bindings*")))
  (defun define-key (keymap key def)
    (with-current-buffer bindings-buffer
      (insert (format "%s -> %s\n" key def))
      (mapbacktrace (lambda (evald func args flags)
                      (insert (format "* %s\n" (cons func args))))))
    (funcall old-func keymap key def)))

Upvotes: 1

npostavs
npostavs

Reputation: 5027

The problem was the code

(define-key smartparens-mode-map (kbd "M up") nil)
(define-key smartparens-mode-map (kbd "M down") nil)))

This doesn't bind shift m as Meta but rather binds the key sequences M u p and M d o w n to nil. To specify Meta inside kbd use M-{the key}, to specify up use <up>, for the code in question:

(define-key smartparens-mode-map (kbd "M-<up>") nil)
(define-key smartparens-mode-map (kbd "M-<down>") nil)))

Upvotes: 2

Related Questions