我想编写一个ELisp函数来在新框架中启动Python解释器(IPython),然后在IPython解释器中运行前一个缓冲区的内容。我使用的是Emacs 23.3.1,python-mode 6.0和ipython.el。
到目前为止,这是我的功能:
(defun python-run ()
"Use to run Python programs."
(interactive)
(let (my-buffer-name buffer-name)
(select-frame (make-frame))
(set-frame-size (selected-frame) 90 60)
(py-shell)
(delete-other-windows)
(switch-to-buffer my-buffer-name)
(py-execute-buffer)))
输出是:
py-shell
成功启动。In [1]: execfile(r'/var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-/python-26368Zoi.py') # PYTHON-> MODE --------------------------------------------------------------------------- IOError Traceback (most recent call last) /Users/ben/ in () ----> 1 execfile(r'/var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-/python-26368Zoi.py') # PYTHON-> MODE IOError: [Errno 2] No such file or directory: '/var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-> /python-26368Zoi.py' In [2]: ## working on region in file /var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-/python-> 26368fXv.py... execfile(r'/var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-/python-26368fXv.py') # PYTHON-MODE File "/var/folders/so/sox1TODiEE0hAb6AVusYq++++Tc/-Tmp-/python-26368fXv.py", line 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ^ SyntaxError: invalid syntax
有关如何获取单个窗口或缓冲区的任何想法?谢谢!
答案 0 :(得分:0)
不确定那个python输出但是在elisp代码中你没有将my-buffer-name设置为任何东西(它将是nil)。它应该是:
(let ((my-buffer-name (buffer-name))
....