[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 5440b23: Disable completion while entering python m
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] master 5440b23: Disable completion while entering python multiline statements |
Date: |
Sun, 27 Aug 2017 14:25:53 -0400 (EDT) |
branch: master
commit 5440b238b1ec4175dd32bc14b4098f6570b2ca85
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Disable completion while entering python multiline statements
The "legacy" completion mechanism sends newlines to the running python
process to get the list of completions, which confuses things if the
user is in the middle of entering a multiline statement (Bug#28051).
It's better to disable completion in this case.
* lisp/progmodes/python.el (python-shell--block-prompt): New variable.
(python-shell-prompt-set-calculated-regexps): Set it.
(python-shell-completion-at-point): Return 'ignore' as the completion
function when the current prompt is a block prompt.
---
lisp/progmodes/python.el | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e73b2a8..444167f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2212,6 +2212,11 @@ machine then modifies `tramp-remote-process-environment'
and
Do not set this variable directly, instead use
`python-shell-prompt-set-calculated-regexps'.")
+(defvar python-shell--block-prompt nil
+ "Input block prompt for inferior python shell.
+Do not set this variable directly, instead use
+`python-shell-prompt-set-calculated-regexps'.")
+
(defvar python-shell--prompt-calculated-output-regexp nil
"Calculated output prompt regexp for inferior python shell.
Do not set this variable directly, instead use
@@ -2366,6 +2371,7 @@ and `python-shell-output-prompt-regexp' using the values
from
(dolist (prompt (butlast detected-prompts))
(setq prompt (regexp-quote prompt))
(cl-pushnew prompt input-prompts :test #'string=))
+ (setq python-shell--block-prompt (nth 1 detected-prompts))
(cl-pushnew (regexp-quote
(car (last detected-prompts)))
output-prompts :test #'string=))
@@ -2726,6 +2732,7 @@ variable.
(set (make-local-variable 'python-shell-interpreter-args)
(or python-shell--interpreter-args python-shell-interpreter-args))
(set (make-local-variable 'python-shell--prompt-calculated-input-regexp) nil)
+ (set (make-local-variable 'python-shell--block-prompt) nil)
(set (make-local-variable 'python-shell--prompt-calculated-output-regexp)
nil)
(python-shell-prompt-set-calculated-regexps)
(setq comint-prompt-regexp python-shell--prompt-calculated-input-regexp)
@@ -3632,7 +3639,14 @@ using that one instead of current buffer's process."
;; Also, since pdb interaction is single-line
;; based, this is enough.
(string-match-p python-shell-prompt-pdb-regexp prompt))
- #'python-shell-completion-get-completions)
+ (if (or (equal python-shell--block-prompt prompt)
+ (string-match-p
+ python-shell-prompt-block-regexp prompt))
+ ;; The non-native completion mechanism sends
+ ;; newlines to the interpreter, so we can't use
+ ;; it during a multiline statement (Bug#28051).
+ #'ignore
+ #'python-shell-completion-get-completions))
(t #'python-shell-completion-native-get-completions)))))
(list start end
(completion-table-dynamic
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 5440b23: Disable completion while entering python multiline statements,
Noam Postavsky <=