diff options
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 57 |
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 @@ | |||
| 1 | 2014-10-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * progmodes/python.el (python-shell-completion-get-completions): | ||
| 4 | Use python-shell--prompt-calculated-input-regexp from the | ||
| 5 | process buffer (bug#18582). | ||
| 6 | Don't assume that `line' comes from the process buffer. | ||
| 7 | |||
| 1 | 2014-09-30 Leonardo Nobrega <leonobr@gmail.com> (tiny change) | 8 | 2014-09-30 Leonardo Nobrega <leonobr@gmail.com> (tiny change) |
| 2 | 9 | ||
| 3 | * progmodes/python.el (python-fill-paren): Don't inf-loop at EOB | 10 | * 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." | |||
| 2687 | (defun python-shell-completion-get-completions (process line input) | 2687 | (defun python-shell-completion-get-completions (process line input) |
| 2688 | "Do completion at point for PROCESS. | 2688 | "Do completion at point for PROCESS. |
| 2689 | LINE is used to detect the context on how to complete given INPUT." | 2689 | LINE is used to detect the context on how to complete given INPUT." |
| 2690 | (let* ((prompt | 2690 | (with-current-buffer (process-buffer process) |
| 2691 | ;; Get last prompt of the inferior process buffer (this | 2691 | (let* ((prompt |
| 2692 | ;; intentionally avoids using `comint-last-prompt' because | 2692 | ;; Get last prompt of the inferior process buffer (this |
| 2693 | ;; of incompatibilities with Emacs 24.x). | 2693 | ;; intentionally avoids using `comint-last-prompt' because |
| 2694 | (with-current-buffer (process-buffer process) | 2694 | ;; of incompatibilities with Emacs 24.x). |
| 2695 | (save-excursion | 2695 | (save-excursion |
| 2696 | (buffer-substring-no-properties | 2696 | (buffer-substring-no-properties |
| 2697 | (- (point) (length line)) | 2697 | (line-beginning-position) ;End of prompt. |
| 2698 | (progn | 2698 | (progn |
| 2699 | (re-search-backward "^") | 2699 | (re-search-backward "^") |
| 2700 | (python-util-forward-comment) | 2700 | (python-util-forward-comment) ;FIXME: Why? |
| 2701 | (point)))))) | 2701 | (point))))) |
| 2702 | (completion-code | 2702 | (completion-code |
| 2703 | ;; Check whether a prompt matches a pdb string, an import | 2703 | ;; Check whether a prompt matches a pdb string, an import |
| 2704 | ;; statement or just the standard prompt and use the | 2704 | ;; statement or just the standard prompt and use the |
| 2705 | ;; correct python-shell-completion-*-code string | 2705 | ;; correct python-shell-completion-*-code string |
| 2706 | (cond ((and (> (length python-shell-completion-pdb-string-code) 0) | 2706 | (cond ((and (> (length python-shell-completion-pdb-string-code) 0) |
| 2707 | (string-match | 2707 | (string-match |
| 2708 | (concat "^" python-shell-prompt-pdb-regexp) prompt)) | 2708 | (concat "^" python-shell-prompt-pdb-regexp) prompt)) |
| 2709 | python-shell-completion-pdb-string-code) | 2709 | python-shell-completion-pdb-string-code) |
| 2710 | ((string-match | 2710 | ((string-match |
| 2711 | python-shell--prompt-calculated-input-regexp prompt) | 2711 | python-shell--prompt-calculated-input-regexp prompt) |
| 2712 | python-shell-completion-string-code) | 2712 | python-shell-completion-string-code) |
| 2713 | (t nil))) | 2713 | (t nil))) |
| 2714 | (input | 2714 | (input |
| 2715 | (if (string-match | 2715 | (if (string-match |
| 2716 | (python-rx (+ space) (or "from" "import") space) | 2716 | (python-rx (+ space) (or "from" "import") space) |
| 2717 | line) | 2717 | line) |
| 2718 | line | 2718 | line |
| 2719 | input))) | 2719 | input))) |
| 2720 | (and completion-code | 2720 | (and completion-code |
| 2721 | (> (length input) 0) | 2721 | (> (length input) 0) |
| 2722 | (with-current-buffer (process-buffer process) | ||
| 2723 | (let ((completions | 2722 | (let ((completions |
| 2724 | (python-util-strip-string | 2723 | (python-util-strip-string |
| 2725 | (python-shell-send-string-no-output | 2724 | (python-shell-send-string-no-output |