summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-02-23 16:03:50 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2024-02-23 16:03:50 +0100
commit64c32fd63ef740ddac48c83d3d1af524426ea39e (patch)
treec21799a20118c83a3231e6cf2245fa0ae8179f97
parent91df48c8e1331e434ce6ce3bab709de2035e3ec4 (diff)
Add orderless--match-p helper
-rw-r--r--orderless.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/orderless.el b/orderless.el
index 26c4783..e9d9f31 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