From 9e810f43f0152148f34ab5c84ab311da6bfc8762 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 17 Feb 2024 13:47:08 +0100 Subject: Simplify orderless--compile-component --- orderless.el | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/orderless.el b/orderless.el index 98e4080..395f1f2 100644 --- a/orderless.el +++ b/orderless.el @@ -383,21 +383,19 @@ DEFAULT as the list of styles." (defun orderless--compile-component (component idx total styles dispatchers) "Compile COMPONENT at IDX of TOTAL components with STYLES and DISPATCHERS." - (pcase-let ((`(,newsty . ,newcomp) (orderless--dispatch dispatchers styles component idx total))) - (when (functionp newsty) - (setq newsty (list newsty))) - (cl-loop - with pred = nil - for style in newsty - for res = (condition-case nil - (funcall style newcomp) - (wrong-number-of-arguments - (when-let ((res (orderless--compile-component newcomp idx total styles dispatchers))) - (funcall style (car res) (cdr res))))) - if (functionp res) do (cl-callf orderless--predicate-and pred res) - else if res collect (if (stringp res) `(regexp ,res) res) into regexps - finally return - (and (or pred regexps) (cons pred (and regexps (rx-to-string `(or ,@(delete-dups regexps))))))))) + (cl-loop + with pred = nil + with (newsty . newcomp) = (orderless--dispatch dispatchers styles component idx total) + for style in (if (functionp newsty) (list newsty) newsty) + for res = (condition-case nil + (funcall style newcomp) + (wrong-number-of-arguments + (when-let ((res (orderless--compile-component newcomp idx total styles dispatchers))) + (funcall style (car res) (cdr res))))) + if (functionp res) do (cl-callf orderless--predicate-and pred res) + else if res collect (if (stringp res) `(regexp ,res) res) into regexps + finally return + (and (or pred regexps) (cons pred (and regexps (rx-to-string `(or ,@(delete-dups regexps)))))))) (defun orderless-compile (pattern &optional styles dispatchers) "Build regexps to match the components of PATTERN. -- cgit v1.0