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

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

[nongnu] elpa/bash-completion 2dbc7e61f6 248/313: Extend bash-completion


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 2dbc7e61f6 248/313: Extend bash-completion-refresh to refresh everything, test it.
Date: Sat, 3 Dec 2022 10:59:35 -0500 (EST)

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

    Extend bash-completion-refresh to refresh everything, test it.
---
 bash-completion.el                       | 12 ++++++------
 test/bash-completion-integration-test.el | 25 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 156e97ebf5..70a60c5b4b 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1350,18 +1350,18 @@ completion candidates."
 
 ;;;###autoload
 (defun bash-completion-refresh ()
-  "Refresh the completion table.
+  "Force a refresh the completion table.
 
 This can be called after changing the completion table on BASH,
-with the builtin complete.
+or after starting a new BASH job.
 
 This is only useful when `bash-completion-use-separate-processes'
 is t."
   (interactive)
-  (let* ((process (bash-completion--get-process))
-         (buffer (bash-completion--get-buffer process)))
-    (bash-completion-send "complete -p" process)
-    (process-put process 'complete-p (bash-completion-build-alist buffer))))
+  (let* ((process (bash-completion--get-process)))
+    (unless process
+      (error "Bash completion not available on current buffer."))
+    (bash-completion--setup-bash-common process)))
   
 ;;;###autoload
 (defun bash-completion-reset ()
diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index c767129a2b..7a8326a655 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -108,6 +108,15 @@
   (buffer-substring-no-properties
    (line-beginning-position) (point)))
 
+(defun bash-completion_test-send (command)
+  "Execute COMMAND in a shell buffer."
+  (goto-char (point-max))
+  (delete-region (line-beginning-position) (line-end-position))
+  (insert command)
+  (comint-send-input)
+  (bash-completion--wait-for-regexp
+   (get-buffer-process (current-buffer)) comint-prompt-regexp 3.0))
+
 (defun bash-completion_test-candidates (complete-me)
   "Complete COMPLETE-ME and returns the candidates."
   (goto-char (point-max))
@@ -356,4 +365,20 @@ for testing completion."
    (should (equal "dummy 1 Yooo "
                   (bash-completion_test-complete "dummy 1 Y")))))
 
+(ert-deftest bash-completion-integration-refresh-test ()
+  (bash-completion_test-with-shell-harness
+   (concat ; .bashrc
+    "function _dummy { COMPREPLY=(Yooo); }\n"
+    "function dummy { echo $1; }\n"
+    "complete -F _dummy dummy\n")
+   nil ; use-separate-process
+   (should (equal "dummy 1 Yooo "
+                  (bash-completion_test-complete "dummy 1 Y")))
+   (bash-completion_test-send "function _dummy2 { COMPREPLY=(Yaaa); }")
+   (bash-completion_test-send "complete -F _dummy2 dummy")
+   (bash-completion-refresh)
+   (should (equal "dummy 1 Yaaa "
+                  (bash-completion_test-complete "dummy 1 Y")))))
+
+   
 ;;; bash-completion-integration-test.el ends here



reply via email to

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