[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion f6e1c44057 013/313: put everything togethe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion f6e1c44057 013/313: put everything together |
Date: |
Sat, 3 Dec 2022 10:59:11 -0500 (EST) |
branch: elpa/bash-completion
commit f6e1c440570350bc9edd47ef252da638c4bedfe4
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
put everything together
---
bash-complete.el | 34 ++++++++++++++++++++++------------
bash-complete_test.el | 4 ++++
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/bash-complete.el b/bash-complete.el
index 0a2547d2f3..78f2d96980 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -28,18 +28,23 @@ Call bash to do the completion."
(bash-complete-dynamic-complete-0)))
(defun bash-complete-dynamic-complete-0 ()
- (save-excursion
(let* ( (pos (point))
(start (comint-line-beginning-position))
(end (line-end-position))
(line (buffer-substring-no-properties start end))
- (wordsplit (bash-complete-split start end pos))
- (words (car wordsplit))
- (cword (cdr wordsplit))
- (stub (nth cword words)) )
- (comint-simple-complete stub
- (bash-complete-comm
- line pos words cword)))))
+ (wordsplit)
+ (cword)
+ (words)
+ (stub) )
+ (save-excursion
+ (setq wordsplit (bash-complete-split start end pos))
+ (setq cword (car wordsplit))
+ (setq words (cdr wordsplit))
+ (setq stub (nth cword words)))
+ (comint-dynamic-simple-complete
+ stub
+ (bash-complete-comm
+ line (- pos start) words cword))))
(defun bash-complete-join (words)
"Join WORDS into a shell line, escaped all words with single quotes"
@@ -126,7 +131,12 @@ calls compgen.
The result is a list of candidates, which might be empty."
(bash-complete-send (concat (bash-complete-generate-line line pos words
cword) " 2>/dev/null"))
(with-current-buffer (bash-complete-buffer)
- (split-string (buffer-string) "\n" t)))
+ (mapcar 'bash-complete-trim (split-string (buffer-string) "\n" t))))
+
+(defun bash-complete-trim (str)
+ (if (string-match "^ *\\(.*[^ ]\\) *$" str)
+ (match-string 1 str)
+ str))
(defun bash-complete-require-process ()
;; TODO(szermatt): if this fails, kill process and complain
@@ -157,13 +167,13 @@ The result is a list of candidates, which might be empty."
(let ((function-name (car (cdr function))))
(setcar function "-F")
(setcar (cdr function) "__bash_complete_wrapper")
- (format "__BASH_COMPLETE_WRAPPER=%s compgen %s %s"
- (bash-complete-quote (format "COMP_LINE=%s; COMP_POS=%s;
COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
+ (format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
+ (bash-complete-quote (format "COMP_LINE=%s;
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
(bash-complete-quote line)
pos cword (bash-complete-join words)
(bash-complete-quote
function-name)))
(bash-complete-join args)
(bash-complete-quote (nth cword words))))
- (format "compgen %s %s" (bash-complete-join args) (nth cword
words)))))))
+ (format "compgen %s -- %s" (bash-complete-join args) (nth cword
words)))))))
(defun bash-complete-kill-process ()
(when (bash-complete-is-running)
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 3969b7303c..3a77c25ba7 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -187,6 +187,10 @@ garbage
(bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
"__BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; COMP_POS=7;
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F
__bash_complete_wrapper worl")
+ ("bash-complete-trim"
+ (mapcar 'bash-complete-trim '(" hello " " world " "x"))
+ '("hello" "world" "x"))
+
)))
- [nongnu] elpa/bash-completion 29b5fc860a 312/313: Shorten overly long docstring (#53), (continued)
- [nongnu] elpa/bash-completion 29b5fc860a 312/313: Shorten overly long docstring (#53), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3ffc296e0b 149/313: Close opened quote for all completion candidate that don't end with a, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6bf1536325 150/313: Fix occasional escaping issue with candidates containing quotes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21149fdc27 152/313: Introduce the variable bash-completion-start-files, that allow, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 31bc1c1c21 161/313: Compile bash-completion.el before running tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 054ecdfce3 290/313: ignore file ert-profile created by ert-runner, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c444230670 154/313: Add run_tests.sh, to run tests from the command-line, with specific, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0709a9803d 303/313: Support newlines in the output of complete -p., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c5eaeed156 311/313: Always ensure that a copy of the candidate list is returned (#48), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f6e1c44057 013/313: put everything together,
ELPA Syncer <=