Long story short, there's a little library I like but I don't like any of the default keybindings. E.g. it's a global minor mode and binds a function to C-c C-s, but that shadows org-schedule in my org and org-agenda buffers.

I want to keep the little library but get rid of all the bindings in the little library keymap.

In an early attempt to do this, I tried the following (after confirming that little-library-mode-map is where the bindings live):

(with-eval-after-load "little-library-mode"
  (setq little-library-mode-map (make-sparse-keymap)))

The code "succeeds" (C-h v little-library-mode-map RET shows that it's just (keymap) now) but all the little library keybindings still "work" (C-c C-s still does the little library function, including in org and org-agenda buffers).

I've found another way to solve my issue, but I'm really curious why this approach fails. Emacs' keybindings still seem like black magic to me.

  • You'll need to destructively modify the data structure the minor mode uses, like (setcdr little-library-mode-map nil).
    – wasamasa
    Sep 25, 2016 at 9:51

2 Answers 2


There are three important things in this story:

  • the minor mode keymap
  • its name
  • the sparse keymap you create

Basically what you did is make the name point at the sparse keymap instead of the original, but it's too late: the minor mode uses the original.

  • Ah, got it. When you put it that way it makes perfect sense. Do you know how Emacs / the minor mode finds the original keymap? What data structure does it look in? Sep 25, 2016 at 6:42
  • 3
    @purple_arrows the original keymap is in minor-mode-map-alist.
    – npostavs
    Sep 25, 2016 at 13:42

At some point when activating little-library-mode the keymap stored in the variable little-library-mode-map gets added to minor-mode-map-alist:

(push (cons 'little-library-mode little-library-mode-map) minor-mode-map-alist)

Emacs uses this alist to lookup minor-mode bindings. When you bind the variable little-library-mode-map to a new value afterwards this has no effect on the keymap minor-mode-map-alist points to. As noted in the comment by @wasamasa one way to get rid of all bindings in this keymap is to mutate the keymap directly:

 (setcdr little-library-mode-map nil)

Another way is to reset the keymap before loading the library:

(setq little-library-mode-map (make-sparse-keymap))
(with-eval-after-load "little-library-mode" 

If the minor-mode is well behaved, this will avoid instantiating its bindings, too.

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.