(defun send-buffer-to-ipython ()
"Send current buffer to the running ipython process."
(interactive)
(let* ((ipython-buffer "*ansi-term*") ; the buffer name of your running terminal
(proc (get-buffer-process ipython-buffer)))
(unless proc
(error "no process found"))
(save-buffer)
(process-send-string proc
(format "execfile(\"%s\")\n" (buffer-file-name)))
(pop-to-buffer ipython-buffer) ; show ipython and select it
;; (display-buffer ipython-buffer) ; show ipython but don't select it
))
用python-模式.el在
M-x自定义变量RET py shell name RET ansi term
M-x ansi术语RET ipython RET
在ipythonshell中执行Python缓冲区中的C-C C-C
注意:默认py shell名称前面有一个shebang
https://launchpad.net/python-mode/trunk/6.0.12/+download/python-mode.el-6.0.12.tar.gz
然后将命令
^{pr2}$send-buffer-to-ipython
绑定到您喜欢的任何键上。我把它绑定到C-c C-c
我有一个次要模式用于此目的(除了它不是IPython特有的,我主要将它用于shell脚本):isend-mode。在
以下是如何使用它:
打开
ansi-term
缓冲区:M-x
ansi-term
RET/usr/bin/ipython
RET使用要执行的代码打开缓冲区,并将其与解释器缓冲区关联:
M-x
isend-associate
RET*ansi-term*
RET在python缓冲区中点击C-RET将当前行发送到
ansi-term
缓冲区中的解释器。相关问题 更多 >
编程相关推荐