emacs python-mode:指定向哪个 python shell 发送命令

发布于 2024-12-18 13:22:26 字数 433 浏览 7 评论 0原文

对此问题的跟进 - 如果我在 emacs 中运行两个 python shell,如何指定每个 python 脚本缓冲区中的哪些 shell 命令发送到?我怀疑它与 python-buffer 和 python-set-proc 有关,但将这些变量设置为 shell 的名称显然不是解决方案。

编辑:实际上,由于我使用的是python-mode而不是loveshack python,所以它可能与python-bufferpython-set-proc。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巴黎夜雨 2024-12-25 13:22:26

您可以为python-buffer设置一个新值。

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

然后M-xmy-python-set-procRET*Python*RET,
M-xmy-python-set-procRET*Python*<2>;RET

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.

半世蒼涼 2024-12-25 13:22:26

在任何 Python 缓冲区中,您可以使用变量 py-which-bufname 来控制代码在执行时发送到哪个 Python shell。该变量是缓冲区本地的,因此为了将其设置为自定义值,您需要通过按 M-: 并输入以下内容从缓冲区内更改它,

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

这也使您可以轻松地快速创建进程缓冲区:如果将py-which-bufname设置为没有相应进程缓冲区的名称,则只需发出Cc!< /code> 快速创建一个。

华泰

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

小嗷兮 2024-12-25 13:22:26

py-shell-name 设置默认值,该默认值可能会被命令覆盖。

如果缓冲区代码包含指定 pythonVERSION 的 shebang,则该值优先于默认设置。

您可以通过调用 py-execute-buffer-pythonVERSION 类的命令来通过特定的 pythonVERSION 强制执行缓冲区

请参阅菜单 PyExec,条目执行缓冲区 ...

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 ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文