[IPython-user] Please change the ipython.el to fix the tab completion issue of ipython with emac
Tue Jan 8 19:32:03 CST 2008
wang frank <email@example.com> writes:
> Hi, Alexander,
> When I run the ipython in the emacs, I found that the tab completion behaves
> different from the ipython running directly from DOS prompt. When you type,
> for example, win and tab key, the ipython will complete the win to
> If you type the tab key again, without the change, ipython.el will display
> something differently since the pattern in ipython.el becomes empty. By
> adding the / in the command, it will skip the / and work normally.
> However, if the file name or directory contains empty, such as Program
> Files, this will not fix the problem. I am not emacs and elisp expert and
> could not figout the issue out.
Ah, ok it looks like ipython recently might have got smarter in its
emacs-interaction (I wouldn't have noticed since I have bound M-shift-tab to
hippie-expand globally and that will complete filenames (inter alia)).
The following is all from vague memory so details might be wrong:
IIRC, the original reason why ipython.el had different completion
functionality from normal ipython, is that ipython delegated some of the
functionality of finding the right completion to readline, which doesn't work
under emacs. So currently ipython.el just tries to find the preceding
expression and passes that to an function that I think I wrote years ago
somewhere in the guts of ipython, that offers some (limited) subset of the
functionality that would otherwise have been provided by readline. But as the
;; XXX currently we go backwards to find the beginning of an
;; expression part; a more powerful approach in the future might be
;; to let ipython have the complete line, so that context can be
;; to do things like filename completion etc.
(beg (save-excursion (skip-chars-backward "a-z0-9A-Z_." (point-at-bol))
Note that your proposed fix won't work for other types of filename (e.g. w/
hyphens, tildes and backslashes in it) and will break identifier search (e.g.
"13.0/some_number<tab>" will be parsed as a single chunk which might cause
breakage, depnding on what __IP.Completer.all_completions does these days).
Since I don't use ipython's completion (outside emacs) as I always run ipython
in emacs, I don't know how smart this completion mechanism has become (e.g.
whether it will complete differently on "cd blah<tab>" then on, say
"help(blah<tab>")) and I don't know whether the code is now factored so that
there's some nice function one can call w/ the *whole line* and it will give
some completions. If there is (or someone volunteers to write it) that would
be the way to go (i.e. replace the skip-chars-backward w/ beginning-of-linea
and modify that function so that it calls ipython-completion-command-string)).
More information about the IPython-user