1

I want to fully define my own C-c keymap, but some modes add default keybindings under that prefix. For example, I have C-c C-c for rustic-mode bindings and C-c & for yasnippet bindings. How can I unbind anything that starts with C-c? I've tried:

  • (global-set-key (kbd "C-c") nil)
  • general.el's (general-unbind "C-c")

But none of them work. I've also tried unbinding specific bindings such as with (general-unbind "C-c C-c c") but it didn't work either.

3
  • This seems like an X-Y problem. You don't need to unbind existing keybindings to replace them with your own; just put your own bindings in a separate keymap, and then set overriding-local-map as needed.
    – rpluim
    Jan 10 at 13:32
  • Revising that advice: use-local-map combined with set-keymap-parent will likely work better
    – rpluim
    Jan 10 at 14:09
  • You're not wrong, but the main problem is that which-key shows all predefined mappings (on which I have no interest, since I prefer my own) and they clutter the hints, making it harder for me to find my own
    – Haf
    Jan 10 at 16:10

1 Answer 1

1

If you want to suppress all the local bindings starting with C-c, the following will do that:

(define-key (current-local-map) (kbd "C-c") nil)

Of course you'll need to add that to the startup hook for every mode where you want to do that.

(this kind of thing is why I put almost all my personal bindings on C-z)

1
  • Seems cumbersome and unreliable... but I'm convinced it's the best solution. Maybe I'll put mine on C-z too
    – Haf
    Jan 10 at 19:26

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.