From barry at python.org Sun Apr 13 00:35:11 2008 From: barry at python.org (Barry Warsaw) Date: Sat, 12 Apr 2008 18:35:11 -0400 Subject: [Python-mode] Fwd: Idea for python-mode References: <20080331164923.D56571142B3@banane.furius.ca> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Martin has a need idea... Begin forwarded message: > From: Martin Blais > 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----- From yoda at isr.ist.utl.pt Tue Apr 29 20:24:53 2008 From: yoda at isr.ist.utl.pt (Rodrigo Ventura) Date: Tue, 29 Apr 2008 18:24:53 -0000 Subject: [Python-mode] patch to allow file completion in py-shell Message-ID: Hello, I'm sending this this tiny patch to python-mode.el so that py-shell supports file completion after hiting the TAB key (and M-TAB lists possible completions): --------------------- cut here ---------------------------- --- python-mode.el.orig 2008-04-29 16:42:04.000000000 +0100 +++ python-mode.el 2008-04-29 16:46:08.000000000 +0100 @@ -708,9 +708,10 @@ (if py-shell-map nil (setq py-shell-map (copy-keymap comint-mode-map)) - (define-key py-shell-map [tab] 'tab-to-tab-stop) (define-key py-shell-map "\C-c-" 'py-up-exception) (define-key py-shell-map "\C-c=" 'py-down-exception) + (define-key py-shell-map "\t" 'comint-dynamic-complete-filename) + (define-key py-shell-map "\e\t" 'comint-dynamic-list-filename- completions) ) (defvar py-mode-syntax-table nil --------------------- cut here ---------------------------- Cheers, Rodrigo Ventura Institute for Systems and Robotics (www.isr.ist.utl.pt) Instituto Superior T?cnico Lisbon, Portugal