[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)))
+ ))
- [elpa] branch externals/trie created (now 63da3b1), Stefan Monnier, 2020/12/14
- [elpa] externals/trie 1697b5f 001/111: trie.el re-implements tstree.el using AVL trees, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5a0883f 005/111: Fixed bug in trie-complete when passed list of prefixes.,
Stefan Monnier <=
- [elpa] externals/trie 4dc003b 006/111: Fixed bug when deleting non-existent entries., Stefan Monnier, 2020/12/14
- [elpa] externals/trie d998322 011/111: Made trie--terminator symbol into a configurable defconst., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6cdaed0 046/111: Removed left-over debugging code and other minor tidying., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 160f092 054/111: Revert "Replaced advice with cedet-edebug.el for pretty-printing", Stefan Monnier, 2020/12/14
- [elpa] externals/trie defa7e0 053/111: Replaced advice with cedet-edebug.el for pretty-printing, Stefan Monnier, 2020/12/14
- [elpa] externals/trie af10bd5 043/111: Bug-fix in trie--do-regexp-search, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 58c6685 014/111: Replaced bare avl-trees, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 9f5b6c2 060/111: Simplified persistent-storage code for tries and dict-trees., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6aa6701 033/111: Added optional RESULTFUN argument to trie query functions,, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 2345832 047/111: Advised edebug-prin1 and edebug-prin1-to-string to prevent edebug hanging, Stefan Monnier, 2020/12/14