[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 6ab1fe406b 148/313: Always quote the stub
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 6ab1fe406b 148/313: Always quote the stub before passing it to compgen. |
Date: |
Sat, 3 Dec 2022 10:59:25 -0500 (EST) |
branch: elpa/bash-completion
commit 6ab1fe406b774ef3cc9defb7b79c421ee9027ab7
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Always quote the stub before passing it to compgen.
Before this commit, the stub was quoted only sometimes, when doing
custom completion using a function. This caused issues when completing
stubs with spaces.
---
bash-completion-test.el | 18 +++++++++++++++++-
bash-completion.el | 11 ++++++-----
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/bash-completion-test.el b/bash-completion-test.el
index f9a5b2ee1f..4c4902c457 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -814,7 +814,12 @@ before calling `bash-completion-dynamic-complete-nocomint'.
(should (equal
'("Documents/Modes\\ d\\'emplois/KAR\\ 1.pdf"
"Documents/Modes\\ d\\'emplois/KAR\\ 2.pdf")
- (nth 2(bash-completion-dynamic-complete-nocomint 3 (point)))))))
+ (nth 2(bash-completion-dynamic-complete-nocomint 3 (point)))))
+ (should (equal
+ (concat
+ "cd >/dev/null 2>&1 /tmp/test ; "
+ "compgen -o default -- 'Documents/Modes d'\\''emplois/'
2>/dev/null")
+ (pop --captured-commands)))))
(ert-deftest bash-completion-complete-single-quoted-dir ()
(--with-fake-bash-completion-send
@@ -851,6 +856,17 @@ before calling `bash-completion-dynamic-complete-nocomint'.
"compgen -b -c -a -A function -- b 2>/dev/null")
(pop --captured-commands)))))
+(ert-deftest bash-completion-complete-command-with-space ()
+ (--with-fake-bash-completion-send
+ (push "some command\n" --send-results)
+ (insert "$ some\\ c")
+ (should (equal
+ '("some\\ command ")
+ (nth 2 (bash-completion-dynamic-complete-nocomint 3 (point)))))
+ (should (equal (concat "cd >/dev/null 2>&1 /tmp/test ; "
+ "compgen -b -c -a -A function -- 'some c'
2>/dev/null")
+ (pop --captured-commands)))))
+
(ert-deftest bash-completion-failed-completion ()
(--with-fake-bash-completion-send
(setq --send-results '("" "bad"))
diff --git a/bash-completion.el b/bash-completion.el
index 0c44a8121b..141dfdc22e 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1101,19 +1101,19 @@ completion candidates."
(compgen-args
(or (cdr (assoc command-name bash-completion-alist))
(and allowdefault (cdr (assoc nil bash-completion-alist)))))
- (stub (nth cword words))
+ (quoted-stub (bash-completion-quote (nth cword words)))
(completion-type)
(commandline) )
(cond
((= cword 0)
;; a command. let bash expand builtins, aliases and functions
(setq completion-type 'command)
- (setq commandline (concat "compgen -b -c -a -A function -- " stub)))
+ (setq commandline (concat "compgen -b -c -a -A function -- "
quoted-stub)))
((not compgen-args)
;; no completion configured for this command
(setq completion-type 'default)
- (setq commandline (concat "compgen -o default -- " stub)))
+ (setq commandline (concat "compgen -o default -- " quoted-stub)))
((or (member "-F" compgen-args) (member "-C" compgen-args))
;; custom completion with a function of command
@@ -1133,11 +1133,12 @@ completion candidates."
(bash-completion-join words)
(bash-completion-quote function-name)))
(bash-completion-join args)
- (bash-completion-quote stub)))))
+ quoted-stub))))
(t
;; simple custom completion
(setq completion-type 'custom)
- (setq commandline (format "compgen %s -- %s" (bash-completion-join
compgen-args) stub))))
+ (setq commandline (format "compgen %s -- %s" (bash-completion-join
compgen-args)
+ quoted-stub))))
(cons completion-type
(concat
(bash-completion-cd-command-prefix)
- [nongnu] elpa/bash-completion dce43a54c5 119/313: Update comment in bash-completion-test, (continued)
- [nongnu] elpa/bash-completion dce43a54c5 119/313: Update comment in bash-completion-test, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5209200f3b 120/313: Using cl-letf instead of flet., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9588a9c0dd 125/313: Updated README, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c5f2b2756f 129/313: Define sz-testutils as a global variable., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f085c41d8d 131/313: Add defcustom for bash-completion-args, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8ca917f428 133/313: Stop escaping = in completion. fixes #18, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 319886faa9 138/313: Add / after directory names - even if they contain spaces or special, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f2ea2b65df 141/313: Detect directories when expanding commands and add a slash instead of a, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 44bc73449e 144/313: Fixes strange behavior when completing --., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b4757884b0 145/313: Expand the tests to better cover wordbreak and command argument, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6ab1fe406b 148/313: Always quote the stub before passing it to compgen.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion a789093cd3 155/313: Run tests on older versions of Emacs., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5e05365dc8 153/313: Cleanup tests, split them into unit and integration tests., ELPA Syncer, 2022/12/03
- [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