[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion c3797e0d09 277/313: Avoid running the same
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion c3797e0d09 277/313: Avoid running the same completion multiple times. |
Date: |
Sat, 3 Dec 2022 10:59:37 -0500 (EST) |
branch: elpa/bash-completion
commit c3797e0d09af7f1a7173e24ad0c774c52b0e90b6
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Avoid running the same completion multiple times.
Before this change bash-completion--completion-table-with-cache was
not caching aggressively enough. It used to check the string argument,
which was useless since the COMP argument cannot change anyways. The
completions returned by bash are just meant to be used as they are.
---
bash-completion.el | 25 +++++++++++--------------
test/bash-completion-integration-test.el | 18 ++++++++++++++++++
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 4b48c8f7ab..874dacaee0 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1578,28 +1578,25 @@ Return the parsed value, as a string or nil."
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 complete
-and that completion style doesn't necessarily use substring
-completion."
- (let ((last-str) (last-result)
+completions, built by `bash-completion-comm' are not filtered
+using the current Emacs completion style."
+ (let ((last-result)
(calling-buffer (current-buffer))
(dir default-directory)
(use-separate-process bash-completion-use-separate-processes)
(nospace bash-completion-nospace))
- (lambda (str predicate action)
+ (lambda (_str predicate action)
(if (or (eq (car-safe action) 'boundaries)
(eq action 'metadata))
nil
(let ((result
- (if (equal str last-str)
- 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))))))
- (setq last-str str
- last-result 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))))))
+ (setq last-result result)
(let ((filtered-result (if predicate (mapcar predicate result)
result))
(completion-ignore-case (process-get process
'completion-ignore-case)))
(cond
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index be9765f5aa..827cfbad87 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -538,4 +538,22 @@ $ ")))))
(let ((default-directory "/does-not-exist/"))
(should (equal "ls some/" (bash-completion_test-complete "ls so"))))))
+(ert-deftest bash-completion-integration-caching ()
+ "Make sure caching works and that completion is only executed once."
+ (bash-completion_test-with-shell-harness
+ (concat ; .bashrc
+ "PS1='$ '\n"
+ "dummycount=0;\n"
+ "function _dummy {\n"
+ " dummycount=$(( $dummycount + 1 ))\n"
+ " COMPREPLY=(libra library librarian)\n"
+ "}\n"
+ "function dummy { echo count: ${dummycount}.; }\n"
+ "complete -F _dummy dummy\n")
+ nil ; use-separate-process
+ (bash-completion_test-send "dummy libr" 'complete)
+ (should (string-match
+ (regexp-quote "$ dummy libra\ncount: 1.")
+ (bash-completion_test-buffer-string)))))
+
;;; bash-completion-integration-test.el ends here
- [nongnu] elpa/bash-completion aec357fbf1 249/313: Test default completion with both value of use-separate-process., (continued)
- [nongnu] elpa/bash-completion aec357fbf1 249/313: Test default completion with both value of use-separate-process., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 38c82e5d59 252/313: Conserve quotes even when expanding case-insensitively., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6a66eeda45 253/313: Add test-case to cover tilde and tilde expansion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b9e519e2ad 263/313: Fix typo, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2684ea9e46 264/313: Fix issue with case-insensitive completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6d74dd30ba 266/313: Avoid interference from PROMPT_COMMAND in single process mode., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 23a3402844 270/313: Trying to disable the warning on MacOS that breaks the tests., ELPA Syncer, 2022/12/03
- [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 <=
- [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, 2022/12/03
- [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