5

有没有办法python-shell在运行 Emacs 时强制创建一个新实例?在使用单独的工作目录(和不同的模块集)处理多个项目时会很方便。

任何调用尝试python-shell只会拉起当前实例。

4

3 回答 3

3

在打开一个新的之前,您需要重命名您原来的 python-shell。使用M- x rename-buffer

于 2011-11-26T22:10:54.520 回答
3

重命名缓冲区对我不起作用,但您可以使用run-python.

M - : (run-python nil nil t)RET

由于切换到当前缓冲区的绑定并没有真正的帮助,您可以将其重新绑定到更有用的东西

(defun my-run-python (&optional new)
  (interactive "P")
  (if new
   (run-python nil nil new)
   (pop-to-buffer (process-buffer (python-proc)) t)))

(define-key python-mode-map (kbd "C-c C-z") 'my-run-python)

并使用C- cC-z切换到当前的 python 解释器和 C- uC- cC-z 切换到新的 python 解释器。

于 2011-11-29T12:47:48.413 回答
0

python-mode通过python.el使用时,每个 Python 缓冲区有一个 Python shell 是默认设置。

但是,如果您希望多个 Python 缓冲区共享同一个 Python shell,则可以更改此默认行为。为此,在打开第一个 Python 缓冲区后,输入:

M-x python-set-proc

...记录在案:

Set the default value of `python-buffer' to correspond to this buffer.
If the current buffer has a local value of `python-buffer', set the
default (global) value to that.  The associated Python process is the
one that gets input from C-c C-r et al when used in a buffer that
doesn't have a local value of `python-buffer'.

然后,如果您希望新的 Python 缓冲区使用自己的 shell,请输入:

M-x set-variable python-buffer [RET] nil [RET]

python-switch-to-python这样做之后,然后打开一个新的 Python 缓冲区,在输入or之后将为该缓冲区创建一个新的 Python shell C-c C-z

于 2015-01-16T16:05:20.417 回答