开发者

How can I set up two, parallel buffers in emacs to edit Python files in one and execute in an IPython shell in the other?

I'm trying to setup ipython.el in emacs23. I've successfully installed it (after putting python-mode.el in my load-path to supplant python.el which comes pre-installed with emacs). And I can even get it to run via M-x py-shell, etc.

The interface seems to be pretty poorly setup, and I was wondering if I was doing it wrong, or if I need to customize it to make it work the way I'd like.

In short, the workflow I'd like to have:

  • 开发者_如何学运维in one or more buffers, edit Python code
  • When I hit C-c C-c in that buffer, either execute the Python code in that buffer in the open IPython shell buffer (if there is one) or open up another buffer to do that.

But what happens right now is:

  • With the IPython shell in one buffer and the Python file in the other, if I hit C-c C-c in the Python file buffer, the file buffer switches to the IPython buffer (meaning I now have two, duplicated iPython buffers) and the file is executed.
  • This is annoying.

I'm pretty new to elisp, but my understanding of defadvice is that I could advise around python-execute-buffer to take note of the existing file buffer, run python-execute-buffer, and then switch back to the original file buffer as a workaround.

This seems pretty silly. Any suggestions for better ways to accomplish this would be appreciated!

If it matters: I'm on OS X 10.6.8 with IPython 0.10.1 running Emacs 24.0.50.

Thanks in advance!


Turns out that simply installing python-mode.el and anything-ipython.el and putting

(require 'python-mode)
(require 'ipython)
(require 'anything-ipython)
(add-hook 'python-mode-hook #'(lambda ()
                                (define-key py-mode-map (kbd "C-<tab>") 'anything-ipython-complete)))
(add-hook 'ipython-shell-hook #'(lambda ()
                                  (define-key py-mode-map (kbd "C-<tab>")
                        'anything-ipython-complete)))

in my .emacs made everything work just how I wanted if py-shell is executed before py-execute-buffer (so that C-c C-c) executes the code in the shell instead of just opening up the *Python Output* buffer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜