有沒有辦法在運行Emacs時強制新實例python-shell
?在使用不同工作目錄(和不同組模塊)的多個項目上工作會很方便。在Python或IPython中使用Emacs'python-mode'中的多個Python shell
任何試圖調用python-shell
的操作只會拉起當前實例。
有沒有辦法在運行Emacs時強制新實例python-shell
?在使用不同工作目錄(和不同組模塊)的多個項目上工作會很方便。在Python或IPython中使用Emacs'python-mode'中的多個Python shell
任何試圖調用python-shell
的操作只會拉起當前實例。
你需要在打開一個新的之前重命名你的原始python-shell。使用M - xrename-buffer
。
重命名緩衝區對我不起作用,但您可以使用run-python
的第三個參數。
中號 - :(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 - cÇ - Ž切換 到當前python解釋和 Ç - üÇ - ÇÇ - Ž 切換到新鮮python解釋。
謝謝。這是偉大的,除了它與loveshack python,我正在使用'python-mode'。我想在某個時候切換,但現在我正在使用'iPython',它似乎只與'python-mode'兼容。 – hatmatrix
當經由python.el使用python-mode
,具有每Python的緩衝區中的一個的Python殼是默認的。
但是,如果您想要多個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緩衝區使用自己的殼,輸入:
M-x set-variable python-buffer [RET] nil [RET]
這樣做,然後打開一個新的Python緩衝區後,一個新的Python外殼將被用於該緩衝區進入python-switch-to-python
或C-c C-z
後創建。
簡單而甜美 – hatmatrix