1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-02 11:21:42 +00:00

* 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
This commit is contained in:
Stefan Monnier 2014-09-30 20:41:51 -04:00
parent d3b7a90bc2
commit 85ee81a08f
2 changed files with 35 additions and 29 deletions

View File

@ -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) 2014-09-30 Leonardo Nobrega <leonobr@gmail.com> (tiny change)
* progmodes/python.el (python-fill-paren): Don't inf-loop at EOB * progmodes/python.el (python-fill-paren): Don't inf-loop at EOB

View File

@ -2687,39 +2687,38 @@ the full statement in the case of imports."
(defun python-shell-completion-get-completions (process line input) (defun python-shell-completion-get-completions (process line input)
"Do completion at point for PROCESS. "Do completion at point for PROCESS.
LINE is used to detect the context on how to complete given INPUT." LINE is used to detect the context on how to complete given INPUT."
(let* ((prompt (with-current-buffer (process-buffer process)
;; Get last prompt of the inferior process buffer (this (let* ((prompt
;; intentionally avoids using `comint-last-prompt' because ;; Get last prompt of the inferior process buffer (this
;; of incompatibilities with Emacs 24.x). ;; intentionally avoids using `comint-last-prompt' because
(with-current-buffer (process-buffer process) ;; of incompatibilities with Emacs 24.x).
(save-excursion (save-excursion
(buffer-substring-no-properties (buffer-substring-no-properties
(- (point) (length line)) (line-beginning-position) ;End of prompt.
(progn (progn
(re-search-backward "^") (re-search-backward "^")
(python-util-forward-comment) (python-util-forward-comment) ;FIXME: Why?
(point)))))) (point)))))
(completion-code (completion-code
;; Check whether a prompt matches a pdb string, an import ;; Check whether a prompt matches a pdb string, an import
;; statement or just the standard prompt and use the ;; statement or just the standard prompt and use the
;; correct python-shell-completion-*-code string ;; correct python-shell-completion-*-code string
(cond ((and (> (length python-shell-completion-pdb-string-code) 0) (cond ((and (> (length python-shell-completion-pdb-string-code) 0)
(string-match (string-match
(concat "^" python-shell-prompt-pdb-regexp) prompt)) (concat "^" python-shell-prompt-pdb-regexp) prompt))
python-shell-completion-pdb-string-code) python-shell-completion-pdb-string-code)
((string-match ((string-match
python-shell--prompt-calculated-input-regexp prompt) python-shell--prompt-calculated-input-regexp prompt)
python-shell-completion-string-code) python-shell-completion-string-code)
(t nil))) (t nil)))
(input (input
(if (string-match (if (string-match
(python-rx (+ space) (or "from" "import") space) (python-rx (+ space) (or "from" "import") space)
line) line)
line line
input))) input)))
(and completion-code (and completion-code
(> (length input) 0) (> (length input) 0)
(with-current-buffer (process-buffer process)
(let ((completions (let ((completions
(python-util-strip-string (python-util-strip-string
(python-shell-send-string-no-output (python-shell-send-string-no-output