Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Unbind a Mode's KeyBinding [duplicate]

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.

like image 931
darksky Avatar asked Oct 11 '13 18:10

darksky


People also ask

How do you bind commands in Emacs?

Keys can be bound to commands either interactively or in your . emacs file. To interactively bind keys for all modes, type M-x global-set-key RET key cmd RET . To bind a key just in the current major mode, type M-x local-set-key RET key cmd RET .


1 Answers

(add-hook 'python-mode-hook
          (lambda()
            (local-unset-key (kbd "C-c C-c"))))
like image 51
Andreas Röhler Avatar answered Oct 05 '22 07:10

Andreas Röhler