Python emacs mode (newbie)
Thomas Heller
thomas.heller at ion-tof.com
Mon Feb 19 07:39:53 EST 2001
The following lets you enter a (possibly dotted)
python module name in the minibuffer after
entering M-x find-pymodule RET.
Comments welcome, I'm new to elisp.
This is for the .emacs file:
(defun find-pymodule ()
(interactive)
(let ((keyword (symbol-near-point)))
(let ((text (shell-command-to-string
(format "cmd.exe /c find-pymodule.py %s"
(read-from-minibuffer "module? " keyword)))))
(find-file text))))
and this is somewhere on the path, in find-pymodule.py:
import imp, sys, string
def find(parts, path=None):
top = parts[0]
file, pathname, stuff = imp.find_module(top, path)
if not parts[1:]:
return pathname
mod = imp.load_module(top, file, pathname, stuff)
return find(parts[1:], mod.__path__)
if __name__ == '__main__':
try:
sys.stdout.write(find(string.split(sys.argv[1], '.')))
except ImportError:
pass
I prefer to do the actual searching in python, not elisp
Thomas
More information about the Python-list
mailing list