[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie 81268ae 012/111: Added functions for pushing thing
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie 81268ae 012/111: Added functions for pushing things onto dictree and trie stacks |
Date: |
Mon, 14 Dec 2020 11:35:10 -0500 (EST) |
branch: externals/trie
commit 81268ae9cab8f151c5fbf1621e847242b2ecde7a
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Added functions for pushing things onto dictree and trie stacks
---
trie.el | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/trie.el b/trie.el
index 139b004..aa41fef 100644
--- a/trie.el
+++ b/trie.el
@@ -333,9 +333,9 @@ If START or END is negative, it counts from the end."
;; Return t if NODE is a trie--node, nil otherwise.
;; Have to define this ourselves, because we created a defstruct
;; without any identifying tags (i.e. (:type vector)) for efficiency.
- `(or (trie--node-data-p ,node)
- (and (vectorp ,node)
- (= (length ,node) 2)
+ `(and (vectorp ,node)
+ (= (length ,node) 2)
+ (or (trie--node-data-p ,node)
(trie--p (trie--node-subtree ,node)))))
@@ -396,6 +396,7 @@ If START or END is negative, it counts from the end."
(funcall stack-createfun
(trie--node-subtree (trie--root trie))
reverse)))))
+ (pushed '())
))
(:constructor
trie--completion-stack-create
@@ -408,9 +409,11 @@ If START or END is negative, it counts from the end."
(stack-emptyfun (trie--stack-emptyfun trie))
(store (trie--completion-stack-construct-store
trie prefix reverse))
+ (pushed '())
))
(:copier nil))
- reverse stack-createfun stack-popfun stack-emptyfun store)
+ reverse predicatefun stack-createfun stack-popfun stack-emptyfun
+ store pushed)
(defun trie--completion-stack-construct-store (trie prefix reverse)
@@ -438,9 +441,8 @@ If START or END is negative, it counts from the end."
;; Recursively push children of the node at the head of STACK onto the front
;; of STACK, until a data node is reached.
- ;; nothing to do if stack is empty or first element isn't a trie node
- (when (and (not (trie-stack-empty-p stack))
- (trie--node-p (trie-stack-first stack)))
+ ;; nothing to do if stack is empty
+ (unless (trie-stack-empty-p stack)
(let ((node (funcall (trie--stack-stack-popfun stack)
(cdar (trie--stack-store stack))))
(seq (caar (trie--stack-store stack))))
@@ -871,21 +873,29 @@ it is better to use one of those instead."
(defun trie-stack-pop (trie-stack)
"Pop the first element from TRIE-STACK.
Returns nil if the stack is empty."
- (let ((first (pop (trie--stack-store trie-stack))))
- (when first
- (trie--stack-repopulate trie-stack)
- first)))
+ ;; if elements have been pushed onto the stack, pop those first
+ (if (trie--stack-pushed trie-stack)
+ (pop (trie--stack-pushed trie-stack))
+ ;; otherwise, pop first element from trie-stack and repopulate it
+ (let ((first (pop (trie--stack-store trie-stack))))
+ (when first
+ (trie--stack-repopulate trie-stack)
+ first))))
(defun trie-stack-push (element trie-stack)
"Push ELEMENT onto TRIE-STACK."
- (push element (trie--stack-store trie-stack)))
+ (push element (trie--stack-pushed trie-stack)))
(defun trie-stack-first (trie-stack)
"Return the first element from TRIE-STACK, without removing it
from the stack. Returns nil if the stack is empty."
- (car (trie--stack-store trie-stack)))
+ ;; if elements have been pushed onto the stack, return first of those
+ (if (trie--stack-pushed trie-stack)
+ (car (trie--stack-pushed trie-stack))
+ ;; otherwise, return first element from trie-stack
+ (car (trie--stack-store trie-stack))))
(defalias 'trie-stack-p 'trie--stack-p
@@ -894,7 +904,8 @@ from the stack. Returns nil if the stack is empty."
(defun trie-stack-empty-p (trie-stack)
"Return t if TRIE-STACK is empty, nil otherwise."
- (null (trie--stack-store trie-stack)))
+ (and (null (trie--stack-store trie-stack))
+ (null (trie--stack-pushed trie-stack))))
- [elpa] externals/trie cc94506 070/111: Enable lexical binding, and fix issues it picks up., (continued)
- [elpa] externals/trie cc94506 070/111: Enable lexical binding, and fix issues it picks up., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6a449ed 049/111: Improved edebug-prin1 advice, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 7bf9008 100/111: Implement fuzzy-completion with fixed initial prefix segment., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 3117b5b 076/111: Fix bugs in trie searches introduced by code cleanup., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5909c59 083/111: Include prefix length information in fuzzy completion results., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 18dc856 084/111: Don't wrap rank and filter functions for regexp and fuzzy queries., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 633c8b1 089/111: Mention iterator generators in Commentary., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 1eb515f 078/111: Implement trie fuzzy match and completion stacks., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 3b7aa3c 082/111: Document that fuzzy queries with distance 0 won't work., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 53146c1 080/111: Implement fuzzy match and completion on dict-trees., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 81268ae 012/111: Added functions for pushing things onto dictree and trie stacks,
Stefan Monnier <=
- [elpa] externals/trie a402c27 021/111: Implemented wildcard searches!, Stefan Monnier, 2020/12/14
- [elpa] externals/trie e505b47 039/111: Pass equality function constructed from trie comparison function to tNFA functions, Stefan Monnier, 2020/12/14
- [elpa] externals/trie a35651b 029/111: Implemented grouping constructs in trie wildcards, Stefan Monnier, 2020/12/14
- [elpa] externals/trie a8615f7 052/111: Bug-fixes to edebug pretty-print functions., Stefan Monnier, 2020/12/14
- [elpa] externals/trie a1f9faa 044/111: Re-filled to 72 chars/line, for mailing to gnu-emacs-sources list, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 13bb42f 042/111: Updated docstrings for regexp-related functions and others., Stefan Monnier, 2020/12/14
- [elpa] externals/trie c7c9994 015/111: trie--createfun now passed corresponding sequence as an argument, Stefan Monnier, 2020/12/14
- [elpa] externals/trie da9ace9 051/111: More efficient implementations of replacements for CL 'position' function., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 0d17008 037/111: Added nilflag argument to trie-stack functions, Stefan Monnier, 2020/12/14
- [elpa] externals/trie f930fe9 027/111: Documentation updates related to wildcard searches and predictive features that make use of them, Stefan Monnier, 2020/12/14