将代码从Python缓冲区发送到从M-x ansi-term运行的IPython会话 [英] Sending code from Python buffer to IPython session running from M-x ansi-term

查看:89
本文介绍了将代码从Python缓冲区发送到从M-x ansi-term运行的IPython会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我在Emacs中使用 M-x ansi-term 打开终端模拟器。这在Emacs中使用我选择的shell打开一个缓冲区。说我然后从这个shell运行 ipython 。可以从Emacs中的Python代码的另一个缓冲区发送代码到这个 ipython 会话吗?如果是这样的话

解决方案

我有一个小的模式为此目的(除了它不是IPython特定的,我大都使用它对于shell脚本): isend-mode



这是你如何使用它:


  1. 打开一个 ansi-term buffer:



    Mx ansi-term RET / usr / bin / ipython RET


  2. 使用您要执行的代码打开缓冲区,并将其与解释器缓冲区相关联:



    Mx isend-准 RET * ANSI-术语* RET


  3. 在python缓冲区中点击 C-RET ,将当前行发送到 ansi-term 缓冲区。



Say I open a terminal emulator in Emacs with M-x ansi-term. This opens a buffer in Emacs with the shell of my choice. Say I then run ipython from this shell. Can I send code to this ipython session from another buffer with Python code in Emacs? If so how?

解决方案

I have a minor mode for this purpose (except it is not IPython-specific and I mostly use it for shell scripts): isend-mode.

Here is how you would use it:

  1. Open an ansi-term buffer:

    M-xansi-termRET/usr/bin/ipythonRET

  2. Open the buffer with the code you want to execute, and associate it to the interpreter buffer:

    M-xisend-associateRET*ansi-term*RET

  3. Hit C-RET in the python buffer to send the current line to the interpreter in the ansi-term buffer.

这篇关于将代码从Python缓冲区发送到从M-x ansi-term运行的IPython会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆