Comment 2 for bug 944242

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

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-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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-mode/+bug/944242/+subscriptions