[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion fd853663ee 304/313: Detect non-responsive
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion fd853663ee 304/313: Detect non-responsive processes more quickly. |
Date: |
Sat, 3 Dec 2022 10:59:40 -0500 (EST) |
branch: elpa/bash-completion
commit fd853663ee40c4493d58296731b3b90a8a0950e6
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Detect non-responsive processes more quickly.
With this change, bash-completion-send first sends a short echo command,
just to see whether the process answers properly, so that, in the case
where the process is not able to respond or not a bash process,
bash-completion fails quickly.
This makes issue #44 less annoying but doesn't actually solve the
problem yet.
---
bash-completion.el | 31 ++++++++++++++++++++-----------
test/bash-completion-test.el | 9 +++++----
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 5c391b9190..cb81729914 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -179,11 +179,11 @@ explanation."
:type '(repeat (string :tag "Argument"))
:group 'bash-completion)
-(defcustom bash-completion-process-timeout 2.5
+(defcustom bash-completion-process-timeout 0.5
"Number of seconds to wait for an answer from bash.
-If bash takes longer than that to answer, the answer will be
-ignored."
+This doesn't include the time it takes to execute an actual
+completion command, which is set by `bash-completion-command-timeout'."
:type '(float)
:group 'bash-completion)
@@ -1506,8 +1506,10 @@ Return the status code of the command, as a number."
(send-string (if bash-completion-use-separate-processes
#'process-send-string
#'comint-send-string))
- (pre-command (unless bash-completion-use-separate-processes
- "__emacs_complete_pre_command; "))
+ (pre-command (concat
+ "echo bash\\-completion:; "
+ (unless bash-completion-use-separate-processes
+ "__emacs_complete_pre_command; ")))
(complete-command (concat pre-command commandline "\n")))
(setq bash-completion--debug-info
(list (cons 'commandline complete-command)
@@ -1517,17 +1519,24 @@ Return the status code of the command, as a number."
(with-current-buffer (bash-completion--get-buffer process)
(erase-buffer)
(funcall send-string process complete-command)
+ ;; Wait for 'echo bash\-completion' to be executed within
+ ;; bash-completion-process-timeout. This takes care of any
+ ;; command-line echo as well.
+ (unless (bash-completion--wait-for-regexp process "bash-completion:"
bash-completion-process-timeout)
+ (push (cons 'error "non-bash") bash-completion--debug-info)
+ (push (cons 'buffer-string (buffer-substring-no-properties (point-min)
(point-max)))
+ bash-completion--debug-info)
+ (error "Bash completion failed; not a bash process."))
+ (delete-region (point-min) (1+ (match-end 0)))
+ (goto-char (point-max))
+ ;; Now wait for the real to be executed within timeout. This can
+ ;; take a while for some completion commands.
(unless (bash-completion--wait-for-regexp process "\t-?[[:digit:]]+\v"
timeout)
+
(push (cons 'error "timeout") bash-completion--debug-info)
(push (cons 'buffer-string (buffer-substring-no-properties (point-min)
(point-max)))
bash-completion--debug-info)
(error "Bash completion failed. M-x bash-completion-debug for
details."))
- (when pre-command
- ;; Detect the command having been echoed and remove it
- (save-excursion
- (goto-char (point-min))
- (when (looking-at pre-command)
- (delete-region (match-beginning 0) (line-beginning-position 2)))))
(let ((status (string-to-number
(buffer-substring-no-properties
(1+ (point))
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index bbe7cd56f6..061eef7ca8 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -519,15 +519,16 @@ Return (const return-value new-buffer-content)"
(lambda (process command)
(unless (eq process 'process)
(error "unexpected process: %s" process))
- (unless (equal "cmd\n" command)
+ (unless (equal command "echo bash\\-completion:; cmd\n")
(error "unexpected command: %s" command))))
((symbol-function 'accept-process-output)
(lambda (process timeout &optional millisec just-this-one)
(unless (eq process 'process)
(error "unexpected process: %s" process))
- (unless (= timeout 3.14)
- (error "unexpected timeout: %s" timeout))
- (insert buffer-content)
+ (cond ((= timeout 3.14) (insert buffer-content))
+ ((= timeout bash-completion-process-timeout)
+ (insert "bash-completion:\n"))
+ (t (error "unexpected timeout: %s" timeout)))
t)))
(bash-completion-test-with-buffer
""
- [nongnu] elpa/bash-completion 1598101f06 271/313: Remove the fallback to a separate process., (continued)
- [nongnu] elpa/bash-completion 1598101f06 271/313: Remove the fallback to a separate process., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 18ed1504ce 274/313: Add test cases for TRAMP shell., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 23dbe5b537 276/313: Change minimum supported Emacs version from 24.1 to 24.3., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c3797e0d09 277/313: Avoid running the same completion multiple times., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0210d346f1 279/313: Make bash-completion-use-separate-processes default to nil., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7a1f127851 292/313: Test and fix the dynamic table function that's returned., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3dbbd1beff 293/313: Fix tests to run under Emacs 24.3., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d47edb9d41 294/313: Bump version to 3.1, a bugfix release., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion faefaf6950 298/313: Add command M-x bash-completion-debug, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fa5557709e 300/313: GitHub Actions now runs tests on Emacs 27.1., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fd853663ee 304/313: Detect non-responsive processes more quickly.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 65e54c6f9c 307/313: Temporarily revert fixes for issue #44., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d9c97b741d 309/313: Attempt to fix automated tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 29b5fc860a 312/313: Shorten overly long docstring (#53), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3ffc296e0b 149/313: Close opened quote for all completion candidate that don't end with a, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6bf1536325 150/313: Fix occasional escaping issue with candidates containing quotes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21149fdc27 152/313: Introduce the variable bash-completion-start-files, that allow, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 31bc1c1c21 161/313: Compile bash-completion.el before running tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 054ecdfce3 290/313: ignore file ert-profile created by ert-runner, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c444230670 154/313: Add run_tests.sh, to run tests from the command-line, with specific, ELPA Syncer, 2022/12/03