Search code examples
emacskey-bindingsemacs24python-mode

Emacs Unbind a Mode's KeyBinding


I've created a custom key binding macro as follows:

(global-set-key (kbd "C-C C-c") "\C-a\C- \C-n\M-w\C-y")

The problem is that C-c C-c is defined for python-send-buffer in python-mode. So my macro works for all modes except python-mode. I am assuming that python-mode is evaluated after my init file, so it overwrites that keybinding.

I tried unsetting C-c C-c using (eval-after-load "python-mode") and using global-unset-key but that doesn't work. C-c C-c in python is always mapping to python-send-buffer.

How can I completely disable Python's C-c C-c, and use my macro instead?

I am using Emacs 24.2.1.


Solution

  • (add-hook 'python-mode-hook
              (lambda()
                (local-unset-key (kbd "C-c C-c"))))