tags:

views:

71

answers:

2

I am trying to bind <C-return>. I tried global-set-key but it didn't work. I then found a suggestion in "Globally override key binding in Emacs" where someone created a custom minor-mode which included their keybindings, like this:

(define-key my-keys-minor-mode-map (kbd "<C-return>") 'insert-and-indent-line-above)

Bit it still won't replace the current binding. If I do a describe-key and press C-Return it tells me that it is bound to cua-set-rectangle-mark.

How do I make this binding supersede all other bindings?

+2  A: 

It sounds like you have cua-mode enabled, which is setting that binding. You can disable cua-mode:

(cua-mode -1)

Or, change the binding for cua-set-rectangle-mark like so:

(setq cua-rectangle-mark-key (kbd "C-S-return"))
(cua-mode 1)

And then your binding should take effect (using the global-set-key).

Trey Jackson
I do want cua-mode but changing the key before cua-mode starts did the trick
MDCore
A: 

You want to use global-unset-key.

(global-unset-key (read-kbd-macro "C-<return>"))
Joe Casadonte
if I `eval-region` this line it still doesn't unbind it. very strange.
MDCore
Because the binding is in the `cua-mode-map`, not the `(current-global-map)`. From the docs: "Note that if KEY has a local binding in the current buffer, that local binding will continue to shadow any global binding that you make with this function."
jrockway