ipython prompt missed

Bug #944242 reported by Andreas Roehler
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
New
Medium
Andreas Roehler

Bug Description

I just installed python-mode 6.0.4 in Emacs 23.4 under OS X, and was happy to see that completion at the command prompt works very nicely. However, I then switched to using ipython rather than python as the shell (by editing py-shell-name). ipython is invoked fine, but when I try to complete using TAB, I think it has trouble understanding the ipython prompt, throwing up the following error:

Debugger entered--Lisp error: (error "No prompt found or `comint-prompt-regexp' not set properly")
  signal(error ("No prompt found or `comint-prompt-regexp' not set properly"))
  error("No prompt found or `comint-prompt-regexp' not set properly")
  py-shell-redirect-send-command-to-process("" #<buffer *pyshellcomplete-output*> #<process /Library/Frameworks/Epd64.Framework/Versions/7.2/Bin/Ipython> nil t)
  (save-current-buffer (set-buffer procbuf) (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while (not comint-redirect-completed) (accept-process-output proc 1)))
  (with-current-buffer procbuf (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while (not comint-redirect-completed) (accept-process-output proc 1)))
  (if lines (with-current-buffer procbuf (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while ... ...)))
  (progn (if lines (with-current-buffer procbuf ... ...)) (with-current-buffer outbuf (delete-region ... ...)) (with-current-buffer procbuf (py-shell-redirect-send-command-to-process cmd outbuf proc nil t) (while ... ...)) (with-current-buffer outbuf (buffer-substring ... ...)))
  (condition-case nil (progn (if lines ...) (with-current-buffer outbuf ...) (with-current-buffer procbuf ... ...) (with-current-buffer outbuf ...)) (quit (with-current-buffer procbuf ... ...) (signal ... nil)))
  (unwind-protect (condition-case nil (progn ... ... ... ...) (quit ... ...)) (if (with-current-buffer procbuf comint-redirect-completed) (while lines ... ... ...)))
  (if (and proc (not py-file-queue)) (unwind-protect (condition-case nil ... ...) (if ... ...)))
  (let* ((proc ...) (cmd ...) (procbuf ...) (outbuf ...) (lines ...)) (if (and proc ...) (unwind-protect ... ...)))
  py-shell-execute-string-now(#("\ndef print_completions(namespace, text, prefix=''):\n for name in namespace:\n if name.startswith(text):\n print prefix + name\n\ndef complete(text):\n import __builtin__\n import __main__\n if '.' in text:\n terms = text.split('.')\n try:\n if hasattr(__main__, terms[0]):\n obj = getattr(__main__, terms[0])\n else:\n obj = getattr(__builtin__, terms[0])\n for term in terms[1:-1]:\n obj = getattr(obj, term)\n print_completions(dir(obj), terms[-1], text[:text.rfind('.') + 1])\n except AttributeError:\n pass\n else:\n import keyword\n print_completions(keyword.kwlist, text)\n print_completions(dir(__builtin__), text)\n print_completions(dir(__main__), text)\ncomplete('a.')\n" 829 831 (fontified t)))
  (setq result (py-shell-execute-string-now (format "\ndef print_completions(namespace, text, prefix=''):\n for name in namespace:\n if name.startswith(text):\n print prefix + name\n\ndef complete(text):\n import __builtin__\n import __main__\n if '.' in text:\n terms = text.split('.')\n try:\n if hasattr(__main__, terms[0]):\n obj = getattr(__main__, terms[0])\n else:\n obj = getattr(__builtin__, terms[0])\n for term in terms[1:-1]:\n obj = getattr(obj, term)\n print_completions(dir(obj), terms[-1], text[:text.rfind('.') + 1])\n except AttributeError:\n pass\n else:\n import keyword\n print_completions(keyword.kwlist, text)\n print_completions(dir(__builtin__), text)\n print_completions(dir(__main__), text)\ncomplete('%s')\n" word)))
  (if (equal word "") (tab-to-tab-stop) (setq result (py-shell-execute-string-now ...)) (if (eq result nil) (message "Could not do completion as the Python process is busy") (let ... ...)))
  (let ((word ...) result) (if (equal word "") (tab-to-tab-stop) (setq result ...) (if ... ... ...)))
  py-shell-complete()
  call-interactively(py-shell-complete nil nil)

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

Hi,

completion should work with current trunk. Can you check out the and try again?

thanks,

Andreas

Revision history for this message
Richard Stanton (a-stanton) wrote : RE: [Bug 944242] Re: ipython prompt missed
Download full text (5.7 KiB)

Completion now works, though there's one very minor oddity. Sometimes, when I press TAB to complete, the completion does what it's supposed to do, but in addition I get a new input line, as if I'd previously pressed Return without any text.

For example,

In [2]: import numpy as np

In [3]: a = np.ar[now press TAB]

A completion window opens fine, but the shell window now shows

In [2]: import numpy as np

In [3]:
In [4]: a = np.ar

Every time I press TAB, I get another blank input line inserted before the current line.

If I only get as far as typing "np.a" before pressing TAB, I don't get another input line. Minor, as I said, but odd...

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Andreas Roehler
Sent: Thursday, March 01, 2012 11:27 AM
To: Richard Stanton
Subject: [Bug 944242] Re: ipython prompt missed

Hi,

completion should work with current trunk. Can you check out the and try again?

thanks,

Andreas

--
You received this bug notification because you are subscribed to the bug report.
https://bugs.launchpad.net/bugs/944242

Title:
  ipython prompt missed

Status in An Emacs mode for editing Python code:
  New

Bug description:
  I just installed python-mode 6.0.4 in Emacs 23.4 under OS X, and was
  happy to see that completion at the command prompt works very nicely.
  However, I then switched to using ipython rather than python as the
  shell (by editing py-shell-name). ipython is invoked fine, but when I
  try to complete using TAB, I think it has trouble understanding the
  ipython prompt, throwing up the following error:

  Debugger entered--Lisp error: (error "No prompt found or `comint-prompt-regexp' not set properly")
    signal(error ("No prompt found or `comint-prompt-regexp' not set properly"))
    error("No prompt found or `comint-prompt-regexp' not set properly")
    py-shell-redirect-send-command-to-process("" #<buffer *pyshellcomplete-output*> #<process /Library/Frameworks/Epd64.Framework/Versions/7.2/Bin/Ipython> nil t)
    (save-current-buffer (set-buffer procbuf) (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while (not comint-redirect-completed) (accept-process-output proc 1)))
    (with-current-buffer procbuf (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while (not comint-redirect-completed) (accept-process-output proc 1)))
    (if lines (with-current-buffer procbuf (py-shell-redirect-send-command-to-process "" outbuf proc nil t) (while ... ...)))
    (progn (if lines (with-current-buffer procbuf ... ...)) (with-current-buffer outbuf (delete-region ... ...)) (with-current-buffer procbuf (py-shell-redirect-send-command-to-process cmd outbuf proc nil t) (while ... ...)) (with-current-buffer outbuf (buffer-substring ... ...)))
    (condition-case nil (progn (if lines ...) (with-current-buffer outbuf ...) (with-current-buffer procbuf ... ...) (with-current-buffer outbuf ...)) (quit (with-current-buffer procbuf ... ...) (signal ... nil)))
    (unwind-protect (condition-case nil (progn ... ... ... ...) (quit ... ...)) (if (with-current-buffer procbuf comint-r...

Read more...

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

Am 01.03.2012 22:57, schrieb Richard Stanton:
> Completion now works, though there's one very minor oddity. Sometimes,
> when I press TAB to complete, the completion does what it's supposed to
> do, but in addition I get a new input line, as if I'd previously pressed
> Return without any text.
>
> For example,
>
> In [2]: import numpy as np
>
> In [3]: a = np.ar[now press TAB]
>
> A completion window opens fine, but the shell window now shows
>
> In [2]: import numpy as np
>
> In [3]:
> In [4]: a = np.ar
>
> Every time I press TAB, I get another blank input line inserted before
> the current line.
>
> If I only get as far as typing "np.a" before pressing TAB, I don't get
> another input line. Minor, as I said, but odd...
>

Agree. That's known at lp:939320

ipython-complete also uses the ipython-process, thus incrementing the
prompt counter. Changing the py-complete-function into
py-completion-at-point should avoid this - however it completes from
common Python, ignores IPython symbols, so it's probably not the
solution yet.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

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