[Python-mode] Patched python-mode with IPython support

Fernando Perez Fernando.Perez at colorado.edu
Fri Nov 5 06:22:21 CET 2004


Dear Python-mode maintainers,

the attached code is a patched version of python-mode 4.62, which incorporates 
some changes to allow python-mode to support ipython[1] instead of the default 
python interpreter in (X)emacs.  The work was done by Alex Schmolck and Prabhu 
Ramachandran, and over time ipython has distributed this specially patched 
version (since python-mode 4.22) to support ipytho's users.

It would be great if these changes could be folded into the python-mode 
mainline code.  As far as I understand, the changes are fairly unobtrusive for 
normal python users, and they would benefit greatly ipython's user base.

Best regards,

Fernando Perez

[1] http://ipython.scipy.org

Below follows the original message from Prabhu regarding this work.

-------- Original Message --------
Subject: Re: [IPython-user] ipython + emacs py-execute-region problem.
Date: Fri, 15 Oct 2004 15:23:25 +0530
From: Prabhu Ramachandran <Prabhu Ramachandran <prabhu_r at users.sourceforge.net>
To: Fernando Perez <Fernando.Perez at colorado.edu>
CC: Bo Peng <ben.bob at gmail.com>, ipython-user at scipy.net
References: <6ea7b543041014093632091eb at mail.gmail.com> 
<416F6CB9.9040005 at colorado.edu>	<16751.32181.153111.604247 at monster.linux.in> 
<416F7EEC.9010709 at colorado.edu>

>>>>> "FP" == Fernando Perez <Fernando.Perez at colorado.edu> writes:

     >> Well, I think Bo means that this does not seem to happen if he
     >> uses Alex's python-mode but does not use ipython.  So it
     >> appears that something funky happens when ipython is used.  I
     >> am not elisp guru either to be able to help.  When will Alex be
     >> back?

     FP> Oh, I misunderstood things then.  My point about the lag in
     FP> the ipython-compatible version of python-mode being an
     FP> unpleaseant situation remains, though.

     FP> I think Alex said a month, and he only left a few days ago.

Nevermind, I have fixed the problem.  I've updated python-mode.el to
the latest version (revision 4.62) available from CVS here:

  http://cvs.sourceforge.net/viewcvs.py/python-mode/python-mode/

I've retained Alex's fixes for IPython support in this version.  I
have also added a defcustom for py-shell-switch-buffers-on-execute
which defaults to true and will therefore switch buffers to the
py-shell when you execute a region.  If you turn it off it disables
this behavior.  So, switching the buffer was a feature and not a bug,
it appears.

So, to get Bo's desired behavior you simply need to do this in your
.xemacs/init.el:

  (require 'python-mode)
  (setq py-shell-switch-buffers-on-execute nil)
  (require 'ipython)


Please find attached a gzipped file containing the new-and-improved
python-mode.el.  I think you could consider sending this in to
python-mode at python.org.  I'm not doing it since I have already spent a
little too much time on this today.

cheers,
prabhu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-mode.el.gz
Type: application/octet-stream
Size: 43659 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-mode/attachments/20041104/c0515123/python-mode.el-0001.obj


More information about the Python-mode mailing list