[Zope-dev] emacs/pdbtrack users - enhanced to handle Zope's "Script (Python)"

Ken Manheimer klm@zope.com
Sun, 2 Mar 2003 19:49:23 -0500 (EST)


For those of you that use emacs and pdbtrack, i've extended it a bit
to be useful with non-local scripts - eg, through-the-web python
scripts, or filesystem-based code on the server's filesystem, hence
not findable in your filesystem at the compiled-in path.

Pdbtrack is part of emacs python-mode which displays the source file
and indicates the current line as you step through the code with the
python debugger, pdb, in an emacs shell buffer.  It uses information
in the pdb trace to find the file and the line, but couldn't do
anything if the path of the file isn't valid on your system - eg if
the script was compiled on a different system, with the source in a
different place or noexistent on your system, or if there is no valid
path for the script, eg through-the-web scripts.

With the changes, when pdbtrack can't find the file at the indicated
path, it tries to find it in existing buffers.  It uses the function
name and looks through the buffers in your emacs session, from most to
least recent, looking for a python-mode buffer that either is named
for the function or has a definition (def or class) for that function.

So to get source tracking for code that's not resident in your
filesystem, you put a copy of the script in a buffer, and pdbtrack
will find it.  (It also allows an offset for the leading '##'
meta-comment lines in filesystem copies of python scripts.)

You can find the new version at:

  http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Misc/python-mode.el?rev=4.30&content-type=text/vnd.viewcvs-markup

It's pretty fresh - i'd be happy if people would give it a try, and
let me know if you hit problems with it.

--
Ken Manheimer
klm@zope.com