TAB completion not working

Bug #1325474 reported by Zeitlinie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

TAB completion does not work for me in the IPython shell.
My system details are:
 GNU Emacs 24.3.1
 IPython 1.0.0
 python-mode-6.1.3
 Python 2.7.6

I've boiled down my init.el to this torso

;;;;;;;;;;;;;;;;;
(require 'package)
(package-initialize)
(require 'python-mode)
(setq-default py-shell-name "ipython")
;;;;;;;;;;;;;;;;;

With that, I do
    M-x ipython RET
to start an IPython shell. At the IPython shell's prompt I type
    In[x]: pr
    TAB
and ... nothing happens ... ?! ... except that in the command buffer
    End of buffer
pops up
I have also tried ESC-TAB and C-M-i instead of TAB only.
In that case I get (instead of 'End of buffer')
'ipython-complete: Wrong type argument: stringp, nil'
in the command buffer.

When I run an IPython shell from a terminal session TAB completion on my system leads to
    In[x]: pr
    TAB
%%prun %precision %profile %prun print property

Additionally, I have exchanged the python-mode-6.1.3 version of
python-mode.elc with that obtained from 'bzr branch lp:python-mode'.
Also with that TAB completion remains non-functional. The only difference is, that the use of ESC-TAB and C-M-i instead of TAB now returns
'ipython-complete: Symbol's function definition is void: position'
in the command buffer.

Any help on how to get TAB completion to work would be most welcome.
Thank you.
Mark

Revision history for this message
Andreas Roehler (a-roehler) wrote :

What do you get from M-TAB, where completion in Python-shell is set to?

TAB just indents. BTW may change that, as many users seems to expect TAB to complete.

Changed in python-mode:
importance: Undecided → Medium
assignee: nobody → Andreas Roehler (a-roehler)
Revision history for this message
Zeitlinie (zeitlinie) wrote :

Well, for me, M-TAB does what it probably does on most window-managed systems: it switches between tasks - independent of Emacs - and I would be very reluctant to change that 'only' because of Emacs IPython TAB-completion ;)

Should I just bind completion to a different key? How? Actually within Emacs I cannot even describe the key M-TAB with C-h k, because it will immediately invoke the systems task switcher.

Thanks for any additional help,
Mark

> TAB just indents.
Yep, I realized that also while writing this report. That is why I went to http://www.gnu.org/software/emacs/manual/html_node/emacs/Symbol-Completion.html, where they claimed, that ESC-TAB and C-M-i would serve as replacement for just TAB alone (which I find awkward). At that place they also point out that M-TAB may not be a good choice on window-managed systems.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 1325474] Re: TAB completion not working

On 02.06.2014 10:37, Zeitlinie wrote:
> Well, for me, M-TAB does what it probably does on most window-managed
> systems: it switches between tasks - independent of Emacs - and I would
> be very reluctant to change that 'only' because of Emacs IPython TAB-
> completion ;)
>
> Should I just bind completion to a different key? How? Actually within
> Emacs I cannot even describe the key M-TAB with C-h k, because it will
> immediately invoke the systems task switcher.
>
> Thanks for any additional help,
> Mark
>
>> TAB just indents.
> Yep, I realized that also while writing this report. That is why I went to http://www.gnu.org/software/emacs/manual/html_node/emacs/Symbol-Completion.html, where they claimed, that ESC-TAB and C-M-i would serve as replacement for just TAB alone (which I find awkward). At that place they also point out that M-TAB may not be a good choice on window-managed systems.
>

Okay, understand. Will change the default for windows-systems

For the moment applying the patch attached will change the key-setting of py-shell-map.
After re-loading TAB should complete.

There is no key for `py-indent-line' than, however C-j should DTRT.

Revision history for this message
Zeitlinie (zeitlinie) wrote :

ehem, just to make sure: by "..window-managed .." systems I did not imply M$-Windows. Eg., mine runs X11/KDE
Will apply the patch now and get back later,
Thanks,
Mark

Revision history for this message
Andreas Roehler (a-roehler) wrote :

On 02.06.2014 11:39, Zeitlinie wrote:
> ehem, just to make sure: by "..window-managed .." systems I did not imply M$-Windows.

Thanks clarifying this. Was heading towards Windows indeed.
Well, most Emacs/Linux-users are used to re-define that keys.

Why not make it easier?

Being inclined to change that for all

Let's see what the Python-Rock users say :)

  Eg., mine runs X11/KDE
> Will apply the patch now and get back later,
> Thanks,
> Mark
>

Revision history for this message
Zeitlinie (zeitlinie) wrote :

No success yet.

Now, with the patch applied, and on a single TAB, Emacs's command buffer says to me:
'Symbol's function definition is void: position'
and the *Messages* buffer contains
'ipython-complete: Symbol's function definition is void: position'

That is exactly what I got previously, using ESC-TAB and C-M-i instead of TAB with launchpad's most recent head version 'bzr branch lp:python-mode'.

Any idea?
Mark

PS.: maybe I should mention, that.for installing the head of the devel branch I byte-compile my local (and now patched) version of the repo and then pick the python-mode.el(c) from there and replace only my systems version of python-model.el(c) with them ... nothing else ... I hope this is ok?

Revision history for this message
Andreas Roehler (a-roehler) wrote :

On 02.06.2014 12:57, Zeitlinie wrote:
> No success yet.
>
> Now, with the patch applied, and on a single TAB, Emacs's command buffer says to me:
> 'Symbol's function definition is void: position'
> and the *Messages* buffer contains
> 'ipython-complete:

so it got something useful to complete already

Symbol's function definition is void: position'
>

that's provived by cl

Please look into python-mode.el at the spot "(require 'cl)"
Remove the eval-when-compile, so it is loaded in any case.

> That is exactly what I got previously, using ESC-TAB and C-M-i instead
> of TAB with launchpad's most recent head version 'bzr branch lp:python-
> mode'.
>
> Any idea?
> Mark
>
> PS.: maybe I should mention, that.for installing the head of the devel
> branch I byte-compile my local (and now patched) version of the repo and
> then pick the python-mode.el(c) from there and replace only my systems
> version of python-model.el(c) with them ... nothing else ... I hope this
> is ok?
>

The gain from compiling is just nothing IMO at a single file, while it creates confusion easily.
Suggest to remove all "*.elc" files here and not to compile personal stuff. That makes sure always the latest version is loaded.

Revision history for this message
Zeitlinie (zeitlinie) wrote :

Yeyh! That did it.
(Wish I'd understand LISP at some point ... or maybe better not ;) )
Great job - thanks!

Should I expect this to be part of an upcoming version, or will this remain specific to just my private version of python-mode?

Mark

Revision history for this message
Andreas Roehler (a-roehler) wrote :

On 02.06.2014 13:55, Zeitlinie wrote:
> Yeyh! That did it.
> (Wish I'd understand LISP at some point ... or maybe better not ;) )
> Great job - thanks!
>
> Should I expect this to be part of an upcoming version, or will this
> remain specific to just my private version of python-mode?
>
> Mark
>

Will change the default so it's convenient without tweaking.
Please re-load and tell when fix is committed.

Cheers,

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote :

On 02.06.2014 13:55, Zeitlinie wrote:
> Yeyh! That did it.
> (Wish I'd understand LISP at some point ... or maybe better not ;) )
> Great job - thanks!
>
> Should I expect this to be part of an upcoming version, or will this
> remain specific to just my private version of python-mode?
>
> Mark
>

As we may need some indentation also,
   introduced combined command `py-shell-complete-or-indent':

   Complete or indent depending on the context.

   If cursor is at current-indentation and further indent
   seems reasonable, indent. Otherwise try to complete.

Let's see if its better now,

Andreas

Changed in python-mode:
status: New → Fix Committed
milestone: none → 6.2.0
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.