Update: The question still lacks a satisfactory answer.
I would like to "send" code snippets to a IPython interpreter in Emacs 23.2 (Linux). Assuming that I have already started an IPython shell in a buffer in Emacs (e.g. using Python-mode.el and IPython.el), is there a way of selecting a region in a different buffer and "sending" this region to the already-started IPython shell?
I have tried C-c C-c (send-buffer-to-shell) and C-c | (send-region-to-shell), but this only works as long as the code is written in Python and not in IPython (IPython can run Python code). The reason seems to be that, for both commands, Emacs creates a temporary file with .py extension (as opposed to with .ipy extension), which then is interpreted by IPython as "Python-specific code". This prevents me from using IPython-specific features
such as magic commands.
On a separate note, I have also read that Emacs provides M-| ('shell-command-on-region') to run selected regions in a shell. To do this with an IPython interpreter, I have tried setting shell-file-name to my IPython path. However, when I run M-| after selecting a region, Emacs prompts me the following:
Shell command on region:
and if I then type RET, I get the IPython man page on the *Shell Command Output* buffer, without the region being executed. Is there any IPython-specific command that I can use for M-| ('shell-command-on-region') to get IPython run my code?
Thanks!
shell-file-namealone, and simply enter the ipython executable name at the prompt. That's the normal usage forshell-command-on-region, at any rate. The minibuffer history will remember that command, so you can easily repeat it withM-| M-p RET. I'm not sure howcall-process-regionworks, but I imagine it sends the region text to the command as stdin, so as long as the ipython command can deal with receiving a script that way, I would think it ought to work (although if not, it might account for the help text). - phils