[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p outp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p output |
Date: |
Sat, 3 Dec 2022 10:59:06 -0500 (EST) |
branch: elpa/bash-completion
commit 53f2c5d30ee1426bc537deba58749d92981abb4c
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
parse complete -p output
---
bash-complete.el | 18 +++++++++++++++++-
bash-complete_test.el | 18 ++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/bash-complete.el b/bash-complete.el
index 83c22ccd49..0a2567d88d 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -62,7 +62,7 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
(defun bash-complete-split-0 (start end pos accum straccum)
(let ( (char-start (char-after))
(quote nil) )
- (when (or (= char-start ?') (= char-start ?\"))
+ (when (and char-start (or (= char-start ?') (= char-start ?\")))
(forward-char)
(setq quote char-start))
(bash-complete-split-1 start end pos quote accum straccum)))
@@ -119,6 +119,22 @@ The result is a list of candidates, which might be empty."
)
+(defun bash-complete-build-alist (buffer)
+ "Build `bash-complete-alist' with the content of BUFFER.
+
+BUFFER should contains the output of:
+ complete -p
+
+Return `bash-complete-alist'."
+ (with-current-buffer buffer
+ (save-excursion
+ (setq bash-complete-alist nil)
+ (end-of-buffer)
+ (while (= 0 (forward-line -1))
+ (bash-complete-add-to-alist
+ (cdr (bash-complete-split (line-beginning-position)
(line-end-position) 0))))))
+ bash-complete-alist)
+
(defun bash-complete-add-to-alist (words)
"Add split 'complete' line WORDS to `bash-complete-add-to-alist'.
diff --git a/bash-complete_test.el b/bash-complete_test.el
index ec4844c732..31b17544db 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -133,6 +133,24 @@
(bash-complete-add-to-alist '("complete" "-e" "-F" "_cdargs_aliases"
"cdb")))
'(("cdb" . ("-e" "-F" "_cdargs_aliases"))))
+ ("bash-complete-build-alist"
+ (sz-testutils-with-buffer
+ "
+complete -F _cdargs_aliases cdb
+complete -F complete_projects project
+complete -F complete_projects pro
+complete -F _cdargs_aliases cv
+complete -F _cdargs_aliases cb
+garbage
+"
+ (let ((bash-complete-alist '(garbage)))
+ (bash-complete-build-alist (current-buffer))))
+ '(("cdb" "-F" "_cdargs_aliases")
+ ("project" "-F" "complete_projects")
+ ("pro" "-F" "complete_projects")
+ ("cv" "-F" "_cdargs_aliases")
+ ("cb" "-F" "_cdargs_aliases")))
+
)))
- [nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from result, (continued)
- [nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from result, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 540f8f516a 011/313: build bash cmdline, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6eebe8f965 016/313: cleaned up process launch, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 34d11220dd 024/313: add prefix if missing, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3036ef0394 028/313: disable quote_readline to get good whitespace handling for bash 3.2 at least, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ba83e81651 053/313: bash-completion-generate-line, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f7bfc68ea2 001/313: bash completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f5885ec87a 002/313: test case for bash-complete, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 208cb5ab76 007/313: Join, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 47a890dd72 010/313: launch process, send commands, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p output,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 11e52fce6f 018/313: Fixed initialization, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c10cfef5b8 015/313: complex line split, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b5c2fbf4a2 014/313: add hooks, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9eb026ae0b 025/313: fixed current directory for adding slash, workaround for bash ~ expansion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 02d1acf260 030/313: wordbreaks, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5931a2ba43 037/313: completion-fix, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a78fd6b587 044/313: turn off mailwarn and checkjobs, continue if this failed, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0ffaad3ef0 035/313: wordbreak-split, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 80cd654c35 043/313: turn off mailwarn and checkjobs, continue if this failed, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1c6b2efb67 040/313: enormous test, ELPA Syncer, 2022/12/03