2011-07-09 7 views
2

私はバッファまたはファイルを編集したいと思って、C-c C-cを押してファイルをIPythonセッションに送ってください。初めてM-x py-shellを実行してからpy-execute-bufferを実行してC-c C-cを実行すると、これを実現できます。私はエラーを取得する関数の前にpy-shellを実行するには、emacsのpy-execute-bufferにどのようにアドバイスしますか?

(defadvice py-execute-buffer (before open-py-shell-first) 
    (let ((remember-window (selected-window)) 
    (remember-point (point))) 
    (generate-new-buffer "*Python*") 
    (call-interactively 'py-shell) 
    (select-window remember-window) 
    (goto-char remember-point))) 
(ad-activate 'py-execute-buffer) 

経由で機能を助言しようとした場合でも:

## working on region in file /var/folders/6o/6o08knx-FVOhrvCbYyrRDU+++TI/-Tmp-/python-29189FKe.py... 
Python 2.7.1 (r271:86832, Feb 5 2011, 13:58:58) 
Type "copyright", "credits" or "license" for more information. 

IPython 0.10.1 -- An enhanced Interactive Python. 
?   -> Introduction and overview of IPython's features. 
%quickref -> Quick reference. 
help  -> Python's own help system. 
object? -> Details about 'object'. ?object also works, ?? prints more. 

In [1]: --------------------------------------------------------------------------- 
IOError         Traceback (most recent call last) 

/Users/aresnick/Desktop/<ipython console> in <module>() 

IOError: [Errno 2] No such file or directory: '/var/folders/6o/6o08knx-FVOhrvCbYyrRDU+++TI/-Tmp-/python-29189FKe.py' 

In [2]: 

作成された一時ファイルはIPythonで見られていないように見えるでしょうか?私が今度は私のPythonファイルに戻ってpy-execute-bufferを再実行すれば、すべてうまくいきます。

ご意見ありがとうございます - ありがとう!

+0

私は 'py-execute-buffer'コマンドを持っていません。これは 'ipython.el'のものですか? –

答えて

0

は、私はいくつかの解決策を見つけたと思う:

(defun my-py-execute-buffer() 
    (interactive) 
    (set 'code-buffer (current-buffer)) 
    (unless (get-buffer "*Python*") 
    (py-shell) 
    (set-buffer code-buffer) 
    (sleep-for 0.2)) 
    (py-execute-buffer)) 

で睡眠のために、それが正しく動作しています。 python-モード

ちょうどM-X PY-実行バッファ-ipythonのRET

Respの現在のpython-mode.el、

のbzr支店LPに

0

。設定PY-シェルの名前での「ipython」

PY-バッファ実行DTRT必要があります - シェバングがそう告げない限りを

特定のコマンドは、上記の前シェバング

代わりにあなたがを指して「ipython」デフォルトのバージョンも含めて、

関連する問題