[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 3005cf8ee9 077/204: Merge pull request #12 fr
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 3005cf8ee9 077/204: Merge pull request #12 from noctuid/feature/strict-initialism |
Date: |
Tue, 11 Jan 2022 12:58:19 -0500 (EST) |
branch: externals/orderless
commit 3005cf8ee97de4e3cc52f957ea59c65bd0b1470e
Merge: dc3f8da022 862eed345c
Author: Omar AntolĂn Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #12 from noctuid/feature/strict-initialism
Add orderless-strict-initialism style
---
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 16991563ea..7fb2e0ee3e 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 c9ae65ea16 023/204: Highlight component matches in one of four faces, (continued)
- [elpa] externals/orderless c9ae65ea16 023/204: Highlight component matches in one of four faces, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 044fac0859 029/204: Revert "Better match face defaults (kindly contributed by Protesilaos)", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2813ffb2b1 039/204: Optimization: check if first component is string literal, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 25266dfc60 033/204: Update README.org, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 39202177e1 040/204: Undo previous optimization as it is invalid in general :(, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ecddc3da2e 045/204: Un-nest definition of orderless--highlight-matches, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 582b3a9fa8 031/204: Make all `defface' syntax more efficient+readable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c51037b8ef 024/204: Add custom variable for component separator regexp, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9856eeed32 047/204: Mention prefixes style in overview, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless cacd856f9a 041/204: Leverage completion-regexp-list: simplify code, increase speed!, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3005cf8ee9 077/204: Merge pull request #12 from noctuid/feature/strict-initialism,
ELPA Syncer <=
- [elpa] externals/orderless f8efbdae4d 087/204: Document style dispatches in the README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless e16fc5ddb1 099/204: Ido has progressive completion too!, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless dc1a31b5fc 098/204: Merge remote-tracking branch 'github/master', ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 306fb267f5 100/204: Mark orderless-temporarily-change-separator obsolete (#15), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 09f4c74280 105/204: Update dispatchers documentation, add transient vars, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless bc9e48216e 120/204: Add option for "smart case" matching, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1f1e0380e2 122/204: Test for match before highlighting it, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 6b94b9abf8 124/204: Merge pull request #21 from wyuenho/patch-1, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 0826fd4eb4 130/204: Merge pull request #27 from vifon/master, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless fc420e3d07 134/204: Minor readme tweak, ELPA Syncer, 2022/01/11