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

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

[nongnu] elpa/bash-completion 04393bca0f 250/313: Apply filename post-pr


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 04393bca0f 250/313: Apply filename post-processing even when prefix doesn't match.
Date: Sat, 3 Dec 2022 10:59:35 -0500 (EST)

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

    Apply filename post-processing even when prefix doesn't match.
    
    Before this change, the case where completion doesn't match the prefix
    was special-cased, and bypassed the post-processing that detects
    filename type, adding / or " ". With this change, the post-processing
    is applied both when the prefix matched and when it didn't.
---
 bash-completion.el | 54 ++++++++++++++++++++++++++----------------------------
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 70a60c5b4b..c826741622 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -958,7 +958,6 @@ for directory name detection to work."
         (wordbreaks (bash-completion--wordbreaks comp))
         (suffix "")
         (rest) ; the part between the prefix and the suffix
-        (whole)
         (rebuilt))
 
     ;; build rest by removing parsed-prefix from str
@@ -990,34 +989,33 @@ for directory name detection to work."
      ;; Bypass the whole prefix/suffix logic and replace the string
      ;; being completed with the string provided by the completion
      ;; logic.
-     (t (setq whole str)))
+     (t (setq unparsed-prefix ""
+              parsed-prefix ""
+              rest str)))
     
-    (if whole
-        (bash-completion-escape-candidate whole nil)
-      
-      ;; build suffix
-      (let ((last-char (bash-completion-last-char rest))
-            (close-quote-str (if open-quote (char-to-string open-quote) ""))
-            (final-space-str (if nospace "" " ")))
-        (cond
-         ((eq ?\  last-char)
-          (setq rest (substring rest 0 -1))
-          (setq suffix (concat close-quote-str final-space-str)))
-         ((or (bash-completion--find-last last-char wordbreaks)
-              (eq ?/ last-char))
-          (setq suffix ""))
-         ((file-accessible-directory-p
-           (bash-completion--expand-file-name (bash-completion-unescape
-                                               open-quote (concat 
parsed-prefix rest))))
-          (setq suffix "/"))
-         (single
-          (setq suffix (concat close-quote-str final-space-str)))
-         (t (setq suffix close-quote-str))))
-      
-      ;; put everything back together
-      (concat unparsed-prefix
-              (bash-completion-escape-candidate rest open-quote)
-              suffix))))
+    ;; build suffix
+    (let ((last-char (bash-completion-last-char rest))
+          (close-quote-str (if open-quote (char-to-string open-quote) ""))
+          (final-space-str (if nospace "" " ")))
+      (cond
+       ((eq ?\  last-char)
+        (setq rest (substring rest 0 -1))
+        (setq suffix (concat close-quote-str final-space-str)))
+       ((or (bash-completion--find-last last-char wordbreaks)
+            (eq ?/ last-char))
+        (setq suffix ""))
+       ((file-accessible-directory-p
+         (bash-completion--expand-file-name (bash-completion-unescape
+                                             open-quote (concat parsed-prefix 
rest))))
+        (setq suffix "/"))
+       (single
+        (setq suffix (concat close-quote-str final-space-str)))
+       (t (setq suffix close-quote-str))))
+    
+    ;; put everything back together
+    (concat unparsed-prefix
+            (bash-completion-escape-candidate rest open-quote)
+            suffix)))
 
 (defun bash-completion-escape-candidate (completion-candidate open-quote)
   "Escapes COMPLETION-CANDIDATE.



reply via email to

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