[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 12da4f0e91 289/313: Better handle slow com
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 12da4f0e91 289/313: Better handle slow completion functions. |
Date: |
Sat, 3 Dec 2022 10:59:38 -0500 (EST) |
branch: elpa/bash-completion
commit 12da4f0e91f96d71852f13bbe1e4626032313960
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Better handle slow completion functions.
This change sets a very long timeout for custom completion, as
completion functions can take an arbitrarily long time to run.
Bash commands that are not custom completions still have the current,
short timeout, to better deal with unresponsive bash processes.
Additionally, the completion table function now caches any error, to
avoid failed calls being retried when next time the function is called.
---
bash-completion.el | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 8acb540ed7..a0d54e1870 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -187,6 +187,15 @@ ignored."
:type '(float)
:group 'bash-completion)
+(defcustom bash-completion-command-timeout 30
+ "Number of seconds to wait for an answer from programmable
+completion functions.
+
+Programmable completion functions might take an arbitrary long
+time to run, so this should be long."
+ :type '(float)
+ :group 'bash-completion)
+
(defcustom bash-completion-message-delay 0.4
"Time to wait before displaying a message while waiting for results.
@@ -851,8 +860,13 @@ COMP_CWORD) and calls compgen.
The result is a list of candidates, which might be empty."
(let* ((buffer (bash-completion--get-buffer process))
+ (cmd-timeout (if (eq 'custom (bash-completion--type comp))
+ bash-completion-command-timeout
+ bash-completion-process-timeout))
(completion-status))
- (setq completion-status (bash-completion-send
(bash-completion-generate-line comp) process))
+ (setq completion-status (bash-completion-send
+ (bash-completion-generate-line comp)
+ process cmd-timeout))
(when (eq 124 completion-status)
;; Special 'retry-completion' exit status, typically returned by
;; functions bound by complete -D. Presumably, the function has
@@ -861,7 +875,9 @@ The result is a list of candidates, which might be empty."
(bash-completion-send "complete -p" process)
(process-put process 'complete-p (bash-completion-build-alist buffer))
(bash-completion--customize comp process 'nodefault)
- (setq completion-status (bash-completion-send
(bash-completion-generate-line comp) process)))
+ (setq completion-status (bash-completion-send
+ (bash-completion-generate-line comp)
+ process cmd-timeout)))
(when (eq 0 completion-status)
(bash-completion-extract-candidates comp buffer))))
@@ -1541,7 +1557,8 @@ The result is a function that works like one built by
`completion-table-with-cache' with the difference that the
completions, built by `bash-completion-comm' are not filtered
using the current Emacs completion style."
- (let ((last-result)
+ (let ((last-result nil)
+ (last-error nil)
(calling-buffer (current-buffer))
(dir default-directory)
(use-separate-process bash-completion-use-separate-processes)
@@ -1550,13 +1567,18 @@ using the current Emacs completion style."
(if (or (eq (car-safe action) 'boundaries)
(eq action 'metadata))
nil
+ (when last-error (signal (car last-error) (cdr last-error)))
(let ((result
(or last-result
(let ((bash-completion-use-separate-processes
use-separate-process)
(bash-completion-nospace nospace)
(default-directory dir))
(with-current-buffer calling-buffer
- (bash-completion-comm comp process))))))
+ (condition-case err
+ (bash-completion-comm comp process)
+ (error
+ (setq last-error err)
+ (signal (car err) (cdr err)))))))))
(setq last-result result)
(let ((filtered-result (if predicate (mapcar predicate result)
result))
(completion-ignore-case (process-get process
'completion-ignore-case)))
- [nongnu] elpa/bash-completion 04393bca0f 250/313: Apply filename post-processing even when prefix doesn't match., (continued)
- [nongnu] elpa/bash-completion 04393bca0f 250/313: Apply filename post-processing even when prefix doesn't match., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2a937b3763 255/313: Don't let Emacs post-filter completions built by bash., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e95867c993 256/313: completion-table-with-cache captures and restore buffer and variables., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 747920fdbf 265/313: Avoid having to set BASH_COMPLETION., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f15176ee59 267/313: Fix to properly evaluate PROMPT_COMMAND after restoring it., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b4ae893243 268/313: Test prompt and history manipulation, fix $? in prompt., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 20feaf909d 258/313: Fix markdown markup., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8713edbb92 269/313: Mention that completion works with bash 5, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4b80c75c43 272/313: Take current directory from shell when in single-process mode., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ea5cc15b99 273/313: Let status code of compgen through when in single-process mode., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 12da4f0e91 289/313: Better handle slow completion functions.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 7186a18cad 012/313: Integrated into comm, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e81c478032 020/313: bash-complete -> bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8270e09294 023/313: pass words as command-line arguments to the function, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 482383dcd7 021/313: handle slash for directory, usable completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion cd2ec103d1 026/313: Expand directory names with quotes and spaces, but no further, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1d7af7e40d 027/313: Remove debug messages, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion dda4697cfb 029/313: included bash-completion into google env, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21eabde7f9 045/313: Reimplemented split, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3c58afdb0d 033/313: expand file names in colon-separated paths, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5501cb63cf 042/313: Turn off mail warning, ELPA Syncer, 2022/12/03