5

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 ?

ChiseledAbs
  • 449
  • 1
  • 4
  • 12

1 Answers1

7

(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)))
zck
  • 8,984
  • 2
  • 31
  • 65
  • 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 ? – ChiseledAbs Jan 03 '17 at 17:15
  • Check out http://emacs.stackexchange.com/questions/21978/remove-key-binding-in-magit-status-mode . If that doesn't work, ask a separate question, because long answers in comments are hard to read. – zck Jan 03 '17 at 17:27
  • 2
    Check out the Emacs [manual section on named ASCII chars](https://www.gnu.org/software/emacs/manual/html_node/emacs/Named-ASCII-Chars.html) for an explanation of the differences between `RET` and ``. – Tianxiang Xiong Jan 04 '17 at 17:47