Search code examples
emacspython-mode

emacs python-mode: designate which python shell to send commands to


A follow up on this question - if I have two python shells running in emacs, how can I designate which shell commands from each python script buffer is sent to? I suspect it has something to do with python-buffer and python-set-proc but setting these variables to the name of the shell is apparently not the solution.

Edit: actually since I am using python-mode rather than loveshack python, it probably does not have to do with python-buffer and python-set-proc.


Solution

  • In any Python buffer, you can use the variable py-which-bufname to control which Python shell your code gets sent to when executing it. The variable is buffer-local, so in order to set it to a custom value you'll need to change it from within the buffer by pressing M-: and entering the following

    (setq py-which-bufname "My-Custom-Bufname")
    

    This also makes it easy to quickly create new process buffers: If you set py-which-bufname to a name for which there is no corresponding process buffer, you can just issue C-c ! to quickly create one.

    HTH