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)
2
  • (define-key cua-mode-map (kbd "C-<return>") nil) (define-key cua-mode-map (kbd "C-RET") nil) ?
    – PythonNut
    Commented Aug 6, 2015 at 0:53
  • There is no cua-mode-map. At least not in 24.5.1.
    – Zhro
    Commented Aug 6, 2015 at 1:01

1 Answer 1

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.

8
  • 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
    Commented Aug 6, 2015 at 1:19
  • With emacs -q cua-mode doesn't get loaded. Does the keymap exist after you do M-x cua-mode?
    – erikstokes
    Commented Aug 6, 2015 at 1: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
    Commented Aug 6, 2015 at 1: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? Commented Aug 6, 2015 at 1:30
  • @Zhro The old school method of grepping in emacs source code always works :) Commented Aug 6, 2015 at 1:31

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.