2011-08-16 82 views
1

我想编写一个ELisp函数在新框架中启动Python解释器(IPython),然后在IPython解释器中运行前一个缓冲区的内容。我使用Emacs 23.3.1,python-mode 6.0和ipython.el。Emacs Lisp:打开一个新框架,启动IPython,运行以前的缓冲区

这里是我的功能至今:

(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))) 

输出是:

  1. IPython的通过py-shell成功启动。
  2. 框架中还有两个窗口,没有一个像我想要的那样。
  3. 它不会成功执行缓冲,输出为:
 
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

不知道该python输出,但在elisp代码中,您不是将my-buffer-name设置为任何值(它将为零)。它应该是:

(let ((my-buffer-name (buffer-name)) 
    .... 
+0

谢谢你。现在有些作品。第一次调用python-run时,当它试图执行py-execute-buffer时,它会失败,但下次运行。 – Ben

相关问题