2

My finger tends to linger on the Ctrl key and I happen to hit C-RET quite often. I also use cua-mode which binds this to cua-clear-rectangle-mark. I don't want C-RET bound to anything while in this mode.

I can't seem to unbind it though. I've tried:

(global-unset-key (kbd "C-RET"))
(global-unset-key (kbd "<C-return>"))
(global-unset-key [(control return)])
(define-key global-map (kbd "C-RET") 'ignore)
(define-key global-map (kbd "<C-return>") 'ignore)
(define-key global-map [(control return)] 'ignore)

I also tried the following in my .inputrc with no success:

"\C-RET": "\n"

There also doesn't seem to be a cua-mode-map:

;; Doesn't work
(define-key cua-mode-map "C-RET" nil)
Zhro
  • 359
  • 3
  • 11

1 Answers1

1

In Emacs 25, if you run C-h k C-RET it will tell you that C-RET is bound in cua-global-keymap, so that's where we unset it

(define-key cua-global-keymap [C-return] nil)

It seems to be set in the same keymap in 24.4 as well.

erikstokes
  • 12,686
  • 2
  • 34
  • 56
  • I've loaded emacs with `-q` and don't see cua-global-keymap listed anywhere when invoking `C-h k C-RET` while in cua-mode. – Zhro Aug 06 '15 at 01:19
  • With `emacs -q` `cua-mode` doesn't get loaded. Does the keymap exist after you do `M-x cua-mode`? – erikstokes Aug 06 '15 at 01:21
  • I explicitly enable cua-mode after loading emacs with `-q` in this instance. I'm sorry I wasn't clear enough on that. – Zhro Aug 06 '15 at 01:25
  • @erikstokes The keymap information in `C-h k` was introduced only recently in the dev version of emacs on its git master. Are you building your emacs from git? – Kaushal Modi Aug 06 '15 at 01:30
  • @Zhro The old school method of grepping in emacs source code always works :) – Kaushal Modi Aug 06 '15 at 01:31
  • I'm running the dev version. However, I also checked 24.4.1 and `C-RET` is bound in `cua-global-keymap` there too. – erikstokes Aug 06 '15 at 01:33
  • Hmm, that's strange. This feature was added in June: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=958d20d22a5e9b997de0bf7cc63436dc82486111 – Kaushal Modi Aug 06 '15 at 03:00
  • To clarify, `C-h k` isn't giving the keymap in 24.4. You have to check "by hand" in a non-bleeding-edge Emacs. – erikstokes Aug 06 '15 at 03:05