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

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

[elpa] externals/trie 5a0883f 005/111: Fixed bug in trie-complete when p


From: Stefan Monnier
Subject: [elpa] externals/trie 5a0883f 005/111: Fixed bug in trie-complete when passed list of prefixes.
Date: Mon, 14 Dec 2020 11:35:09 -0500 (EST)

branch: externals/trie
commit 5a0883fc1961664dc72610443aa4fd6e775ed567
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>

    Fixed bug in trie-complete when passed list of prefixes.
---
 trie.el | 88 ++++++++++++++++++++++++++++++++---------------------------------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/trie.el b/trie.el
index d6a6e97..e51309c 100644
--- a/trie.el
+++ b/trie.el
@@ -1025,7 +1025,7 @@ completion with two arguments: the completion, and its 
associated
 data. If the filter function returns nil, the completion is not
 included in the results, and does not count towards MAXNUM."
 
-  (let ((node (trie--node-find trie prefix))
+  (let (node
        (trie--complete-accumulate
         (if rankfun
             (heap-create  ; heap order is inverse of rank order
@@ -1036,50 +1036,50 @@ included in the results, and does not count towards 
MAXNUM."
           (make-vector 1 nil)))
        accumulator)
 
-    (when node
-      ;; wrap prefix in a list if necessary
-      ;; FIXME: the test for a list of prefixes, below, will fail if the
-      ;;        PREFIX sequence is a list, and the elements of PREFIX are
-      ;;        themselves lists (there might be no easy way to fully fix
-      ;;        this...)
-      (if (or (atom prefix) (and (listp prefix) (not (sequencep (car 
prefix)))))
-         (setq prefix (list prefix))
-       ;; sort list of prefixes if sorting completions lexically
-       (when (null rankfun)
-         (setq prefix
-               (sort prefix (eval (macroexpand
-                                   `(trie-construct-sortfun
-                                     ,(trie--comparison-function trie))))))))
-
-      ;; construct function to accumulate completions (might as well save a
-      ;; few cycles in the `trie--mapc' call by constructing different
-      ;; functions depending on whether MAXNUM and FILTER were specified)
-      (if rankfun
-         (setq accumulator
-               (trie--complete-construct-ranked-accumulator maxnum filter))
-       (setq accumulator (trie--complete-construct-accumulator
-                          maxnum filter)))
-
-      ;; accumulate completions
-      (catch 'trie-complete--done
-       (mapc (lambda (pfx)
+    ;; wrap prefix in a list if necessary
+    ;; FIXME: the test for a list of prefixes, below, will fail if the PREFIX
+    ;;        sequence is a list, and the elements of PREFIX are themselves
+    ;;        lists (there might be no easy way to fully fix this...)
+    (if (or (atom prefix) (and (listp prefix) (not (sequencep (car prefix)))))
+       (setq prefix (list prefix))
+      ;; sort list of prefixes if sorting completions lexically
+      (when (null rankfun)
+       (setq prefix
+             (sort prefix (eval (macroexpand
+                                 `(trie-construct-sortfun
+                                   ,(trie--comparison-function trie))))))))
+
+    ;; construct function to accumulate completions (might as well save a few
+    ;; cycles in the `trie--mapc' call by constructing different functions
+    ;; depending on whether MAXNUM and FILTER were specified)
+    (if rankfun
+       (setq accumulator
+             (trie--complete-construct-ranked-accumulator maxnum filter))
+      (setq accumulator (trie--complete-construct-accumulator
+                        maxnum filter)))
+
+    ;; accumulate completions
+    (catch 'trie-complete--done
+      (mapc (lambda (pfx)
+             (setq node (trie--node-find trie pfx))
+             (when node
                (trie--mapc accumulator (trie--mapfun trie) node pfx
-                           (if maxnum reverse (not reverse))))
-             prefix))
-
-      ;; return list of completions
-      (cond
-       ;; extract completions from heap for ranked query
-       (rankfun
-       (let (completions)
-         (while (not (heap-empty trie--complete-accumulate))
-           (push (heap-delete-root trie--complete-accumulate) completions))
-         completions))
-       ;; reverse result list if MAXNUM supplied
-       (maxnum (nreverse (aref trie--complete-accumulate 0)))
-       ;; otherwise, just return list
-       (t (aref trie--complete-accumulate 0)))
-      )))
+                           (if maxnum reverse (not reverse)))))
+           prefix))
+
+    ;; return list of completions
+    (cond
+     ;; extract completions from heap for ranked query
+     (rankfun
+      (let (completions)
+       (while (not (heap-empty trie--complete-accumulate))
+         (push (heap-delete-root trie--complete-accumulate) completions))
+       completions))
+     ;; reverse result list if MAXNUM supplied
+     (maxnum (nreverse (aref trie--complete-accumulate 0)))
+     ;; otherwise, just return list
+     (t (aref trie--complete-accumulate 0)))
+    ))
 
 
 



reply via email to

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