From: Stefan Monnier Date: Wed, 1 Oct 2014 00:41:51 +0000 (-0400) Subject: * lisp/progmodes/python.el (python-shell-completion-get-completions): X-Git-Tag: emacs-24.3.94~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85ee81a08fa5ec3fb0261174c1dabbef433c2e14;p=emacs.git * lisp/progmodes/python.el (python-shell-completion-get-completions): Use python-shell--prompt-calculated-input-regexp from the process buffer. Don't assume that `line' comes from the process buffer. Fixes: debbugs:18582 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ac4f6b1bf1..0a0fb21b1e5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-10-01 Stefan Monnier + + * progmodes/python.el (python-shell-completion-get-completions): + Use python-shell--prompt-calculated-input-regexp from the + process buffer (bug#18582). + Don't assume that `line' comes from the process buffer. + 2014-09-30 Leonardo Nobrega (tiny change) * progmodes/python.el (python-fill-paren): Don't inf-loop at EOB diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d5126fa8881..aa9d9b10dbc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2687,39 +2687,38 @@ the full statement in the case of imports." (defun python-shell-completion-get-completions (process line input) "Do completion at point for PROCESS. LINE is used to detect the context on how to complete given INPUT." - (let* ((prompt - ;; Get last prompt of the inferior process buffer (this - ;; intentionally avoids using `comint-last-prompt' because - ;; of incompatibilities with Emacs 24.x). - (with-current-buffer (process-buffer process) + (with-current-buffer (process-buffer process) + (let* ((prompt + ;; Get last prompt of the inferior process buffer (this + ;; intentionally avoids using `comint-last-prompt' because + ;; of incompatibilities with Emacs 24.x). (save-excursion (buffer-substring-no-properties - (- (point) (length line)) + (line-beginning-position) ;End of prompt. (progn (re-search-backward "^") - (python-util-forward-comment) - (point)))))) - (completion-code - ;; Check whether a prompt matches a pdb string, an import - ;; statement or just the standard prompt and use the - ;; correct python-shell-completion-*-code string - (cond ((and (> (length python-shell-completion-pdb-string-code) 0) - (string-match - (concat "^" python-shell-prompt-pdb-regexp) prompt)) - python-shell-completion-pdb-string-code) - ((string-match - python-shell--prompt-calculated-input-regexp prompt) - python-shell-completion-string-code) - (t nil))) - (input - (if (string-match - (python-rx (+ space) (or "from" "import") space) - line) - line - input))) - (and completion-code - (> (length input) 0) - (with-current-buffer (process-buffer process) + (python-util-forward-comment) ;FIXME: Why? + (point))))) + (completion-code + ;; Check whether a prompt matches a pdb string, an import + ;; statement or just the standard prompt and use the + ;; correct python-shell-completion-*-code string + (cond ((and (> (length python-shell-completion-pdb-string-code) 0) + (string-match + (concat "^" python-shell-prompt-pdb-regexp) prompt)) + python-shell-completion-pdb-string-code) + ((string-match + python-shell--prompt-calculated-input-regexp prompt) + python-shell-completion-string-code) + (t nil))) + (input + (if (string-match + (python-rx (+ space) (or "from" "import") space) + line) + line + input))) + (and completion-code + (> (length input) 0) (let ((completions (python-util-strip-string (python-shell-send-string-no-output