0

I'm trying to unbind M-o in diff-mode with use-package. To do that I've written:

(use-package diff
  :defer t
  :config
  (unbind-key "M-o" diff-mode-map))

Restarted Emacs 25, open a diff file, but M-o still seems to be mapped to diff-goto-source.

I checked diff-mode.el and found out that there is diff-mode-shared-map which seems to have M-o. So I did changed the map in the previous code to:

(use-package diff
  :defer t
  :config
  (unbind-key "M-o" diff-mode-shared-map))

But, it still does not work.

I've used the same snippet for other modes and they seem to work as I expected. Is diff-mode special?

  • In the second code block you have diff-mode-sAHred-map, is it a mispell in your code? – Konstantin Morenko Aug 3 '16 at 10:20
  • Oops. That was a typo in the question. I should have copy & past from my init.el. My init.el has diff-mode-shared-map in it. C-h v on it works too. Fixed in the question. Thanks. – Yasushi Shoji Aug 4 '16 at 6:11
2

The package* name is diff-mode, not diff. The use-package package symbol depends on what is provided, see near the bottom of diff-mode.el:

;; provide the package
(provide 'diff-mode)

I checked diff-mode.el and found out that there is diff-mode-shared-map which seems to have M-o.

diff-mode-shared-map binds o, diff-mode-map adds an ESC prefix which is equivalent to M-o. Therefore diff-mode-map is the map you want to modify.

(use-package diff-mode
  :defer t
  :config
  (unbind-key "M-o" diff-mode-map))

Or you could unbind o in diff-mode-shared-map:

(use-package diff-mode
  :defer t
  :config
  (unbind-key "o" diff-mode-shared-map))

This would unbind C-c = o in diff-minor-mode as well.


* This is not the same kind of package as a package.el package)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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