unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Python completion when using pdb (M-x pdb)
@ 2017-05-23 16:06 Maxim Cournoyer
  2017-05-28 14:38 ` Charles A. Roelli
  0 siblings, 1 reply; 2+ messages in thread
From: Maxim Cournoyer @ 2017-05-23 16:06 UTC (permalink / raw)
  To: help-gnu-emacs

Hello Emacs!

I've recently discovered that Emacs provides it's own completion
mechanism, for example when running M-x run-python. This works even with
the vanilla Python interpreter, which doesn't provide such completion
out-of-the-box itself, which is nice!

However, I couldn't make completion work in pdb. My understanding, when
searching on the web, is that it *should* work in pdb too. For example,
the commit a92066b (python.el: Fix completion for pdb interactions) made
two years ago would suggest that it should work.

Things I've tried:

1. Using M-x pdb: The buffer is not even set up for completion with
python.el. C-h k <TAB> reveals that it simply calls
`indent-for-tab-command'.

2. Once debugging, I used 'M-x run-python'. The Python process "inherited"
the already running pdb process and I could see the (Pdb) prompt from
there. (The same could have been attained by M-x run-python at first,
then execfile some/file (python 2) in wich "import pdb; pdb.set_trace()"
is used.

This time, C-h k <TAB> revealed it was bound to
`python-shell-completion-complete-or-indent', which is better. However,
attempting to tab-complete any symbol at the pdb prompt returned 'No
match' at the minibuffer.

I also tested with realgud instead of gud, with the same result.

Any pointers would be very appreciated :)

Maxim



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Python completion when using pdb (M-x pdb)
  2017-05-23 16:06 Python completion when using pdb (M-x pdb) Maxim Cournoyer
@ 2017-05-28 14:38 ` Charles A. Roelli
  0 siblings, 0 replies; 2+ messages in thread
From: Charles A. Roelli @ 2017-05-28 14:38 UTC (permalink / raw)
  To: Maxim Cournoyer, help-gnu-emacs

Hi Maxim,

I use PDB all the time and was wondering about this too.  From what I've
found, it looks like M-x pdb does not implement completion -- although it
probably could be done by reusing some of the code already written
in python.el.

However, python.el does come with a "PDB tracking" function that works like
this: as soon as a "(Pdb)" prompt is detected in a Python shell buffer
(done by the function `python-pdbtrack-comint-output-filter-function'),
the line/file where the Python interpreter stopped is shown in a buffer.
(I've never tried it out, but this is what I can gather from reading the
code).  To me this seems more limited than using M-x pdb, since you miss
out on the helpful features of GUD (traversing stack frames, printing
expressions in tooltips, setting breakpoints with C-x C-a C-b, etc.).
But it may still be helpful in some cases.

Apparently, though, completion in a "PDB tracking" Python shell buffer is
supposed to work, looking at the following lines from
`python-shell-completion-at-point':

          (completion-fn
           (with-current-buffer (process-buffer process)
             (cond ((or (null prompt)
                        (< (point) (cdr prompt-boundaries)))
                    #'ignore)
                   ((or (not python-shell-completion-native-enable)
                        ;; Even if native completion is enabled, for
                        ;; pdb interaction always use the fallback
                        ;; mechanism since the completer is changed.
                        ;; Also, since pdb interaction is single-line
                        ;; based, this is enough.
                        (string-match-p python-shell-prompt-pdb-regexp 
prompt))
                    #'python-shell-completion-get-completions)
                   (t #'python-shell-completion-native-get-completions)))))

i.e., the completion code is supposed to use the fallback method for
PDB.  If you can put together a simple example where this isn't working,
it would be helpful if you filed a bug report with M-x report-emacs-bug,
and we can discuss this further there.

Cheers,
Charles


On 23/05/2017 18:06, Maxim Cournoyer wrote:
> Hello Emacs!
>
> I've recently discovered that Emacs provides it's own completion
> mechanism, for example when running M-x run-python. This works even with
> the vanilla Python interpreter, which doesn't provide such completion
> out-of-the-box itself, which is nice!
>
> However, I couldn't make completion work in pdb. My understanding, when
> searching on the web, is that it *should* work in pdb too. For example,
> the commit a92066b (python.el: Fix completion for pdb interactions) made
> two years ago would suggest that it should work.
>
> Things I've tried:
>
> 1. Using M-x pdb: The buffer is not even set up for completion with
> python.el. C-h k <TAB> reveals that it simply calls
> `indent-for-tab-command'.
>
> 2. Once debugging, I used 'M-x run-python'. The Python process "inherited"
> the already running pdb process and I could see the (Pdb) prompt from
> there. (The same could have been attained by M-x run-python at first,
> then execfile some/file (python 2) in wich "import pdb; pdb.set_trace()"
> is used.
>
> This time, C-h k <TAB> revealed it was bound to
> `python-shell-completion-complete-or-indent', which is better. However,
> attempting to tab-complete any symbol at the pdb prompt returned 'No
> match' at the minibuffer.
>
> I also tested with realgud instead of gud, with the same result.
>
> Any pointers would be very appreciated :)
>
> Maxim
>
>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-28 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23 16:06 Python completion when using pdb (M-x pdb) Maxim Cournoyer
2017-05-28 14:38 ` Charles A. Roelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).