[IPython-dev] emacs display problems + patch

Stefan van der Walt stefan at sun.ac.za
Fri Sep 15 04:26:49 CDT 2006


Hi all,

I while ago, I mentioned the following problem when running IPython
from within emacs:  if you start emacs, open a python file and use C-c
C-c to pipe the region to IPython (*before* running IPython using C-c
!), the result is garbled.

After looking at the code in ipython.el, I noticed that it *does* try
to prevent this from happening:

(defadvice py-execute-region (around py-execute-buffer-ensure-process)
  "HACK: if `py-shell' is not active or ASYNC is explicitly desired, fall back
  to python instead of ipython."
  (let ((py-python-command (if (and (comint-check-proc "*Python*") (not async))
			       py-python-command
			     ipython-backup-of-py-python-command)))
    ad-do-it))


It accomplishes this by setting py-python-command to "python"
(ipython-backup-of-py-python-command), instead of to "ipython"
(py-python-command).  The problem is that python-mode doesn't examine
py-python-command anywhere but on startup.  Rather, it examines a
variable called py-which-shell.  The attached patch simply changes
py-python-command to py-which-shell.

I'd appreciate it if a couple of people could test it, to be sure that
it works correctly on different versions on emacs.

Thanks
Stéfan
-------------- next part --------------
Index: ipython.el
===================================================================
--- ipython.el	(revision 1777)
+++ ipython.el	(working copy)
@@ -248,9 +248,9 @@
 (defadvice py-execute-region (around py-execute-buffer-ensure-process)
   "HACK: if `py-shell' is not active or ASYNC is explicitly desired, fall back
   to python instead of ipython." 
-  (let ((py-python-command (if (and (comint-check-proc "*Python*") (not async))
-                               py-python-command
-                               ipython-backup-of-py-python-command)))
+  (let ((py-which-shell (if (and (comint-check-proc "*Python*") (not async))
+			    py-python-command
+			  ipython-backup-of-py-python-command)))
     ad-do-it))
 (ad-activate 'py-execute-region)
 


More information about the IPython-dev mailing list