diff options
| author | kobarity | 2022-10-22 21:36:15 +0900 |
|---|---|---|
| committer | Eli Zaretskii | 2022-10-27 19:04:14 +0300 |
| commit | 7ac3d91eb2a7e9454087f17e1fadba350a86a208 (patch) | |
| tree | 96df09ecf27e5da25fa943058afa46357cb60033 /lisp/progmodes/python.el | |
| parent | d820c39bd18e493ba716ad3ceb8101c1dee3a02b (diff) | |
| download | emacs-7ac3d91eb2a7e9454087f17e1fadba350a86a208.tar.gz emacs-7ac3d91eb2a7e9454087f17e1fadba350a86a208.zip | |
Disable completion/ElDoc/FFAP when Python program is running
* lisp/progmodes/python.el (python-completion-at-point)
(python-ffap-module-path, python-eldoc--get-doc-at-point): Add check
using `python-util-comint-end-of-output-p'.
(python-util-comint-end-of-output-p): New function.
* test/lisp/progmodes/python-tests.el (python-tests-shell-wait-for-prompt):
Use `python-util-comint-end-of-output-p'.
(python-completion-at-point-while-running-1)
(python-ffap-module-path-1)
(python-ffap-module-path-while-running-1)
(python-eldoc--get-doc-at-point-1)
(python-eldoc--get-doc-at-point-while-running-1): New tests.
(Bug#58713)
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 11195894234..cec0d54a447 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -4375,7 +4375,9 @@ For this to work as best as possible you should call | |||
| 4375 | `python-shell-send-buffer' from time to time so context in | 4375 | `python-shell-send-buffer' from time to time so context in |
| 4376 | inferior Python process is updated properly." | 4376 | inferior Python process is updated properly." |
| 4377 | (let ((process (python-shell-get-process))) | 4377 | (let ((process (python-shell-get-process))) |
| 4378 | (when process | 4378 | (when (and process |
| 4379 | (python-shell-with-shell-buffer | ||
| 4380 | (python-util-comint-end-of-output-p))) | ||
| 4379 | (python-shell-completion-at-point process)))) | 4381 | (python-shell-completion-at-point process)))) |
| 4380 | 4382 | ||
| 4381 | (define-obsolete-function-alias | 4383 | (define-obsolete-function-alias |
| @@ -4800,6 +4802,8 @@ def __FFAP_get_module_path(objstr): | |||
| 4800 | (defun python-ffap-module-path (module) | 4802 | (defun python-ffap-module-path (module) |
| 4801 | "Function for `ffap-alist' to return path for MODULE." | 4803 | "Function for `ffap-alist' to return path for MODULE." |
| 4802 | (when-let ((process (python-shell-get-process)) | 4804 | (when-let ((process (python-shell-get-process)) |
| 4805 | (ready (python-shell-with-shell-buffer | ||
| 4806 | (python-util-comint-end-of-output-p))) | ||
| 4803 | (module-file | 4807 | (module-file |
| 4804 | (python-shell-send-string-no-output | 4808 | (python-shell-send-string-no-output |
| 4805 | (format "%s\nprint(__FFAP_get_module_path(%s))" | 4809 | (format "%s\nprint(__FFAP_get_module_path(%s))" |
| @@ -4918,7 +4922,9 @@ If not FORCE-INPUT is passed then what `python-eldoc--get-symbol-at-point' | |||
| 4918 | returns will be used. If not FORCE-PROCESS is passed what | 4922 | returns will be used. If not FORCE-PROCESS is passed what |
| 4919 | `python-shell-get-process' returns is used." | 4923 | `python-shell-get-process' returns is used." |
| 4920 | (let ((process (or force-process (python-shell-get-process)))) | 4924 | (let ((process (or force-process (python-shell-get-process)))) |
| 4921 | (when process | 4925 | (when (and process |
| 4926 | (python-shell-with-shell-buffer | ||
| 4927 | (python-util-comint-end-of-output-p))) | ||
| 4922 | (let* ((input (or force-input | 4928 | (let* ((input (or force-input |
| 4923 | (python-eldoc--get-symbol-at-point))) | 4929 | (python-eldoc--get-symbol-at-point))) |
| 4924 | (docstring | 4930 | (docstring |
| @@ -5664,6 +5670,13 @@ This is for compatibility with Emacs < 24.4." | |||
| 5664 | comint-last-prompt) | 5670 | comint-last-prompt) |
| 5665 | (t nil))) | 5671 | (t nil))) |
| 5666 | 5672 | ||
| 5673 | (defun python-util-comint-end-of-output-p () | ||
| 5674 | "Return non-nil if the last prompt matches input prompt." | ||
| 5675 | (when-let ((prompt (python-util-comint-last-prompt))) | ||
| 5676 | (python-shell-comint-end-of-output-p | ||
| 5677 | (buffer-substring-no-properties | ||
| 5678 | (car prompt) (cdr prompt))))) | ||
| 5679 | |||
| 5667 | (defun python-util-forward-comment (&optional direction) | 5680 | (defun python-util-forward-comment (&optional direction) |
| 5668 | "Python mode specific version of `forward-comment'. | 5681 | "Python mode specific version of `forward-comment'. |
| 5669 | Optional argument DIRECTION defines the direction to move to." | 5682 | Optional argument DIRECTION defines the direction to move to." |