2

C-c C-cバッファまたはファイルを編集し、ヒットしてファイルをIPythonセッションに送信したいと思います。を介して実行するM-x py-shell前に最初に実行すれば、これを達成できます。しかし、私が経由して機能をアドバイスしようとするとpy-execute-bufferC-c C-c

(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と、すべて問題ありません。

どんな考えでもありがたいです-ありがとう!

4

2 に答える 2

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

睡眠あり-それは正しく機能しているからです。

于 2012-02-13T19:33:28.217 に答える
0

現在の python-mode.el では、

bzr ブランチ lp:python-mode

ただ Mx py-execute-buffer-ipython RET

応答。py-shell-name を「ipython」に設定

py-execute-buffer は DTRT である必要があります - シバンが特に指示しない限り

上記の特定のコマンドはシバンに先行します

デフォルトの「ipython」の代わりに、パスを含むバージョンを指すことができます

于 2012-12-01T19:43:45.907 に答える