[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 862eed345c 075/204: Add more orderless initia
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 862eed345c 075/204: Add more orderless initialism styles |
Date: |
Tue, 11 Jan 2022 12:58:19 -0500 (EST) |
branch: externals/orderless
commit 862eed345c0f521a0b009180dd1ddf0e51b72790
Author: Fox Kiester <noct@posteo.net>
Commit: Fox Kiester <noct@posteo.net>
Add more orderless initialism styles
The orderless-strict-initialism style does not allow unmatched words to be
in
between initials. The orderless-strict-leading-initialism style additionally
requires that the first initial match the candidate's beginning. The
orderless-strict-full-initialiasm style additionally requires the last
initial
be at the last word.
---
README.org | 16 ++++++++++++++++
orderless.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index 5f67c595ab..67f5257864 100644
--- a/README.org
+++ b/README.org
@@ -101,6 +101,22 @@ define new matching styles. The predefined ones are:
This maps =abc= to =\<a.*\<b.*\c=.
+- orderless-strict-initialism :: like initialism but only allow
+ non-letters in between the matched words.
+
+ For example =fb= would match =foo-bar= but not =foo-qux-bar=.
+
+- orderless-strict-leading-initialism :: like strict-initialism but
+ require the first initial to match the candidate's first word.
+
+ For example =bb= would match =bar-baz= but not =foo-bar-baz=.
+
+- orderless-strict-full-initialism :: like strict-initialism but
+ require the first initial to match the candidate's first word and the
+ last initial to be at the final word.
+
+ For example =fbb= would match =foo-bar-baz= but not =foo-bar-baz-qux=.
+
- orderless-flex :: the characters of the component should appear in
that order in the candidate, but not necessarily consecutively.
diff --git a/orderless.el b/orderless.el
index 06780f4c24..ce904277e6 100644
--- a/orderless.el
+++ b/orderless.el
@@ -121,6 +121,11 @@ highlighted, otherwise just the captured groups are."
(const :tag "Regexp" orderless-regexp)
(const :tag "Literal" orderless-literal)
(const :tag "Initialism" orderless-initialism)
+ (const :tag "Strict initialism" orderless-strict-initialism)
+ (const :tag "Strict leading initialism"
+ orderless-strict-leading-initialism)
+ (const :tag "Strict full initialism"
+ orderless-strict-full-initialism)
(const :tag "Flex" orderless-flex)
(const :tag "Prefixes" orderless-prefixes)
(function :tag "Custom matching style"))
@@ -134,12 +139,21 @@ 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 ""))
+ "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."
+ (rx-to-string
+ `(seq
+ ,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."
- (rx-to-string
- `(seq ,@(cl-loop for (sexp . more) on rxs
- collect `(group ,sexp)
- when more collect `(zero-or-more nonl)))))
+ (orderless--separated-by '(zero-or-more nonl) rxs))
(defun orderless-flex (component)
"Match a component in flex style.
@@ -155,6 +169,39 @@ candidate, in that order, at the beginning of words."
(orderless--anything-between
(cl-loop for char across component collect `(seq word-start ,char))))
+(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))))
+
+(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)))))
+
+(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)))
+
(defun orderless-prefixes (component)
"Match a component as multiple word prefixes.
The COMPONENT is split at word endings, and each piece must match
- [elpa] externals/orderless 81248a8dbf 109/204: Merge branch 'dispatcher', (continued)
- [elpa] externals/orderless 81248a8dbf 109/204: Merge branch 'dispatcher', ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 0efa87672d 011/204: Fix bug on no matches, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless acc2645cf3 030/204: Even better match faces (kindly contributed by Protesilaos), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 6ada0ad21c 035/204: Add docstrings to functions, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a371c26c69 003/204: Stronger wording for warning, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d576dc9fac 028/204: Add reminder that match faces only are used if orderless "wins", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 6aabc83f02 022/204: Remove warning and stuff about SPC, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1ad6bd254b 021/204: Only copy and highlight once the candidate is known to match, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f2af44bf2e 057/204: Mention Icicles's progressive matching, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1631eb1733 073/204: Fix autoload for ivy, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 862eed345c 075/204: Add more orderless initialism styles,
ELPA Syncer <=
- [elpa] externals/orderless e3644defcd 088/204: Add orderless-pattern-compiler variable for maximum flexibility, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 436ef98b16 089/204: Add optional argument for dispatches: total number of components, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ed37c22902 097/204: Prefer descriptive argument over "mystery t's", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9cebf2fc8c 106/204: Escape parenthesis in first column of docstrings, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 93f4bccea1 112/204: Go back to split-string until empty components issue is resolved, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2d1f68b914 114/204: Fix tiny bug in customization type, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5c2f44d901 115/204: Allow component separator to be a function, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 43896f3e10 140/204: Accidentally omitted the overview! Bring it back, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless b059c15911 052/204: Make orderless-prefixes more like partial-completion, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless dc3f8da022 076/204: Avoid other cl-pushnes in an autoload, ELPA Syncer, 2022/01/11