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)
Hi,
completion should work with current trunk. Can you check out the and try again?
thanks,
Andreas