[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie 6d76748 028/111: Allow "]" to be included in a neg
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie 6d76748 028/111: Allow "]" to be included in a negated character alternatives, by placing immediately after the "[^". |
Date: |
Mon, 14 Dec 2020 11:35:13 -0500 (EST) |
branch: externals/trie
commit 6d76748b607908971cd44456888a0a6a132fb413
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Allow "]" to be included in a negated character alternatives, by placing
immediately after the "[^".
---
trie.el | 76 +++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 48 insertions(+), 28 deletions(-)
diff --git a/trie.el b/trie.el
index 9189681..44bc4cd 100644
--- a/trie.el
+++ b/trie.el
@@ -1238,11 +1238,12 @@ from the stack. Returns nil if the stack is empty."
(rankfun maxnum reverse filter accfun duplicates &rest body)
;; Accumulate results of running BODY code, and return them in appropriate
;; order. BODY should call ACCFUN to accumulate a result, passing it two
- ;; arguments: a trie data node, and the corresponding sequence. A non-null
- ;; DUPLICATES flag signals that the accumulated results might contain
- ;; duplicates, which should be deleted. Note that DUPLICATES is ignored if
- ;; RANKFUN is null. The other arguments should be passed straight through
- ;; from the query function.
+ ;; arguments: a trie data node, and the corresponding sequence. BODY can
+ ;; throw 'trie-complete--done to terminate the accumulation and return the
+ ;; results. A non-null DUPLICATES flag signals that the accumulated results
+ ;; might contain duplicates, which should be deleted. Note that DUPLICATES
+ ;; is ignored if RANKFUN is null. The other arguments should be passed
+ ;; straight through from the query function.
;; rename RANKFUN to help avoid dynamic-scoping bugs
`(let* ((--trie-accumulate--rankfun ,rankfun)
@@ -1536,24 +1537,31 @@ syntax:
[^...] negated character alternative
Matches any character *other* then those listed.
- []..] character alternative including `]'
+ []...] character alternative including `]'
Matches any of the listed characters, including `]'.
+ [^]...] negated character alternative including `]'
+ Matches any character other than `]' and any others listed.
+
\\ quote literal
Causes the next element of the pattern sequence to be treated
literally; special characters lose their special meaning, for
anything else it has no effect.
To include a `]' in a character alternative, place it immediately
-after the opening `['. To include a literal `\\', quote it with
-another `\\' (remember that `\\' also has to be quoted within
-elisp strings, so as a string this would be \"\\\\\\\\\"). The
-above syntax descriptions are written in terms of strings, but
-the special characters can be used in *any* sequence
-type. E.g. the character alternative \"[abc]\" would be \(?[ ?a
-?b ?c ?]\) as a list, or [?[ ?a ?b ?c ?]] as a vector. The
-\"characters\" in the alternative can of course be any data type
-that might be stored in the trie, not just actual characters.
+after the opening `[', or the opening `[^' in a negated character
+alternative. To include a `^' in a character alternative, negated
+or otherwise, place it anywhere other than immediately after the
+opening `['. To include a literal `\\' in the pattern, quote it
+with another `\\' (remember that `\\' also has to be quoted
+within elisp strings, so as a string this would be
+\"\\\\\\\\\"). The above syntax descriptions are written in terms
+of strings, but the special characters can be used in *any*
+sequence type. E.g. the character alternative \"[abc]\" would be
+\(?[ ?a ?b ?c ?]\) as a list, or [?[ ?a ?b ?c ?]] as a
+vector. The \"characters\" in the alternative can of course be
+any data type that might be stored in the trie, not just actual
+characters.
If PATTERN is a string, it must be possible to apply `string' to
individual elements of the sequences stored in the trie. The
@@ -1782,24 +1790,31 @@ syntax, with one major restriction on the `*' wildcard:
[^...] negated character alternative
Matches any character *other* then those listed.
- []..] character alternative including `]'
+ []...] character alternative including `]'
Matches any of the listed characters, including `]'.
+ [^]...] negated character alternative including `]'
+ Matches any character other than `]' and any others listed.
+
\\ quote literal
Causes the next element of the pattern sequence to be treated
literally; special characters lose their special meaning, for
anything else it has no effect.
To include a `]' in a character alternative, place it immediately
-after the opening `['. To include a literal `\\', quote it with
-another `\\' (remember that `\\' also has to be quoted within
-elisp strings, so as a string this would be \"\\\\\\\\\"). The
-above syntax descriptions are written in terms of strings, but
-the special characters can be used in *any* sequence
-type. E.g. the character alternative \"[abc]\" would be \(?[ ?a
-?b ?c ?]\) as a list, or [?[ ?a ?b ?c ?]] as a vector. The
-\"characters\" in the alternative can of course be any data type
-that might be stored in the trie, not just actual characters.
+after the opening `[', or the opening `[^' in a negated character
+alternative. To include a `^' in a character alternative, negated
+or otherwise, place it anywhere other than immediately after the
+opening `['. To include a literal `\\' in the pattern, quote it
+with another `\\' (remember that `\\' also has to be quoted
+within elisp strings, so as a string this would be
+\"\\\\\\\\\"). The above syntax descriptions are written in terms
+of strings, but the special characters can be used in *any*
+sequence type. E.g. the character alternative \"[abc]\" would be
+\(?[ ?a ?b ?c ?]\) as a list, or [?[ ?a ?b ?c ?]] as a
+vector. The \"characters\" in the alternative can of course be
+any data type that might be stored in the trie, not just actual
+characters.
If PATTERN is a string, it must be possible to apply `string' to
individual elements of the sequences stored in the trie. The
@@ -1813,7 +1828,6 @@ Wildcard searches on tries are very efficient compared to
similar
searches on other data structures. Due to the restrictions on the
`*' wildcard, there is no significant difference between the
efficiency of all legitimate patterns."
-
;; convert trie from print-form if necessary
(trie-transform-from-read-warn trie)
;; if stack functions aren't defined for trie type, throw error
@@ -2042,8 +2056,14 @@ efficiency of all legitimate patterns."
((eq el ?\[)
;; character alternatives are stored in lists
(setq el ())
- ;; gobble ] appearing straight after [
- (when (eq (car pattern) ?\]) (push (pop pattern) el))
+ (cond
+ ;; gobble ] appearing straight after [
+ ((eq (car pattern) ?\]) (push (pop pattern) el))
+ ;; gobble ] appearing straight after [^
+ ((and (eq (car pattern) ?^) (eq (nth 1 pattern) ?\]))
+ (push (pop pattern) el)
+ (push (pop pattern) el)))
+ ;; gobble everything up to closing ]
(while (not (eq (car pattern) ?\]))
(push (pop pattern) el)
(unless pattern
- [elpa] externals/trie 160f092 054/111: Revert "Replaced advice with cedet-edebug.el for pretty-printing", (continued)
- [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
- [elpa] externals/trie e1be744 030/111: Bug-fix in trie--do-wildcard-search, Stefan Monnier, 2020/12/14
- [elpa] externals/trie e00ae36 058/111: Trivial docstring and comment fixes., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 153d2d4 048/111: Require advice when compiling, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6d76748 028/111: Allow "]" to be included in a negated character alternatives, by placing immediately after the "[^".,
Stefan Monnier <=
- [elpa] externals/trie 00300c4 074/111: Revert trie--node-data defsetf, since it seems to work now., Stefan Monnier, 2020/12/14
- [elpa] externals/trie dd26bb3 023/111: more trivial docstring changes, Stefan Monnier, 2020/12/14
- [elpa] externals/trie bc12ecb 072/111: Exploit lexical closures to allow byte-compilation of wrapped functions., Stefan Monnier, 2020/12/14
- [elpa] externals/trie e88f10d 069/111: Remove ChangeLogs from library headers., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 4efa42d 067/111: Fix trie--node-data defsetf, so it compiles in latest Emacs trunk., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 9986ac7 068/111: Restore trie print/read transformer functions., Stefan Monnier, 2020/12/14
- [elpa] externals/trie ec5396c 071/111: Suppress bogus unused lexical variable byte-compiler warnings., Stefan Monnier, 2020/12/14
- [elpa] externals/trie acad8e8 050/111: Bug-fixes to edebug advice, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 15b4de9 018/111: Simplified trie--create by storing functions for predefined trie types in symbol property lists, Stefan Monnier, 2020/12/14
- [elpa] externals/trie fb1d096 034/111: Changed trie-wildcard-match to return grouping data if pattern matches and contains groups, Stefan Monnier, 2020/12/14