[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless e316991cfe 127/204: Add negative literals (fi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless e316991cfe 127/204: Add negative literals (fix #26) |
Date: |
Tue, 11 Jan 2022 12:58:23 -0500 (EST) |
branch: externals/orderless
commit e316991cfe1274efe5881fee0230532c67f9b035
Author: Omar AntolÃn Camarena <omar.antolin@gmail.com>
Commit: Omar AntolÃn Camarena <omar.antolin@gmail.com>
Add negative literals (fix #26)
---
README.org | 24 ++++++++++++++++++++----
orderless.el | 12 ++++++++++++
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index bedf7ed6d4..e0f5ab7b17 100644
--- a/README.org
+++ b/README.org
@@ -102,6 +102,14 @@ define new matching styles. The predefined ones are:
This is just =regexp-quote=.
+- *orderless-without-literal* :: the component is a treated as a literal
+ string that must *not* occur in the candidate.
+
+ Note that nothing is highlighted for this matching style. You
+ probably don't want to use this style directly in
+ =orderless-matching-styles= but with a style dispatcher instead. There
+ is an example in the section on style dispatchers.
+
- orderless-prefixes :: the component is split at word endings and
each piece must match at a word boundary in the candidate, occurring
in that order.
@@ -143,7 +151,7 @@ define new matching styles. The predefined ones are:
This is similar to the built-in =partial-completion= completion-style.
For example, =re-re= matches =query-replace-regexp=, =recode-region= and
=magit-remote-list-refs=; =f-d.t= matches =final-draft.txt=.
-
+
The variable =orderless-matching-styles= can be set to a list of the
desired matching styles to use. By default it enables the regexp and
initialism styles.
@@ -171,8 +179,10 @@ initialism styles.
- except for the first component, which should always match as an
initialism ---this is pretty useful for, say,
=execute-extended-command= (=M-x=) or =describe-function= (=C-h f=),
- - and any later component ending in =~= should match (the characters
- other than the final =~=) in the flex style.
+ - later components ending in =~= should match (the characters
+ other than the final =~=) in the flex style, and
+ - later components starting with =!= should indicate the rest of the
+ component is a literal string not contained in the candidate.
You can achieve this with the following configuration:
@@ -184,8 +194,14 @@ initialism styles.
(defun first-initialism (pattern index _total)
(if (= index 0) 'orderless-initialism))
+ (defun without-if-bang (pattern _index _total)
+ (when (string-prefix-p "!" pattern)
+ `(orderless-without-literal . ,(substring pattern 1))))
+
(setq orderless-matching-styles '(orderless-regexp)
- orderless-style-dispatchers '(first-initialism flex-if-twiddle))
+ orderless-style-dispatchers '(first-initialism
+ flex-if-twiddle
+ without-if-bang))
#+end_src
** Component separator regexp
diff --git a/orderless.el b/orderless.el
index 3ba62ed1c2..ecd89c7bbf 100644
--- a/orderless.el
+++ b/orderless.el
@@ -307,6 +307,18 @@ at a word boundary in the candidate. This is similar to
the
(cl-loop for prefix in (split-string component "\\>")
collect `(seq word-boundary ,prefix))))
+(defun orderless-without-literal (component)
+ "Match strings that do *not* contain COMPONENT as a literal match."
+ (rx-to-string
+ `(seq
+ (group string-start) ; highlight nothing!
+ (zero-or-more
+ (or ,@(cl-loop for i from 1 below (length component)
+ collect `(seq ,(substring component 1 i)
+ (or (not (any ,(aref component i)))
+ string-end)))))
+ string-end)))
+
;;; Highlighting matches
(defun orderless--highlight (regexps string)
- [elpa] externals/orderless b69b52289f 084/204: Add Company to TOC, (continued)
- [elpa] externals/orderless b69b52289f 084/204: Add Company to TOC, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless bf91e1d8a2 095/204: Name sections of code, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 6c05cf8e00 096/204: Add global dispatcher to compute default matching styles, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 12ea1f2947 110/204: Make transients buffer local, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d42e41c8cb 111/204: Allow separator inside double quotes, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 21e9f87579 116/204: Typo: escapeable --> escapable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2f2c757a33 117/204: Correct error about orderless-transient-style-dispatchers in README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1f985d0e07 119/204: Remove obsolete temporary separator change command and variables, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c6432b086f 121/204: Bump version number for new smart case feature, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 351d2fbb7d 123/204: Fix typo, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless e316991cfe 127/204: Add negative literals (fix #26),
ELPA Syncer <=
- [elpa] externals/orderless 6fec4f0a52 129/204: Remove a duplicated documentation entry, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3bcfb3f806 131/204: Generate texinfo manual from readme, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 487e51ea66 132/204: Merge branch 'master' of https://github.com/oantolin/orderless, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a22d894d39 142/204: Revert "Update documentation" for #31, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ea752ba6e3 143/204: Revert "Add matching style and dispatcher per category overrides (fix #31)", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 8e28b74aab 147/204: Update information about Selectrum, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ee5e8bda25 149/204: Remove unnecessary :group in defcustom, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 237ee002ac 158/204: Make orderless-regexp match invalid regexps literally, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9b70ac8df2 161/204: orderless-filter: Remove unnecessary condition-case, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f6394f19f3 163/204: orderless-default-pattern-compiler: Ignore nil components, ELPA Syncer, 2022/01/11