diff options
| author | kobarity | 2022-10-10 22:24:17 +0900 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-10-11 02:29:42 +0200 |
| commit | b0585441a321a144f2bbdc269b3cfc6c14bab7cf (patch) | |
| tree | f5ca93b995d817a6c3a90f22d7de399f67470198 /lisp/progmodes/python.el | |
| parent | 36ab1644964ae5a933bd9808536f60d4ae64c99f (diff) | |
| download | emacs-b0585441a321a144f2bbdc269b3cfc6c14bab7cf.tar.gz emacs-b0585441a321a144f2bbdc269b3cfc6c14bab7cf.zip | |
Fix Python completion failure under certain conditions
* lisp/progmodes/python.el (python-shell-send-string-no-output):
Save and restore `comint-last-prompt-overlay' or `comint-last-prompt'.
* test/lisp/progmodes/python-tests.el (python-tests-shell-wait-for-prompt):
New helper function.
(python-tests-with-temp-buffer-with-shell): New helper macro.
(python-shell-completion-1, python-shell-completion-native-1)
(python-shell-completion-native-with-ffap-1)
(python-shell-completion-native-with-eldoc-1): New tests (bug#58389).
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 80c5b31b6ea..680b57fc3ef 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -3413,15 +3413,25 @@ detecting a prompt at the end of the buffer." | |||
| 3413 | "Send STRING to PROCESS and inhibit output. | 3413 | "Send STRING to PROCESS and inhibit output. |
| 3414 | Return the output." | 3414 | Return the output." |
| 3415 | (or process (setq process (python-shell-get-process-or-error))) | 3415 | (or process (setq process (python-shell-get-process-or-error))) |
| 3416 | (cl-letf (((process-filter process) | 3416 | (cl-letf* (((process-filter process) |
| 3417 | (lambda (_proc str) | 3417 | (lambda (_proc str) |
| 3418 | (with-current-buffer (process-buffer process) | 3418 | (with-current-buffer (process-buffer process) |
| 3419 | (python-shell-output-filter str)))) | 3419 | (python-shell-output-filter str)))) |
| 3420 | (python-shell-output-filter-in-progress t) | 3420 | (python-shell-output-filter-in-progress t) |
| 3421 | (inhibit-quit t)) | 3421 | (inhibit-quit t) |
| 3422 | (buffer (process-buffer process)) | ||
| 3423 | (last-prompt (cond ((boundp 'comint-last-prompt-overlay) | ||
| 3424 | 'comint-last-prompt-overlay) | ||
| 3425 | ((boundp 'comint-last-prompt) | ||
| 3426 | 'comint-last-prompt))) | ||
| 3427 | (last-prompt-value (buffer-local-value last-prompt buffer))) | ||
| 3422 | (or | 3428 | (or |
| 3423 | (with-local-quit | 3429 | (with-local-quit |
| 3424 | (python-shell-send-string string process) | 3430 | (unwind-protect |
| 3431 | (python-shell-send-string string process) | ||
| 3432 | (when (not (null last-prompt)) | ||
| 3433 | (with-current-buffer buffer | ||
| 3434 | (set last-prompt last-prompt-value)))) | ||
| 3425 | (while python-shell-output-filter-in-progress | 3435 | (while python-shell-output-filter-in-progress |
| 3426 | ;; `python-shell-output-filter' takes care of setting | 3436 | ;; `python-shell-output-filter' takes care of setting |
| 3427 | ;; `python-shell-output-filter-in-progress' to NIL after it | 3437 | ;; `python-shell-output-filter-in-progress' to NIL after it |
| @@ -3430,7 +3440,7 @@ Return the output." | |||
| 3430 | (prog1 | 3440 | (prog1 |
| 3431 | python-shell-output-filter-buffer | 3441 | python-shell-output-filter-buffer |
| 3432 | (setq python-shell-output-filter-buffer nil))) | 3442 | (setq python-shell-output-filter-buffer nil))) |
| 3433 | (with-current-buffer (process-buffer process) | 3443 | (with-current-buffer buffer |
| 3434 | (comint-interrupt-subjob))))) | 3444 | (comint-interrupt-subjob))))) |
| 3435 | 3445 | ||
| 3436 | (defun python-shell-internal-send-string (string) | 3446 | (defun python-shell-internal-send-string (string) |