Function: orderless-compile

orderless-compile is a natively compiled function defined in orderless.el.

Signature

(orderless-compile PATTERN &optional STYLES DISPATCHERS)

Documentation

Build regexps to match the components of PATTERN.

Split PATTERN on orderless-component-separator and compute matching styles for each component. For each component the style DISPATCHERS are run to determine the matching styles to be used; they are called with arguments the component, the 0-based index of the component and the total number of components. If the DISPATCHERS decline to handle the component, then the list of matching STYLES is used. See orderless--dispatch for details on dispatchers.

The STYLES default to orderless-matching-styles, and the DISPATCHERS default to orderless-dipatchers. Since nil gets you the default, if you want no dispatchers to be run, use
'(ignore) as the value of DISPATCHERS.

The return value is a pair of a predicate function and a list of regexps. The predicate function can also be nil. It takes a string as argument.

Source Code

;; Defined in /nix/store/x8591dlnsvch2j4brlxddqs0axxy3w60-emacs-packages-deps/share/emacs/site-lisp/elpa/orderless-20260927.2344/orderless.el
(defun orderless-compile (pattern &optional styles dispatchers)
  "Build regexps to match the components of PATTERN.
Split PATTERN on `orderless-component-separator' and compute
matching styles for each component.  For each component the style
DISPATCHERS are run to determine the matching styles to be used;
they are called with arguments the component, the 0-based index
of the component and the total number of components.  If the
DISPATCHERS decline to handle the component, then the list of
matching STYLES is used.  See `orderless--dispatch' for details
on dispatchers.

The STYLES default to `orderless-matching-styles', and the
DISPATCHERS default to `orderless-dipatchers'.  Since nil gets
you the default, if you want no dispatchers to be run, use
\\='(ignore) as the value of DISPATCHERS.

The return value is a pair of a predicate function and a list of
regexps.  The predicate function can also be nil.  It takes a
string as argument."
  (unless styles (setq styles orderless-matching-styles))
  (unless dispatchers (setq dispatchers orderless-style-dispatchers))
  (cl-loop
   with predicate = nil
   with sep = orderless-component-separator
   with temp = (cond ((functionp sep) (funcall sep pattern))
                     ((consp sep) (apply (car sep) pattern (cdr sep)))
                     (t (split-string pattern sep)))
   with components = (if (equal (car (last temp)) "") (nbutlast temp) temp)
   with total = (length components)
   for comp in components and index from 0
   for (pred . regexp) = (orderless--compile-component
                          comp index total styles dispatchers)
   when regexp collect regexp into regexps
   when pred do (cl-callf orderless--predicate-and predicate pred)
   finally return (cons predicate regexps)))