[IPython-user] ipython in emacs <tab> filename completion (again)

Arthur Woll aw30@cornell....
Fri Oct 9 08:59:09 CDT 2009


OK -- so it turns out I had to STFW, but More Carefully than I had done 
before. Is STFWMC in fashion?

Solution 
1(http://www.nabble.com/TAB-Completion-for-emacs-with-python-2.6-td22025019.html) 
:

Edit ipython.el rev 2927 (which is in the ipython distro at 
ipython-0.10/docs/emacs/) line 314 to read

"print(';'.join(__IP.Completer.all_completions('%s')))\n"

and NOT

"print ';'.join(__IP.Completer.all_completions('%s')) #PYTHON-MODE 
SILENT\n"

as distributed. (Is there a context where the later is correct? If not,  
can A.S. move to Rev 2928? )

Solution 2 (Really, a variant of solution 1, from 
http://www.emacswiki.org/emacs/PythonMode#toc14)

Add:

(setq ipython-completion-command-string 
"print(';'.join(__IP.Completer.all_completions('%s')))\n")

to your .emacs file (or alternatively ~/Library/Preferences/Aquamacs\ 
Emacs/Preferences.el)

Summary:

The minimum mods to my Aquamacs dists  (1.9 based on GNU 22.3.1 and 
2.0preview based on GNU 23.1.1)  that get ipython TAB completion working 
(and hopefully debugging) are:

1) Stick python-mode.el (5.1.0) and ipython.el (modified as above in 
Solution 1, or corrected as in Solution 2) into my load path (I use the 
Aquamacs default location ~/Library/Preferences/Aquamacs\ Emacs/)

2) put a line:
(require 'ipython)
into either ~/.emacs OR (the Mac-conforming Aquamacs location 
~/Library/Preferences/Aquamacs\ Emacs/Preferences.el)

Note:  see iptyhon.el for additional nice customizations to access history

Suggestion:

It might be nice (for newcomers like me) to have this info more explicit 
on the iPython site, e.g. here:

http://ipython.scipy.org/moin/Cookbook/IPythonEmacs23

and/or here:

http://ipython.scipy.org/doc/rel-0.10/html/config/initial_config.html?highlight=emacs#x-emacs-configuration

With the mods above, you can start an ipython shell with M-x py-shell. 
(Option - x py-shell for me).

-Arthuir

> Greetings all,
>
> I am [an ipython novice, and] using ipython inside emacs (on Mac OS 
> 10.5, ipython 0.10, python 2.6). My setup is virtually identical to 
> that described here:
>
> http://mail.scipy.org/pipermail/ipython-user/2008-September/005791.html
>
> but with python-mode 5.1.0  (ipython.el Revision 2297 )
>
> My problem is identical to that described earlier in the same thread:
>
> http://mail.scipy.org/pipermail/ipython-user/2008-September/005777.html
>
> but the solution isn't explicitly mentioned in that thread as far as I 
> can tell.
>
> (For good measure, I also tested the settings listed here:
> http://mail.scipy.org/pipermail/ipython-user/2008-September/005781.html
> with identical results.)
>
> To reiterate the problem: Filename completion on tab does not appear 
> to work properly within Emacs. That is,
>
> In [14]: cd Py<tab>
>
> results in:
>
> In [14]:    ....: cd Py
>
>
> If, alternatively, I am running ipython inside tcsh or bash (*OR* 
> within an ansi-term inside emacs), the result is
>
> In [14]: cd Python/
>
> as desired.
>
> Is there a known fix?
>
> -Arthur
>
> Here is my Preferences.el (I am using Aquamacs 1.9)
>
>
> ;; ************************************
> ;; BEGIN PYTHON - RELATED CUSTOMIZATION
> ;; ************************************
> (require 'comint)
> (define-key comint-mode-map [up]
>   'comint-previous-matching-input-from-input)
> (define-key comint-mode-map [down]
>   'comint-next-matching-input-from-input)
> (define-key comint-mode-map [(control down)]
>    'comint-next-input)
> (define-key comint-mode-map [(control up)]
>    'comint-previous-input)
>
> (setq comint-completion-autolist t    ;list possibilities on partial
>                    ;completion
>       comint-completion-recexact nil    ;use shortest compl. if
>                    ;characters cannot be added
>       ;; how many history items are stored in comint-buffers (e.g. py- 
> shell)
>       ;; use the HISTSIZE environment variable that shells use (if  
> avail.)
>       ;; (default is 32)
>       comint-input-ring-size (string-to-number (or (getenv  
> "HISTSIZE") "100")))
>
> (add-to-list 'interpreter-mode-alist '("python" . python-mode))
> (require 'ipython)
>
> (setq py-python-command-args '("-i" "-pylab" "-colors" "LightBG"))
> ;; ************************************
> ;; END PYTHON - RELATED CUSTOMIZATION
> ;; ************************************
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> IPython-user mailing list
> IPython-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>   



More information about the IPython-user mailing list