[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 8756e80737 184/313: Replace 'options' in t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 8756e80737 184/313: Replace 'options' in the completion struct with 'nospace'. |
Date: |
Sat, 3 Dec 2022 10:59:29 -0500 (EST) |
branch: elpa/bash-completion
commit 8756e807378debbc7db8e0a31a31d1a4aa93ece5
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Replace 'options' in the completion struct with 'nospace'.
Turns out, there are no other options than nospace that need to be
tracked, so the older implementation was overkill.
Issue #19
---
bash-completion.el | 51 ++++++---------
test/bash-completion-integration-test.el | 23 ++++---
test/bash-completion-test.el | 109 ++++++++++++++++---------------
3 files changed, 90 insertions(+), 93 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index ae4b988748..c73586775e 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -184,7 +184,7 @@ which typically takes a long time."
:type '(float)
:group 'bash-completion)
-(defcustom bash-completion-nospace 'as-configured
+(defcustom bash-completion-nospace nil
"Never let bash add a final space at the end of a completion.
When there is only one completion candidate, bash sometimes adds
@@ -283,16 +283,17 @@ customized, usually by `bash-completion--customize'.
((bash-completion--compgen-args comp) 'custom)
(t 'default)))
-(defun bash-completion--options (comp)
- "Returns options for comp, either default or customized.
+(defun bash-completion--nospace (comp)
+ "Returns the value of the nospace option to use for COMP.
-See options definition in
-`bash-completion--extract-compgen-options'"
- (bash-completion--parse-options
- (if (eq (bash-completion--type comp) 'custom)
- (bash-completion--extract-compgen-options
- (bash-completion--compgen-args comp))
- nil)))
+The option can be:
+ - set globally, by setting `bash-completion-nospace' to t
+ - set for a customized completion, in bash, with
+ '-o' 'nospace'."
+ (if bash-completion-nospace
+ t ; set globally
+ (bash-completion--has-compgen-option
+ (bash-completion--compgen-args comp) "nospace")))
(defun bash-completion--command (comp)
"Return the current command for the completion, if there is one."
@@ -756,7 +757,7 @@ for directory name detection to work."
(let ((parsed-prefix (bash-completion--stub comp))
(unparsed-prefix (bash-completion--unparsed-stub comp))
(open-quote (bash-completion--open-quote comp))
- (options (bash-completion--options comp))
+ (nospace (bash-completion--nospace comp))
(wordbreaks (bash-completion--wordbreaks comp))
(suffix "")
(rest) ; the part between the prefix and the suffix
@@ -795,7 +796,7 @@ for directory name detection to work."
;; build suffix
(let ((last-char (bash-completion-last-char rest))
(close-quote-str (if open-quote (char-to-string open-quote) ""))
- (final-space-str (if (memq 'nospace options) "" " ")))
+ (final-space-str (if nospace "" " ")))
(cond
((eq ?\ last-char)
(setq rest (substring rest 0 -1))
@@ -1209,25 +1210,15 @@ Return the status code of the command, as a number."
(file-remote-p expanded 'localname)
expanded)))
-(defun bash-completion--extract-compgen-options (compgen-args)
- "Extract from COMPGEN-ARGS the -o option strings."
- (let ((rest compgen-args)
- (options (list)))
- (while (setq rest (cdr (member "-o" rest)))
- (push (car rest) options)
+(defun bash-completion--has-compgen-option (compgen-args option-name)
+ "Check whether COMPGEN-ARGS contains -o OPTION-NAME."
+ (let ((rest compgen-args) (found))
+ (while (and (not found)
+ (setq rest (cdr (member "-o" rest))))
+ (when (string= option-name (car rest))
+ (setq found t))
(setq rest (cdr rest)))
- options))
-
-(defun bash-completion--parse-options (option-strings)
- "Parse OPTIONS-STRINGS for compgen into a list of symbols.
-
-The only supported option is nospace, which might come from
-compgen options or from `bash-completion-nospace'"
- (if (if (eq 'as-configured bash-completion-nospace)
- (member "nospace" option-strings)
- bash-completion-nospace)
- '(nospace)
- nil))
+ found))
(provide 'bash-completion)
;;; bash-completion.el ends here
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index e3a753b46b..5a29b1a086 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -37,7 +37,7 @@
`(if (file-executable-p bash-completion-prog)
(let ((test-env-dir (bash-completion_test-setup-env)))
(let ((bash-completion-processes nil)
- (bash-completion-nospace 'as-configured)
+ (bash-completion-nospace nil)
(bash-completion-enable-caching nil)
(bash-completion-start-files nil)
(bash-completion-args
@@ -119,17 +119,16 @@ for testing completion."
(should (bash-completion-is-running))
(should-not (null (member
"help "
- (let ((bash-completion-nospace nil))
- (bash-completion-comm
- (bash-completion--make
- :line "hel"
- :point 4
- :words '("hel")
- :cword 0
- :stub "hel"
- :unparsed-stub "hel"
- :wordbreaks "@><=;|&(:")
- (bash-completion-require-process))))))
+ (bash-completion-comm
+ (bash-completion--make
+ :line "hel"
+ :point 4
+ :words '("hel")
+ :cword 0
+ :stub "hel"
+ :unparsed-stub "hel"
+ :wordbreaks "@><=;|&(:")
+ (bash-completion-require-process)))))
(bash-completion-reset)
(should-not (bash-completion-is-running))))
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index 65e5617f88..afb202f193 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -667,33 +667,45 @@ Return (const return-value new-buffer-content)"
nil)))))
;; append a space for initial command that is not a directory
- (should (let ((bash-completion-nospace nil))
- (equal "somecmd "
- (bash-completion-fix
- "somecmd"
- (bash-completion--make
- :cword 0
- :stub "some"
- :unparsed-stub "some"
- :wordbreaks "")
- 'single))))
+ (let ((bash-completion-nospace nil))
+ (should
+ (equal "somecmd "
+ (bash-completion-fix
+ "somecmd"
+ (bash-completion--make
+ :cword 0
+ :stub "some"
+ :unparsed-stub "some"
+ :wordbreaks "")
+ 'single))))
+
+ ;; ... but not if nospace option is set for the function
+ (should (equal "somecmd"
+ (bash-completion-fix
+ "somecmd"
+ (bash-completion--make
+ :cword 0
+ :stub "some"
+ :unparsed-stub "some"
+ :wordbreaks ""
+ :compgen-args '("-o" "nospace"))
+ nil)))
- ;; ... but not if nospace option is set
- (should (let ((bash-completion-nospace t))
- (equal "somecmd"
+ ;; ... or globally
+ (let ((bash-completion-nospace t))
+ (should (equal "somecmd"
(bash-completion-fix
"somecmd"
(bash-completion--make
:cword 0
:stub "some"
:unparsed-stub "some"
- :wordbreaks ""
- :compgen-args '("-o" "nospace"))
+ :wordbreaks "")
nil))))
;; append a space for a single completion
- (should (let ((bash-completion-nospace nil))
- (equal "somecmd "
+ (let ((bash-completion-nospace nil))
+ (should (equal "somecmd "
(bash-completion-fix
"somecmd"
(bash-completion--make
@@ -704,16 +716,17 @@ Return (const return-value new-buffer-content)"
'single))))
;; but only for a single completion
- (should (let ((bash-completion-nospace nil))
- (equal "somecmd"
- (bash-completion-fix
- "somecmd"
- (bash-completion--make
- :cword 0
- :stub "some"
- :unparsed-stub "some"
- :wordbreaks "")
- nil))))
+ (let ((bash-completion-nospace nil))
+ (should
+ (equal "somecmd"
+ (bash-completion-fix
+ "somecmd"
+ (bash-completion--make
+ :cword 0
+ :stub "some"
+ :unparsed-stub "some"
+ :wordbreaks "")
+ nil))))
;; subset of the prefix"
(should (equal "Dexter"
@@ -850,7 +863,8 @@ before calling `bash-completion-dynamic-complete-nocomint'.
`(let ((default-directory "/tmp/test")
(bash-completion-alist '())
(wordbreaks "@><=;|&(:")
- (bash-completion-enable-caching nil))
+ (bash-completion-enable-caching nil)
+ (bash-completion-nospace nil))
(lexical-let ((--process-buffer)
(--test-buffer)
(--send-results (list))
@@ -1120,28 +1134,21 @@ before calling
`bash-completion-dynamic-complete-nocomint'.
'("somedir/")
(nth 2 (bash-completion-dynamic-complete-nocomint 3
(point))))))))
-(ert-deftest bash-completion--extract-compgen-options-test ()
- (should (equal '("filenames" "default")
- (bash-completion--extract-compgen-options
- '("-a" "-o" "default" "-F" "fun" "-o" "filenames"))))
- (should (equal '()
- (bash-completion--extract-compgen-options
- '("-a" "-F" "fun"))))
- (should (equal '()
- (bash-completion--extract-compgen-options
- '("-a" "-F" "fun" "-o")))))
-
-(ert-deftest bash-completion--parse-options ()
- (let ((bash-completion-nospace 'as-configured))
- (should (equal nil (bash-completion--parse-options nil)))
- (should (equal '(nospace)
- (bash-completion--parse-options
- '("filenames" "nospace" "default"))))
- (setq bash-completion-nospace nil)
- (should (equal '() (bash-completion--parse-options
- '("nospace"))))
- (setq bash-completion-nospace t)
- (should (equal '(nospace)
- (bash-completion--parse-options '())))))
+(ert-deftest bash-completion--has-compgen-option ()
+ (should (equal nil
+ (bash-completion--has-compgen-option
+ '("-F" "boo" "-o" "filenames" "-a" "-o" "default")
+ "nospace")))
+ (should (equal t
+ (bash-completion--has-compgen-option
+ '("-F" "boo" "-o" "filenames" "-a" "-o" "default")
+ "filenames")))
+ (should (equal t
+ (bash-completion--has-compgen-option
+ '("-F" "boo" "-o" "filenames" "-a" "-o" "default")
+ "default")))
+ (should (equal nil (bash-completion--has-compgen-option
+ '("-o") "any")))
+ (should (equal nil (bash-completion--has-compgen-option '() "any"))))
;;; bash-completion_test.el ends here
- [nongnu] elpa/bash-completion 081d03bedc 156/313: Fix issue #21 completion bug, (continued)
- [nongnu] elpa/bash-completion 081d03bedc 156/313: Fix issue #21 completion bug, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1c2153d287 159/313: Call make-obsolete with three arguments, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7965b914da 160/313: Re-enable directory expansion for custom completion. fixes #23, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2c0b8d6a6e 163/313: Merge pull request #27 from vorburger/patch-1, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0c77c64b50 174/313: Disable bash-completion-enable-caching if completion-table-with-cache, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b281e1e181 008/313: bash-complete-add-to-alist, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1144ae69a9 056/313: documented the tokenizer, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 376dd532e2 057/313: modre documentation, up until wordbreak, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fd7e0e6fbe 078/313: added documentation, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion dd34b278bf 069/313: stopping at point; the easy way, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8756e80737 184/313: Replace 'options' in the completion struct with 'nospace'.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 2c4cb6edd2 186/313: Replace bash-completion-integration-test with a higher-level test for, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0aed19067b 188/313: When using Bash 4, split words as Bash 4 does., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4581a7823f 189/313: Bash 4: set COMP_TYPE and COMP_KEY to TAB, to let completion functions, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 802eb4e5a8 194/313: Set EMACS_BASH_COMPLETE even on remote (tramp) completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fbdc78b877 198/313: Support compopt when using Bash 4., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f1bd3d528f 201/313: Improve some docstrings, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fa49dbb382 209/313: Improve status code retrieval, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7822d84812 223/313: Added Cask with ert-runner to compile and run test., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 31a01859b2 227/313: Do not run tests under Emacs 24.1., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21471cc542 228/313: Report result of running the test workflow on README.md., ELPA Syncer, 2022/12/03