ffevotte / isend-mode.el

Interactively send parts of an Emacs buffer to an interpreter
77 stars 17 forks source link

Working with IPython #3

Closed amelio-vazquez-reina closed 11 years ago

amelio-vazquez-reina commented 11 years ago

Note: This issue is a follow up on this StackOverflow thread

@ffevotte You mentioned there is a way of sending %paste commands to an IPython session (which would effectively make the IPython interpreter run the most recent item in the kill ring) . I think you said there is a hook we can use for this, but I could not find the info on the documentation. Would you mind elaborating more on this? Thanks!

For reference: I git cloned the repository and am working on the ipython branch and with the most recent commit as of today (Jan. 24, 2013):

commit 8bf12cfb81bb64977b682f47e4140e774bc000d1
Author: François Févotte <fevotte@gmail.com>
Date:   Tue Dec 18 11:03:41 2012 +0100

    Prepared packaging with MELPA
ffevotte commented 11 years ago

The commit you mention is the latest one on master. If you checkout the ipython branch, the latest commit you should see (as of now) is bd60450e54a1cad48a75d4ed8940d887016a44f8.

Basically, the least error-prone way to test the new iPython features consists in putting this in your init file:

(setq isend-skip-empty-lines nil)
(setq isend-strip-empty-lines nil)
(setq isend-delete-indentation nil)
(setq isend-end-with-empty-line nil)
(setq isend-send-line-function 'insert-buffer-substring)
(setq isend-send-region-function 'isend--ipython-cpaste)

This will use %cpaste to paste code in the iPython buffer, which I tend to prefer to %paste since it allows explicitly seeing the pasted text. You may want to use %paste instead by replacing the last line with:

(setq isend-send-region-function 'isend--ipython-paste)

For more details (including easier setup using hooks as I mentioned in the SO thread), take a look at the README in the ipython branch.

amelio-vazquez-reina commented 11 years ago

This is fantastic. Thanks so much @ffevotte. I have been using this ever since you posted this.

ffevotte commented 11 years ago

Glad to see it! I'll merge this into master, then...