[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 64c32fd63e 1/2: Add orderless--match-p helper
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 64c32fd63e 1/2: Add orderless--match-p helper |
Date: |
Sun, 25 Feb 2024 12:58:55 -0500 (EST) |
branch: externals/orderless
commit 64c32fd63ef740ddac48c83d3d1af524426ea39e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add orderless--match-p helper
---
orderless.el | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/orderless.el b/orderless.el
index 26c4783ee8..e9d9f31ee9 100644
--- a/orderless.el
+++ b/orderless.el
@@ -272,11 +272,16 @@ which can invert any predicate or regexp."
string-end)))))
string-end))
+(defsubst orderless--match-p (pred regexp str)
+ "Return t if STR matches PRED and REGEXP."
+ (and str
+ (or (not pred) (funcall pred str))
+ (or (not regexp) (string-match-p regexp str))))
+
(defun orderless-not (pred regexp)
- "Match strings that do *not* match PRED or REGEXP."
+ "Match strings that do *not* match PRED and REGEXP."
(lambda (str)
- (not (or (and pred (funcall pred str))
- (and regexp (string-match-p regexp str))))))
+ (not (orderless--match-p pred regexp str))))
(defun orderless-annotation (pred regexp)
"Match candidates where the annotation matches PRED and REGEXP."
@@ -296,9 +301,7 @@ which can invert any predicate or regexp."
:affixation-function))))
(lambda (cand) (caddr (funcall aff (list cand))))))))
(lambda (str)
- (when-let ((ann (funcall fun str)))
- (and (or (not pred) (funcall pred ann))
- (or (not regexp) (string-match-p regexp ann)))))))
+ (orderless--match-p pred regexp (funcall fun str)))))
;;; Highlighting matches