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

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

[nongnu] elpa/bash-completion 33ed66e567 099/313: bash-completion-nospac


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 33ed66e567 099/313: bash-completion-nospace option
Date: Sat, 3 Dec 2022 10:59:20 -0500 (EST)

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

    bash-completion-nospace option
---
 bash-completion.el      | 16 +++++++++++++++-
 bash-completion_test.el | 17 ++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 122cfd6800..0498598fb3 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -189,6 +189,19 @@ which typically takes a long time."
   :type '(float)
   :group 'bash-completion)
 
+(defcustom bash-completion-nospace nil
+  "Never let bash add a final space at the end of a completion.
+
+When there is only one completion candidate, bash sometimes adds
+a space at the end of the completion to move the cursor at the
+appropriate position to add more command-line arguments. This
+feature doesn't always work perfectly with programmable completion.
+
+Enable this option if you find yourself having to often backtrack
+to remove the extra space bash adds after a completion."
+  :type '(boolean)
+  :group 'bash-completion)
+
 ;;; ---------- Internal variables and constants
 
 (defvar bash-completion-process nil
@@ -691,7 +704,8 @@ for directory name detection to work."
                   (t str))))
        (when (bash-completion-ends-with rest " ")
         (setq rest (substring rest 0 -1))
-        (setq suffix " "))
+        (unless bash-completion-nospace
+            (setq suffix " ")))
        (concat prefix (bash-completion-escape-candidate rest open-quote) 
suffix)))))
 
 (defun bash-completion-escape-candidate (completion-candidate open-quote)
diff --git a/bash-completion_test.el b/bash-completion_test.el
index ae079f222b..e68bca7ddd 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -469,8 +469,14 @@ garbage
       "a\\ bc\\ d\\ e")
 
      ("bash-completion-fix do not escape final space"
-      (bash-completion-fix "ab " "a")
+      (let ((bash-completion-nospace nil))
+       (bash-completion-fix "ab " "a"))
       "ab ")
+     
+     ("bash-completion-fix remove final space"
+      (let ((bash-completion-nospace t))
+       (bash-completion-fix "ab " "a"))
+      "ab")
 
      ("bash-completion-fix unexpand home and escape"
       (bash-completion-fix (expand-file-name "~/a/hello world") "~/a/he")
@@ -489,10 +495,11 @@ garbage
       "Dexter")
 
      ("bash-completion-extract-candidates"
-      (flet ((bash-completion-buffer () (current-buffer)))
-       (sz-testutils-with-buffer
-        "hello world\nhello \n\n"
-        (bash-completion-extract-candidates "hello" nil)))
+      (let ((bash-completion-nospace nil))
+       (flet ((bash-completion-buffer () (current-buffer)))
+         (sz-testutils-with-buffer
+          "hello world\nhello \n\n"
+          (bash-completion-extract-candidates "hello" nil))))
       '("hello\\ world" "hello "))
 
      ("bash-completion-nonsep"



reply via email to

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