开发者

Emacs Lisp: Open a new frame, start IPython, run previous buffer

I want to write an ELisp function to start a Python interpreter (IPython) in a new frame and then run the contents of the previous buffer in the IPython interpreter. I am using Emacs 23.3.1, python-mode 6.0 and ipython.el.

Here's my function so far:

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

The output is that:

  1. IPython successfully starts via py-shell.
  2. There is still two windows in the frame, not one like I want.
  3. It doesn't successfully execute the buffer, output is:
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

Any thoughts on how to get either the single window开发者_StackOverflow社区 or the buffer to be executed? Thanks!


Not sure about that python output but in the elisp code you are not setting my-buffer-name to anything (it will be nil). It should be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜