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

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

[nongnu] elpa/bash-completion e95867c993 256/313: completion-table-with-


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion e95867c993 256/313: completion-table-with-cache captures and restore buffer and variables.
Date: Sat, 3 Dec 2022 10:59:35 -0500 (EST)

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

    completion-table-with-cache captures and restore buffer and variables.
    
    With this change, completion-table-with-cache restores the original
    buffer. This is useful as here's no guarantee of what the current
    buffer is when the dynamic table function is called, so enforce it
    before calling bash-completion--complete, to be sure.
    
    This change also restores the current directory as well as the value
    of bash-completion-use-separate-processes and bash-completion-nospace,
    as both these are often overridden temporarily in a let section.
---
 bash-completion.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index b6d6d20301..8bd28a4584 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -568,8 +568,7 @@ Returns (list stub-start stub-end completions) with
          comp-pos
          (if dynamic-table
              (bash-completion--completion-table-with-cache
-              comp process
-              bash-completion-use-separate-processes)
+              comp process)
            (bash-completion--complete comp process)))))))
 
 (defun bash-completion--find-last (elt array)
@@ -1538,7 +1537,7 @@ Return the parsed value, as a string or nil."
         (prog1 (match-string 1)
           (delete-region (match-beginning 0) (match-end 0)))))))
 
-(defun bash-completion--completion-table-with-cache (comp process 
use-separate-process)
+(defun bash-completion--completion-table-with-cache (comp process)
   "Build a dynamic completion table for COMP using PROCESS.
 
 The result is a function that works like one built by
@@ -1546,16 +1545,23 @@ The result is a function that works like one built by
 completions, built by `bash-completion--complete' are complete
 and that completion style doesn't necessarily use substring
 completion."
-  (let ((last-str) (last-result))
+  (let ((last-str) (last-result)
+        (calling-buffer (current-buffer))
+        (dir default-directory)
+        (use-separate-process bash-completion-use-separate-processes)
+        (nospace bash-completion-nospace))
     (lambda (str predicate action)
       (if (or (eq (car-safe action) 'boundaries)
               (eq action 'metadata))
           nil
-        (let ((result (if (equal str last-str)
-                          last-result
-                        (let ((bash-completion-use-separate-processes
-                               use-separate-process))
-                          (bash-completion--complete comp process)))))
+        (let ((result
+               (if (equal str last-str)
+                   last-result
+                 (let ((bash-completion-use-separate-processes 
use-separate-process)
+                       (bash-completion-nospace nospace)
+                       (default-directory dir))
+                   (with-current-buffer calling-buffer
+                     (bash-completion--complete comp process))))))
           (setq last-str str
                 last-result result)
           ;; The below passes an empty string to try-completion,



reply via email to

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