emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/bash-completion 0d360a45cd 017/313: fixed test case


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 0d360a45cd 017/313: fixed test case
Date: Sat, 3 Dec 2022 10:59:11 -0500 (EST)

branch: elpa/bash-completion
commit 0d360a45cd51ef882cb46a824a61dd77cd8a5efc
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>

    fixed test case
---
 bash-complete.el      | 16 ++++++++--------
 bash-complete_test.el | 16 ++++++++--------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 2cec4cec64..3946ffcff9 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -1,7 +1,7 @@
 
 (require 'comint)
 
-(defvar bash-complete-command "bash" 
+(defvar bash-complete-command "bash"
   "Command-line to execute bash")
 
 (defvar bash-complete-process-timeout 2.5)
@@ -54,7 +54,7 @@ Call bash to do the completion."
        (setq stub (nth cword words)))
       (comint-dynamic-simple-complete
        stub
-       (bash-complete-comm
+       (bash-complete-comm default-directory
        line (- pos start) words cword))))
 
 (defun bash-complete-line-beginning-position (&optional start)
@@ -75,7 +75,7 @@ Call bash to do the completion."
     ""))
 
 (defun bash-complete-quote (word)
-  (if (string-match "^[a-zA-Z0-9_.-]*$" word)
+  (if (string-match "^[a-zA-Z0-9_./-]*$" word)
       word
     (concat "'"
            (replace-regexp-in-string "'" "'\\''" word :literal t)
@@ -141,15 +141,15 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
       (concat "^ \t\n\r" (char-to-string quote))
     "^ \t\n\r'\""))
 
-(defun bash-complete-comm (line pos words cword)
-  "Set LINE, POS, WORDS and CWORD, call bash completion, return the result.
+(defun bash-complete-comm (dir line pos words cword)
+  "Set DIR, LINE, POS, WORDS and CWORD, call bash completion, return the 
result.
 
 This function starts a separate bash process if necessary, sets 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."
-  (bash-complete-send (concat (bash-complete-generate-line line pos words 
cword) " 2>/dev/null"))
+  (bash-complete-send (concat (bash-complete-generate-line dir line pos words 
cword) " 2>/dev/null"))
   (with-current-buffer (bash-complete-buffer)
     (mapcar 'bash-complete-trim (split-string (buffer-string) "\n" t))))
 
@@ -198,9 +198,9 @@ The result is a list of candidates, which might be empty."
                (kill-process process)
              (error nil))))))))
 
-(defun bash-complete-generate-line (line pos words cword)
+(defun bash-complete-generate-line (dir line pos words cword)
   (concat
-   (if default-directory (concat "cd " (bash-complete-quote (expand-file-name 
default-directory)) " ; ") "")
+   (if default-directory (concat "cd " (bash-complete-quote (expand-file-name 
dir)) " ; ") "")
    (let* ( (command (file-name-nondirectory (car words)))
           (compgen-args (cdr (assoc command bash-complete-alist))) )
      (if (not compgen-args)
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 64e21ba716..d5dfb32955 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -169,23 +169,23 @@ garbage
 
      ("bash-complete-generate-line no custom completion"
       (let ((bash-complete-alist nil))
-       (bash-complete-generate-line "hello worl" 7 '("hello" "worl") 1))
-      "compgen -o default worl")
+       (bash-complete-generate-line "~/test" "hello worl" 7 '("hello" "worl") 
1))
+      (concat "cd " (expand-file-name "~/test") " ; compgen -o default worl"))
 
      ("bash-complete-generate-line custom completion no function or command"
       (let ((bash-complete-alist '(("zorg" . ("-A" "-G" "*.txt")))))
-       (bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
-      "compgen -A -G '*.txt' worl")
+       (bash-complete-generate-line "/test" "zorg worl" 7 '("zorg" "worl") 1))
+      "cd /test ; compgen -A -G '*.txt' -- worl")
 
      ("bash-complete-generate-line custom completion function"
       (let ((bash-complete-alist '(("zorg" . ("-F" "__zorg")))))
-       (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-generate-line "/test" "zorg worl" 7 '("zorg" "worl") 1))
+      "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper -- worl")
 
      ("bash-complete-generate-line custom completion command"
       (let ((bash-complete-alist '(("zorg" . ("-C" "__zorg")))))
-       (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-generate-line "/test" "zorg worl" 7 '("zorg" "worl") 1))
+      "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=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"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]