I'm trying to setup some keybinds using functions from the python-x package. While it works for the simple call (global-set-key (kbd "C-c C-j") 'python-shell-send-line), when I try to chain multiple functions using the lambda trick I get <C-return> is undefined despite having no error at startup. Here is the command I put in the user-config in .spacemacs :

(global-set-key (kbd "C-RET") (lambda () (interactive) (python-shell-send-line) (next-line)))

python-x works with python mode but the simple keybind is available everywhere while the chained keybinds are all undefined. Where does it go wrong ?


1 Answer 1


(kbd "C-RET") does not actually refer to "Control return", the way it looks like it will.

To find out how a key should be written, press C-h c and then the key. If we do that, we get:

<C-return> is undefined

So, use C-<return>:

(global-set-key (kbd "C-<return>") (lambda () (interactive) (python-shell-send-line) (next-line)))
  • thanks for the trick that works, I have another problem I'm trying to ovewrite a keybind introduced by python-x it's C-c C-p, do you know if I can do that in user-config ? Commented Jan 3, 2017 at 17:15
  • Check out emacs.stackexchange.com/questions/21978/… . If that doesn't work, ask a separate question, because long answers in comments are hard to read.
    – zck
    Commented Jan 3, 2017 at 17:27
  • 2
    Check out the Emacs manual section on named ASCII chars for an explanation of the differences between RET and <return>. Commented Jan 4, 2017 at 17:47

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.