[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 34221c1fdd 185/313: Make bash-completion-e
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 34221c1fdd 185/313: Make bash-completion-enable-caching the default, remove the |
Date: |
Sat, 3 Dec 2022 10:59:29 -0500 (EST) |
branch: elpa/bash-completion
commit 34221c1fdd02230218c2964998eb6115150f51df
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Make bash-completion-enable-caching the default, remove the
customization.
With this commit, always return a dynamic table completion when doing
completion from comint.
To preserve backward compatibility,
`bash-completion-dynamic-complete-nocomint' still returns a list of
candidates instead of a lambda, unless passed an optional argument.
Issue #30
---
bash-completion.el | 37 +++++++++++---------------------
test/bash-completion-integration-test.el | 6 ------
test/bash-completion-test.el | 13 ++++++++++-
3 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index c73586775e..bce01221f7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -197,26 +197,6 @@ to remove the extra space bash adds after a completion."
:type '(boolean)
:group 'bash-completion)
-(if (fboundp 'completion-table-with-cache)
- (defcustom bash-completion-enable-caching nil
- "If non-nil, enable caching in
`bash-completion-dynamic-complete-nocomint'.
-
-When caching is enabled,
-`bash-completion-dynamic-complete-nocomint' returns a function
-instead of the list of all possible completions. Enabling caching
-improves performance because less calls will be made to
-`bash-completion-comm' which is an expensive function.
-
-Wordbreak completions behaves slightly differently when this operation is
-enabled."
- :type 'boolean
- :group 'bash-completion)
- (defconst bash-completion-enable-caching nil))
-
-(defalias 'bash-completion--completion-table-with-cache
- (if (fboundp 'completion-table-with-cache)
- 'completion-table-with-cache 'completion-table-dynamic))
-
(defvar bash-completion-start-files
'("~/.emacs_bash.sh" "~/.emacs.d/init_bash.sh")
"Shell files that, if they exist, will be sourced at the
@@ -366,13 +346,19 @@ When doing completion outside of a comint buffer, call
(unwind-protect
(bash-completion-dynamic-complete-nocomint
(comint-line-beginning-position)
- (point))
+ (point)
+ 'dynamic-table)
;; cleanup
(if message-timer
(cancel-timer message-timer)))))
+(defalias 'bash-completion--completion-table-with-cache
+ (if (fboundp 'completion-table-with-cache)
+ 'completion-table-with-cache 'completion-table-dynamic))
+
;;;###autoload
-(defun bash-completion-dynamic-complete-nocomint (comp-start comp-pos)
+(defun bash-completion-dynamic-complete-nocomint
+ (comp-start comp-pos &optional dynamic-table)
"Return completion information for bash command at an arbitrary position.
The bash command to be completed begins at COMP-START in the
@@ -385,8 +371,9 @@ It is meant to be called directly from any completion
engine.
Returns (list stub-start stub-end completions) with
- stub-start, the position at which the completed region starts
- stub-end, the position at which the completed region ends
- - completions, a possibly empty list of completion candidates or a function if
- `bash-completion-enable-caching' is non-nil"
+ - completions, a possibly empty list of completion candidates
+ or a function, if DYNAMIC-TABLE is non-nil, a lambda such as the one
+ returned by `completion-table-dynamic'"
(when bash-completion-enabled
(let* ((process (bash-completion-require-process))
(comp (bash-completion--parse
@@ -397,7 +384,7 @@ Returns (list stub-start stub-end completions) with
(list
stub-start
comp-pos
- (if bash-completion-enable-caching
+ (if dynamic-table
(bash-completion--completion-table-with-cache
(lambda (_)
(bash-completion-comm comp process)))
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index 5a29b1a086..452eb387cc 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -38,7 +38,6 @@
(let ((test-env-dir (bash-completion_test-setup-env)))
(let ((bash-completion-processes nil)
(bash-completion-nospace nil)
- (bash-completion-enable-caching nil)
(bash-completion-start-files nil)
(bash-completion-args
(list "--noediting"
@@ -142,11 +141,6 @@ for testing completion."
(bash-completion_test-with-shell-harness
(bash-completion-integration-test-complete)))
-(ert-deftest bash-completion-integration-completion-test-with-caching ()
- (bash-completion_test-with-shell-harness
- (setq bash-completion-enable-caching t)
- (bash-completion-integration-test-complete)))
-
(defun bash-completion-integration-test-complete ()
;; complete command
(should (equal "somefunction "
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index afb202f193..7472d75edc 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -863,7 +863,6 @@ before calling `bash-completion-dynamic-complete-nocomint'.
`(let ((default-directory "/tmp/test")
(bash-completion-alist '())
(wordbreaks "@><=;|&(:")
- (bash-completion-enable-caching nil)
(bash-completion-nospace nil))
(lexical-let ((--process-buffer)
(--test-buffer)
@@ -911,6 +910,18 @@ before calling `bash-completion-dynamic-complete-nocomint'.
(should (equal "cd >/dev/null 2>&1 /tmp/test ; compgen -o default -- he
2>/dev/null"
(pop --captured-commands)))))
+(ert-deftest bash-completion-simple-dynamic-table-test ()
+ (--with-fake-bash-completion-send
+ (push "hell\nhello1\nhello2\n" --send-results)
+ (insert "$ cat he")
+ (pcase-let ((`(,stub-start ,stub-end ,completions)
+ (bash-completion-dynamic-complete-nocomint
+ 3 (point) 'dynamic-table)))
+ (should (equal 7 stub-start))
+ (should (equal 9 stub-end))
+ (should (equal '("hell" "hello1" "hello2")
+ (funcall completions "he" nil t))))))
+
(ert-deftest bash-completion-single-completion-test ()
(--with-fake-bash-completion-send
(push "hello\n" --send-results)
- [nongnu] elpa/bash-completion 5eb85cf1fc 166/313: Remove obsolete functions bash-completion-dynamic-complete-0 and, (continued)
- [nongnu] elpa/bash-completion 5eb85cf1fc 166/313: Remove obsolete functions bash-completion-dynamic-complete-0 and, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9b94818f88 167/313: Remove support for pre-Emacs24.1 backward compatibility., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 912e1e8153 170/313: Add an option to disable default Readline completion when no matches are found (#29), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 959e27dae3 171/313: Add remote shell support, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 68f7d937b7 175/313: Make wordbreak completion work with bash-completion-enable-caching., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2cf76221c2 178/313: Rely on compgen for default completion, instead of doing it with, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f01d8726de 179/313: Remove support filenames options., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5171866b65 180/313: Simplify options a bit, since the only useful option is nospace., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a223260f2d 181/313: Get rid of bash-completion-alist completely., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4f13e00702 183/313: Execute wordbreak completion "properly", as part of the normal, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 34221c1fdd 185/313: Make bash-completion-enable-caching the default, remove the,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 8c3995aa98 187/313: run_tests.sh displays the bash command to test against., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3eba6922e6 190/313: Use executable-find instead of hardcoding /bin/bash., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1d41c58bd5 192/313: Send initialization command as one string, as long as possible., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c5d4f92e6d 195/313: Still EMACS_BASH_COMPLETE using setenv for local processes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 24088ede85 196/313: Explicitly mention compatibility with Bash 3 and 4., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0f6466eeb4 197/313: Tell minibuffer not to delay after displaying a message while, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0c4557a5ed 193/313: Integration test for default completion (-D)., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e7869dd68d 200/313: Fix a bug when no process is associated with the current buffer, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 80be2f37a9 205/313: Check the buffer uses comint-mode before using the same process, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 28ec870dd1 019/313: only one -complete method, ELPA Syncer, 2022/12/03