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

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

[nongnu] elpa/bash-completion 4a1d89f01e 246/313: Support -o vi and emac


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 4a1d89f01e 246/313: Support -o vi and emacs even in single-process mode.
Date: Sat, 3 Dec 2022 10:59:35 -0500 (EST)

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

    Support -o vi and emacs even in single-process mode.
    
    Changes to the default editing interface must be turned off or adapted
    to when in single-process mode, too.
    
    This changes also adds tests for both options in single and
    multi-process mode.
---
 bash-completion.el                       |  3 ++-
 test/bash-completion-integration-test.el | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index cf6ede1a37..20a8abc7c0 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -379,6 +379,7 @@ returned."
 (defun bash-completion--setup-bash-common (process)
   "Setup PROCESS to be ready for completion."
   (let (bash-major-version)
+    (bash-completion-send "set +o vi" process)
     (bash-completion-send "complete -p" process)
     (process-put process 'complete-p
                  (bash-completion-build-alist (bash-completion--get-buffer 
process)))
@@ -1460,7 +1461,7 @@ Return the status code of the command, as a number."
                (concat
                 commandline
                 (unless bash-completion-use-separate-processes
-                  "; echo \"--\v$?\"; history -d $((HISTCMD - 1))")
+                  "; echo -e \"--\\v$?\"; history -d $((HISTCMD - 1))")
                 "\n"))
       (if bash-completion-use-separate-processes
           (unless (bash-completion--wait-for-regexp process 
"\t-?[[:digit:]]+\v" timeout)
diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index 8976ce0d04..c767129a2b 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -333,4 +333,27 @@ for testing completion."
    (should (equal '("batitita" "batitito")
                   (bash-completion_test-candidates "myprog blah titi")))))
 
+(ert-deftest bash-completion-integration-vioption-single-process-test ()
+  (bash-completion_test--with-bash-option "set -o vi" nil))
+
+(ert-deftest bash-completion-integration-vioption-multi-processes-test ()
+  (bash-completion_test--with-bash-option "set -o vi" t))
+  
+(ert-deftest bash-completion-integration-emacsoption-single-process-test ()
+  (bash-completion_test--with-bash-option "set -o emacs" nil))
+
+(ert-deftest bash-completion-integration-emacsoption-multi-process-test ()
+  (bash-completion_test--with-bash-option "set -o emacs" t))
+
+(defun bash-completion_test--with-bash-option (turn-on-option 
use-separate-process)
+  (bash-completion_test-with-shell-harness
+   (concat ; .bashrc
+    turn-on-option "\n"
+    "function _dummy { COMPREPLY=(Yooo); }\n"
+    "function dummy { echo $1; }\n"
+    "complete -F _dummy dummy\n")
+   use-separate-process
+   (should (equal "dummy 1 Yooo "
+                  (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]