[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie 0d17008 037/111: Added nilflag argument to trie-st
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie 0d17008 037/111: Added nilflag argument to trie-stack functions |
Date: |
Mon, 14 Dec 2020 11:35:15 -0500 (EST) |
branch: externals/trie
commit 0d17008b3e7d41c5e4ffbe0bd5d53fb6df498abd
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Added nilflag argument to trie-stack functions
---
trie.el | 59 ++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 40 insertions(+), 19 deletions(-)
diff --git a/trie.el b/trie.el
index 7bd693b..8cd03bb 100644
--- a/trie.el
+++ b/trie.el
@@ -1094,15 +1094,20 @@ is better to use one of those instead."
(trie--stack-create trie type reverse)))
-(defun trie-stack-pop (trie-stack)
+(defun trie-stack-pop (trie-stack &optional nilflag)
"Pop the first element from TRIE-STACK.
-Returns nil if the stack is empty."
- ;; 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
+
+Returns nil if the stack is empty, or NILFLAG if specified. (The
+latter allows an empty stack to be distinguished from a null
+element stored in the trie.)"
+ ;; return nilflag if stack is empty
+ (if (trie-stack-empty-p trie-stack)
+ nilflag
+ ;; 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))))
(setf (trie--stack-store trie-stack)
(funcall (trie--stack-repopulatefun trie-stack)
(trie--stack-store trie-stack)
@@ -1120,14 +1125,21 @@ Returns nil if the stack is empty."
(push element (trie--stack-pushed trie-stack)))
-(defun trie-stack-first (trie-stack)
+(defun trie-stack-first (trie-stack &optional nilflag)
"Return the first element from TRIE-STACK, without removing it
-from the stack. Returns nil if the stack is empty."
- ;; 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))))
+from the stack.
+
+Returns nil if the stack is empty, or NILFLAG if specified. (The
+latter allows an empty stack to be distinguished from a null
+element stored in the trie.)"
+ ;; return nilflag if stack is empty
+ (if (trie-stack-empty-p trie-stack)
+ nilflag
+ ;; 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
@@ -1529,9 +1541,8 @@ it is better to use one of those instead."
`(cdr ,el))
-
;;; ----------------------------------------------------------------
-;;; The public search functions
+;;; The public wildcard search functions
(defun trie-wildcard-match (pattern sequence cmpfun)
"Return t if wildcard PATTERN matches SEQ, nil otherwise.
@@ -1951,7 +1962,6 @@ first!."
-
;;; ------------------------------------------------------------------
;;; Internal functions (do the real work)
@@ -2036,6 +2046,9 @@ first!."
+;;; ------------------------------------------------------------------
+;;; wildcard search
+
(defun trie--wildcard-construct-rankfun (trie pattern rankfun reverse)
;; construct appropriate rank function for wildcard search, and return a
;; list containing the rankfun and a flags indicating whether to expect
@@ -2318,6 +2331,8 @@ non-terminal * wildcards are not supported"))
+;;; ------------------------------------------------------------------
+;;; wildcard stack
;; FIXME: using a defstruct instead of these macros causes *very* weird
;; bugs...why?!?!?!!!
@@ -2338,7 +2353,7 @@ non-terminal * wildcards are not supported"))
;; (:type vector)
;; (:constructor nil)
;; (:constructor trie--wildcard-stack-el-create
-;; (seq pattern node idx group-stack groups))
+;; (seq pattern node idx group-stack groups))
;; (:copier nil))
;; seq pattern node idx group-stack groups)
@@ -2634,6 +2649,12 @@ non-terminal * wildcards are not supported"))
+
+;; ================================================================
+;; Regexp search
+
+
+
(provide 'trie)
;;; trie.el ends here
- [elpa] externals/trie 53146c1 080/111: Implement fuzzy match and completion on dict-trees., (continued)
- [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, 2020/12/14
- [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 <=
- [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
- [elpa] externals/trie 46369a7 026/111: Added trie-wildcard-match function, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 7823234 095/111: Fix bug in trie-fuzzy-complete that meant it didn't return minimum prefix distance in some cases., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5fa968c 093/111: Fix byte-compiler warning., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 87d5786 102/111: Allow trie-fuzzy-match/complete to take lists of multiple prefixes/strings., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 71f8273 098/111: Significantly improve efficiency of trie-fuzzy-complete., Stefan Monnier, 2020/12/14
- [elpa] externals/trie c2b5e26 105/111: Myriad bug fixes and code refactoring in new fuzzy and ngram completion., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 63da3b1 111/111: * trie.el: Fix header which likely suffered a `M-q` accident, Stefan Monnier, 2020/12/14
- [elpa] externals/trie ff5e05f 040/111: Bumped copyright year, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 2281926 020/111: Minor code reformatting and rearrangement, Stefan Monnier, 2020/12/14