summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-09-30 20:41:51 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-09-30 20:41:51 -0400
commit85ee81a08fa5ec3fb0261174c1dabbef433c2e14 (patch)
treea6ac36a6c6165e030bbadf07182ca45f5d691ad2
parentd3b7a90bc2ad20192d1afd23eb1aa6a18ceda569 (diff)
downloademacs-85ee81a08fa5ec3fb0261174c1dabbef433c2e14.tar.gz
* 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
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/python.el57
2 files changed, 35 insertions, 29 deletions
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 <monnier@iro.umontreal.ca>
+
+ * 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 <leonobr@gmail.com> (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