3

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.

3 Answers 3

2

You can set a new value to python-buffer.

(defun my-python-set-proc (buffer-name)
  (interactive "B")
  (setf python-buffer (get-buffer buffer-name))
  (python-set-proc))

And then M-xmy-python-set-procRET*Python*RET, or M-xmy-python-set-procRET*Python*<2>RET.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - it was my mistake that I suggested python-buffer and python-set-proc as they appear to be relevant variables for loveshack python rather than python-mode.
1

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

2 Comments

Case closed! Thanks - this is exactly what I needed.
This variable does not seem to exist anymore. As this question arrived first on my search engine, here is the modern way. The variable is now named python-shell-buffer-name. By using add-file-variable, you can define a buffer-specific value to this variable with a string, like "TOTO". It will then create a buffer named *TOTO* with the python shell.
0

py-shell-name sets the default, which might be overwritten by command

Should the buffer code contain a shebang specifying pythonVERSION , than this takes precedence over default setting.

You may enforce executing buffer through specific pythonVERSION by calling a command of class py-execute-buffer-pythonVERSION

See menu PyExec, entry Execute buffer ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.