At the moment I am killing the Python interpreter with C-d each time I want to quit Python interpreter.

What is the name of the function to kill the Python interpreter in Python mode (the one which comes with Emacs) so that I can bind it to a key command?

  • Welcome to Emacs Stack Exchange! If I've answered your question, you can accept it by clicking the checkmark next to it and it will give you +2 to your rep! Cheers! – Aaron Hall Oct 4 '18 at 21:00
  • If nothing works for you, you can kill the python interpreter by simply typing inside the command quit(). – Ian May 2 '19 at 15:10

Looks like you want comint-stop-subjob but it looks like it's already bound to C-c C-z for you.

From the docs:

C-c C-z

Stop the shell or its current subjob if any (comint-stop-subjob). This command also kills any shell input pending in the shell buffer and not yet sent.

| improve this answer | |
  • Thanks for your reply! C-c C-z doesn't kill the python shell, but simply changes to the buffer having the shell in it. The right command for me was `C-c C-\`, thanks for the link enyway. – user12021 Oct 4 '18 at 21:48

I believe the command you're looking for is (comint-send-eof).

You can bind it with something like:

(global-set-key (kbd "<f5>") 'comint-send-eof)

It is bound, by default, to C-c C-d.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy