[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion a223260f2d 181/313: Get rid of bash-comple
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion a223260f2d 181/313: Get rid of bash-completion-alist completely. |
Date: |
Sat, 3 Dec 2022 10:59:28 -0500 (EST) |
branch: elpa/bash-completion
commit a223260f2d5bb59d7e034593824b706a1e07d0ef
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Get rid of bash-completion-alist completely.
959e27d introduced per-process alists, but still kept the global
bash-completion-alist in places. This commit removes that global
completely, to avoid confusion.
---
bash-completion.el | 84 +++++++++++---------------------
test/bash-completion-integration-test.el | 1 -
test/bash-completion-test.el | 32 +-----------
3 files changed, 30 insertions(+), 87 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 36a82d93b3..f0d8fbe54f 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -229,15 +229,6 @@ beginning of a bash completion subprocess.")
Mapping between remote paths as returned by `file-remote-p' and
Bash processes")
-(defvar bash-completion-alist nil
- "Maps from command name to the 'complete' arguments.
-
-For example if the following completion is defined in bash:
- complete -F _cdargs_aliases cdb
-the following entry is added to `bash-completion-alist':
- (\"cdb\" . (\"-F\" \"_cdargs\"))
-
-See `bash-completion-add-to-alist'.")
(defconst bash-completion-wordbreaks-str "@><=;|&(:"
"String of word break characters.
@@ -766,9 +757,6 @@ up the completion environment (COMP_LINE, COMP_POINT,
COMP_WORDS,
COMP_CWORD) and calls compgen.
The result is a list of candidates, which might be empty."
- ;; start process now, to make sure bash-completion-alist is
- ;; set before we run bash-completion-generate-line
-
(let* ((entry (bash-completion-require-process))
(process (car entry))
(completion-status)
@@ -779,10 +767,8 @@ The result is a list of candidates, which might be empty."
;; functions bound by complete -D. Presumably, the function has
;; just setup completion for the current command and is asking
;; us to retry once with the new configuration.
- (let ((bash-completion-alist nil))
- (bash-completion-send "complete -p" process)
- (bash-completion-build-alist (process-buffer process))
- (setcdr entry bash-completion-alist))
+ (bash-completion-send "complete -p" process)
+ (setcdr entry (bash-completion-build-alist (process-buffer process)))
(bash-completion--customize comp 'nodefault)
(setq completion-status (bash-completion-send
(bash-completion-generate-line comp) process)))
(setq options (bash-completion--options comp))
@@ -1088,8 +1074,8 @@ is set to t."
;; spaces. Noticed in bash_completion v1.872.
(bash-completion-send "function quote_readline { echo \"$1\"; }"
process)
(bash-completion-send "complete -p" process)
- (bash-completion-build-alist (process-buffer process))
- (let ((entry (cons process bash-completion-alist)))
+ (let ((entry (cons process (bash-completion-build-alist
+ (process-buffer process)))))
(push (cons remote entry)
bash-completion-processes)
(setq cleanup nil)
@@ -1116,47 +1102,34 @@ Return a bash command-line for going to
default-directory or \"\"."
"")))
(defun bash-completion-build-alist (buffer)
- "Build `bash-completion-alist' with the content of BUFFER.
+ "Parse the content of BUFFER into an alist.
BUFFER should contains the output of:
complete -p
-Return `bash-completion-alist', which is slightly parsed version
-of the output of \"complete -p\"."
- (with-current-buffer buffer
- (save-excursion
- (setq bash-completion-alist nil)
- (goto-char (point-max))
- (while (= 0 (forward-line -1))
- (bash-completion-add-to-alist
- (bash-completion-strings-from-tokens
- (bash-completion-tokenize
- (line-beginning-position)
- (line-end-position)))))))
- bash-completion-alist)
-
-(defun bash-completion-add-to-alist (words)
- "Add split 'complete' line WORDS to `bash-completion-add-to-alist'.
-
-This parses the complete command-line arguments as output by
- complete -p
-
-This does not work on arbitrary 'complete' calls.
-
-Lines that do not start with the word complete are skipped.
-
-Return `bash-completion-alist'."
- (when (string= "complete" (car words))
- (if (member "-D" (cdr words))
- ;; default completion
- (push (cons nil (delete "-D" (cdr words))) bash-completion-alist)
- ;; normal completion
- (let* ((reverse-wordsrest (nreverse (cdr words)))
- (command (car reverse-wordsrest))
- (options (nreverse (cdr reverse-wordsrest))) )
- (when (and command options)
- (push (cons command options) bash-completion-alist)))))
- bash-completion-alist)
+The returned alist is a sligthly parsed version of the output of
+\"complete -p\"."
+ (let ((alist (list)))
+ (with-current-buffer buffer
+ (save-excursion
+ (setq alist nil)
+ (goto-char (point-max))
+ (while (= 0 (forward-line -1))
+ (let ((words (bash-completion-strings-from-tokens
+ (bash-completion-tokenize
+ (line-beginning-position)
+ (line-end-position)))))
+ (when (string= "complete" (car words))
+ (if (member "-D" (cdr words))
+ ;; default completion
+ (push (cons nil (delete "-D" (cdr words))) alist)
+ ;; normal completion
+ (let* ((reverse-wordsrest (nreverse (cdr words)))
+ (command (car reverse-wordsrest))
+ (options (nreverse (cdr reverse-wordsrest))) )
+ (when (and command options)
+ (push (cons command options) alist)))))))))
+ alist))
(defun bash-completion--customize (comp &optional nodefault)
(unless (eq 'command (bash-completion--type comp))
@@ -1166,7 +1139,6 @@ Return `bash-completion-alist'."
(or (cdr (assoc command-name bash-completion-alist))
(and (not nodefault) (cdr (assoc nil
bash-completion-alist)))))))))
-
(defun bash-completion-generate-line (comp)
"Generate a command-line that calls compgen for COMP.
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index 09d912aa4f..48e1713933 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -37,7 +37,6 @@
`(if (file-executable-p bash-completion-prog)
(let ((test-env-dir (bash-completion_test-setup-env)))
(let ((bash-completion-processes nil)
- (bash-completion-alist nil)
(bash-completion-nospace 'as-configured)
(bash-completion-enable-caching nil)
(bash-completion-start-files nil)
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index 1ddde4d471..6a741d1b9f 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -279,34 +279,7 @@ The return value is the one returned by BODY."
"cd '/vcr/shows/Dexter'\\''s"
(bash-completion--parse (point-min) 27)))))
-(ert-deftest bash-completion-add-to-alist-test ()
- ;; garbage
- (should (equal nil
- (let ((bash-completion-alist nil))
- (bash-completion-add-to-alist (list "just" "some"
"garbage")))))
-
- ;; empty
- (should (equal nil
- (let ((bash-completion-alist nil))
- (bash-completion-add-to-alist '()))))
-
- ;; empty string
- (should (equal nil
- (let ((bash-completion-alist nil))
- (bash-completion-add-to-alist (list "")))))
-
- ;; empty complete
- (should (equal nil
- (let ((bash-completion-alist nil))
- (bash-completion-add-to-alist (list "complete")))))
-
- ;; one command
- (should (equal '(("cdb" . ("-e" "-F" "_cdargs_aliases")))
- (let (bash-completion-alist)
- (bash-completion-add-to-alist
- (list "complete" "-e" "-F" "_cdargs_aliases" "cdb"))))))
-
-(ert-deftest bash-completion-build-alist-test ()
+(ert-deftest bash-completion-build-alist ()
(should (equal
'(("cdb" "-F" "_cdargs_aliases")
("project" "-F" "complete_projects")
@@ -324,8 +297,7 @@ complete -F _cdargs_aliases cb
complete -F _completion_loader -D
garbage
"
- (let ((bash-completion-alist '(garbage)))
- (bash-completion-build-alist (current-buffer)))))))
+ (bash-completion-build-alist (current-buffer))))))
(ert-deftest bash-completion-quote-test ()
;; not necessary
- [nongnu] elpa/bash-completion 09c93ffbdb 165/313: Explicitly disable support for Emacs version older than 24.1., (continued)
- [nongnu] elpa/bash-completion 09c93ffbdb 165/313: Explicitly disable support for Emacs version older than 24.1., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 62c6567af6 158/313: Complete argument rename, ELPA Syncer, 2022/12/03
- [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 <=
- [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, 2022/12/03
- [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