Comment 6 for bug 981991

Revision history for this message
Richard Stanton (a-stanton) wrote : RE: [Bug 981991] [NEW] Completion not working in python script buffer

More follow-up, all using the test file:

Print "Hi, Richard"
ex

1) I switched from using bash as my shell to using the default (Windows) shell, with py-shell-name set to "ipython". Completion now works if I press ESC-TAB after the end of the second line.

2) Same as #1, but this time with py-shell-name set to "c:/python27/Scripts/ipython.bat"
Now completion fails again, even with the Windows default shell.

> -----Original Message-----
> From: Richard Stanton
> Sent: Sunday, April 15, 2012 9:22 PM
> To: 'Bug 981991'
> Subject: RE: [Bug 981991] [NEW] Completion not working in python script
> buffer
>
> Further follow-up:
>
> Things go wrong in py-set-ipython-completion-command-string because line
> 6678 sets ipython-version to 0.
>
> The line that fails is
>
> ... (ipython-version
> (when (string-match "ipython" pyshellname)
> (string-to-number (substring (shell-command-to-string (concat
> pyshellname " -V")) 2 -1)))))
>
> By comparison, the following almost identical line in py-set-shell-completion-
> environment works fine:
>
> (setq ipython-version (string-to-number (substring (shell-command-to-
> string (concat py-shell-name " -V")) 2 -1)))
>
> The only difference between the two lines is that one refers to py-shell-
> name and the other to pyshellname.
> py-shell-name is set to "c:/python27/Scripts/ipython.bat", whereas
> pyshellname is set to "ipython".
>
> The latter fails because is causes the following command to be passed to the
> shell: "ipython -V". Because I'm using the bash shell, this command fails (EPD
> ipython is started using a DOS batch file ipython.bat, which bash doesn't find
> when you only tell it to look for "ipython").
>
> It seems to me that both should use py-shell-name, as this would avoid the
> problem.
>
>
> > -----Original Message-----
> > From: Richard Stanton
> > Sent: Sunday, April 15, 2012 5:03 PM
> > To: 'Bug 981991'
> > Subject: RE: [Bug 981991] [NEW] Completion not working in python
> > script buffer
> >
> > Further investigating:
> >
> > At line 11,029 in function ipython-complete,
> > py-set-ipython-completion- command-string... returns the (wrong)
> > result
> >
> > "print(';'.join(__IP.Completer.all_completions('%s'))) #PYTHON-MODE
> > SILENT\n"
> >
> > > -----Original Message-----
> > > From: Richard Stanton
> > > Sent: Sunday, April 15, 2012 4:47 PM
> > > To: 'Bug 981991'
> > > Subject: RE: [Bug 981991] [NEW] Completion not working in python
> > > script buffer
> > >
> > > One more followup: I note that the code ipython is complaining about
> > > below is only supposed to be passed to ipython 0.10, but I'm using
> > > 0.12 (and ipython-version equals 12).
> > >
> > > > -----Original Message-----
> > > > From: Richard Stanton
> > > > Sent: Sunday, April 15, 2012 4:28 PM
> > > > To: 'Bug 981991'
> > > > Subject: RE: [Bug 981991] [NEW] Completion not working in python
> > > > script buffer
> > > >
> > > > Try your code but set
> > > >
> > > > (setq py-shell-name "ipython")
> > > >
> > > > In your init.el first. Completion seems to work if I don't have
> > > > this set, but fails if I do.
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: <email address hidden> [mailto:<email address hidden>] On
> > > Behalf
> > > > > Of Andreas Roehler
> > > > > Sent: Saturday, April 14, 2012 11:53 PM
> > > > > To: Richard Stanton
> > > > > Subject: Re: [Bug 981991] [NEW] Completion not working in python
> > > > > script buffer
> > > > >
> > > > > Am 15.04.2012 02:09, schrieb Richard Stanton:
> > > > > > Public bug reported:
> > > > > >
> > > > > > In r937, when I press ESC-TAB in my python script buffer,
> > > > > > Emacs no longer hangs, which is good.
> > > > > >
> > > > > > However, if I type, say, "ex" and then ESC-TAB, I get the
> > > > > > message
> > > > > >
> > > > > > Can't find completion for "ex"
> > > > > >
> > > > > > Looking further, I see that there is a new buffer called
> > > > > > *IPython*, with contents
> > > > > >
> > > > > >
> > > > > > In [1]: ---------------------------------------------------------------------------
> > > > > > NameError Traceback (most recent call last)
> > > > > > c:\projects\<ipython-input-1-ba21655add90> in<module>()
> > > > > > ----> 1 print(';'.join(__IP.Completer.all_completions('ex')))
> > > > > > ----> #PYTHON-MODE SILENT
> > > > > >
> > > > > > NameError: name '__IP' is not defined
> > > > > >
> > > > > > In [2]:
> > > > > >
> > > > >
> > > > > thanks making a new report
> > > > >
> > > > > can't reproduce with Emacs -Q and python-mode.el - see png
> attached.
> > > > > Please send some example code
> > > > >
> > > > >
> > > > > ** Attachment added: "ex1.png"
> > > > >
> > > > >
> > > >
> > >
> >
> https://bugs.launchpad.net/bugs/981991/+attachment/3069436/+files/ex1.
> > > > > png
> > > > >
> > > > > --
> > > > > You received this bug notification because you are subscribed to
> > > > > the bug report.
> > > > > https://bugs.launchpad.net/bugs/981991
> > > > >
> > > > > Title:
> > > > > Completion not working in python script buffer
> > > > >
> > > > > Status in An Emacs mode for editing Python code:
> > > > > New
> > > > >
> > > > > Bug description:
> > > > > In r937, when I press ESC-TAB in my python script buffer, Emacs no
> > > > > longer hangs, which is good.
> > > > >
> > > > > However, if I type, say, "ex" and then ESC-TAB, I get the
> > > > > message
> > > > >
> > > > > Can't find completion for "ex"
> > > > >
> > > > > Looking further, I see that there is a new buffer called *IPython*,
> > > > > with contents
> > > > >
> > > > >
> > > > > In [1]: ---------------------------------------------------------------------------
> > > > > NameError Traceback (most recent call last)
> > > > > c:\projects\<ipython-input-1-ba21655add90> in <module>()
> > > > > ----> 1 print(';'.join(__IP.Completer.all_completions('ex')))
> > > > > #PYTHON-MODE SILENT
> > > > >
> > > > > NameError: name '__IP' is not defined
> > > > >
> > > > > In [2]:
> > > > >
> > > > > To manage notifications about this bug go to:
> > > > > https://bugs.launchpad.net/python-
> > mode/+bug/981991/+subscriptions