-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Martin has a need idea...
Begin forwarded message: > From: Martin Blais <[EMAIL PROTECTED]> > Date: March 31, 2008 12:49:23 PM EDT > Subject: Idea for python-mode > > Here is an idea I've had for emacs python-mode: something > like (find-library) in Emacs, but for Python:: > > (defun string-rstrip (str) > "Strips the whitespace at the end of string STR." > (string-match "[ \t\n]*\\'" str) > (substring str 0 (match-beginning 0))) > > (defun py-find-library (modname) > "Run a subordinate python to find out where a module is located > and load it in a buffer." > (interactive "MModule name: ") > (let* ((program (format "import %s as m; print m.__file__" > modname)) > (filename > (replace-regexp-in-string > "\\(\\.pyc\\|\\.pyo\\)" ".py" > (string-rstrip > (shell-command-to-string (format "python -c '%s'" > program)))))) > (unless (file-exists-p filename) > (error (format "File %s could not be found." filename))) > (find-file filename) > )) > > Feel free to scavenge, adapt and integrate in python-mode if > you like. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBSAE5I3EjvBPtnXfVAQLItgP8D0x1WeoTtBk5nyWZ5ZcFxb97Hxio90v3 cM+8lMxk5zzdKmI+hrtQKdJU2vDKGQSUMbewNnBVYWq3b/ZFudxAECRQgCAivsVg d6YG5B3RCycm/WKdkxcSeGuHkredBH97iUb9c50Al53Rg+SMLek4gwKVFQ+Zk2RN wnZAiEZaJEQ= =+vdG -----END PGP SIGNATURE----- _______________________________________________ Python-mode mailing list Python-mode@python.org http://mail.python.org/mailman/listinfo/python-mode