[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 3c4b4815f0 079/204: Refactor strict initialis
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 3c4b4815f0 079/204: Refactor strict initialism functions |
Date: |
Tue, 11 Jan 2022 12:58:19 -0500 (EST) |
branch: externals/orderless
commit 3c4b4815f05216cfcef67899e5fc416585085abd
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Refactor strict initialism functions
---
orderless.el | 80 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 41 insertions(+), 39 deletions(-)
diff --git a/orderless.el b/orderless.el
index 0a0c426d24..31b4890ad0 100644
--- a/orderless.el
+++ b/orderless.el
@@ -139,75 +139,77 @@ This is simply the identity function.")
"Match a component as a literal string.
This is simply `regexp-quote'.")
-(cl-defun orderless--separated-by (sep rxs &optional (before "") (after ""))
+(defun orderless--separated-by (sep rxs &optional before after)
"Return a regexp to match the rx-regexps RXS with SEP in between.
-If BEFORE is specified, add it to the beginning of the rx sequence. If AFTER is
-specified, add it to the end of the rx sequence."
+If BEFORE is specified, add it to the beginning of the rx
+sequence. If AFTER is specified, add it to the end of the rx
+sequence."
(rx-to-string
`(seq
- ,before
+ ,(or before "")
,@(cl-loop for (sexp . more) on rxs
collect `(group ,sexp)
- when more collect `,sep)
- ,after)))
-
-(defun orderless--anything-between (rxs)
- "Return a regexp to match the rx-regexps RXS with .* in between."
- (orderless--separated-by '(zero-or-more nonl) rxs))
+ when more collect sep)
+ ,(or after ""))))
(defun orderless-flex (component)
"Match a component in flex style.
This means the characters in COMPONENT must occur in the
candidate in that order, but not necessarily consecutively."
- (orderless--anything-between
+ (orderless--separated-by '(zero-or-more nonl)
(cl-loop for char across component collect char)))
(defun orderless-initialism (component)
"Match a component as an initialism.
This means the characters in COMPONENT must occur in the
candidate, in that order, at the beginning of words."
- (orderless--anything-between
+ (orderless--separated-by '(zero-or-more nonl)
(cl-loop for char across component collect `(seq word-start ,char))))
+(defun orderless--strict-*-initialism (component &optional start end)
+ "Match a COMPONENT as a strict initialism, optionally anchored.
+The characters in COMPONENT must occur in the candidate in that
+order at the beginning of subsequent words comprised of letters.
+Only non-letters can be in between the words that start with the
+initials.
+
+If START is non-nil, require that the first initial appear at the
+first word of the candidate. Similarly, if END is non-nil
+require the last initial appear in the last word."
+ (orderless--separated-by
+ '(seq (zero-or-more word) word-end (zero-or-more (not alpha)))
+ (cl-loop for char across component collect `(seq word-start ,char))
+ (when start '(seq buffer-start (zero-or-more (not alpha))))
+ (when end
+ '(seq (zero-or-more word) word-end (zero-or-more (not alpha)) eol))))
+
(defun orderless-strict-initialism (component)
"Match a COMPONENT as a strict initialism.
-This means the characters in COMPONENT must occur in the candidate in that
order
-at the beginning of subsequent words comprised of letters. Only non-letters can
-be in between the words that start with the initials."
- (orderless--separated-by '(seq (zero-or-more word)
- word-end
- (zero-or-more (not alpha)))
- (cl-loop for char across component collect `(seq word-start ,char))))
+This means the characters in COMPONENT must occur in the
+candidate in that order at the beginning of subsequent words
+comprised of letters. Only non-letters can be in between the
+words that start with the initials."
+ (orderless--strict-*-initialism component))
(defun orderless-strict-leading-initialism (component)
- "Match a COMPONENT as a strict initialism (see
`orderless-strict-initialism').
-Additionally require that the first initial appear at the first word of the
-candidate."
- (orderless--separated-by
- '(seq (zero-or-more word)
- word-end
- (zero-or-more (not alpha)))
- (cl-loop for char across component collect `(seq word-start ,char))
- '(seq buffer-start (zero-or-more (not alpha)))))
+ "Match a COMPONENT as a strict initialism, anchored at start.
+See `orderless-strict-initialism'. Additionally require that the
+first initial appear in the first word of the candidate."
+ (orderless--strict-*-initialism component t))
(defun orderless-strict-full-initialism (component)
- "Match a COMPONENT as a strict initialism (see
`orderless-strict-initialism').
-Additionally require that the first initial appear at the first word of the
-candidate and the last initial appear the the last word in the candidate."
- (orderless--separated-by
- '(seq (zero-or-more word)
- word-end
- (zero-or-more (not alpha)))
- (cl-loop for char across component collect `(seq word-start ,char))
- '(seq buffer-start (zero-or-more (not alpha)))
- '(seq (zero-or-more word) word-end (zero-or-more (not alpha)) eol)))
+ "Match a COMPONENT as a strict initialism, anchored at both ends.
+See `orderless-strict-initialism'. Additionally require that the
+first and last initials appear in the first and last words of the
+candidate, respectively."
+ (orderless--strict-*-initialism component t t))
(defun orderless-prefixes (component)
"Match a component as multiple word prefixes.
The COMPONENT is split at word endings, and each piece must match
at a word boundary in the candidate. This is similar to the
`partial-completion' completion style."
- (orderless--anything-between
+ (orderless--separated-by '(zero-or-more nonl)
(cl-loop for prefix in (split-string component "\\>" t)
collect `(seq word-boundary ,prefix))))
- [elpa] externals/orderless 0f674253a8 199/204: Reword sentence for clarity, (continued)
- [elpa] externals/orderless 0f674253a8 199/204: Reword sentence for clarity, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3678f84606 204/204: Add "This file is part of GNU Emacs", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5af63c1217 058/204: Merge remote-tracking branch 'github/master', ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 60e70aa53b 062/204: Add autoloads, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless b0913a9c56 044/204: Placate checkdoc again, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f2ccc538ef 061/204: Refactor to provide reusable filtering and highlightinf functions, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3b15b2f59d 059/204: Demote Icicles heading, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 80b53ec38e 019/204: Rename lim to limit, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 48ec46518a 037/204: Fix typo in README (thanks Juanjo!), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a21ef6d985 070/204: If matching-styles is nil, assume regexp matching, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3c4b4815f0 079/204: Refactor strict initialism functions,
ELPA Syncer <=
- [elpa] externals/orderless f30a3e912c 082/204: Initial implementation of style dispatchers, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 7e83e37870 086/204: Fine-tune dispatcher semantics, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5897841be4 094/204: Rename default pattern compiler, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 830976770b 102/204: Put integration before related packages in README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 68e592055c 113/204: The transient variables should not be customizable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5b292ac136 118/204: Document custom splitter option, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1d62307cce 125/204: Add badge., ELPA Syncer, 2022/01/11
- [elpa] externals/orderless cbc0109eac 136/204: Merge pull request #28 from b3n/patch-1, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and dispatcher per category overrides (fix #31), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5dcf4a6f2b 135/204: Corrected broken link, ELPA Syncer, 2022/01/11