\input texinfo @c -*- texinfo -*- @c %**start of header @setfilename orderless.info @settitle Orderless @documentencoding UTF-8 @documentlanguage en @c %**end of header @dircategory Emacs misc features @direntry * Orderless: (orderless). Completion style for matching regexps in any order. @end direntry @finalout @titlepage @title Orderless @author Omar AntolĂ­n Camarena @end titlepage @contents @ifnottex @node Top @top Orderless @end ifnottex @menu * Overview:: * Customization:: * Integration with other completion UIs:: * Related packages:: @detailmenu --- The Detailed Node Listing --- Customization * Component matching styles:: * Component separator regexp:: * Defining custom orderless styles:: * Faces for component matches:: * Pattern compiler:: * Interactively changing the configuration:: Component matching styles * Style modifiers:: * Style dispatchers:: Integration with other completion UIs * Ivy:: * Helm:: * Company:: Related packages * Ivy and Helm:: * Prescient:: * Restricting to current matches in Icicles@comma{} Ido and Ivy:: @end detailmenu @end menu @node Overview @chapter Overview This package provides an @samp{orderless} @emph{completion style} that divides the pattern into space-separated components@comma{} and matches candidates that match all of the components in any order. Each component can match in any one of several ways: literally@comma{} as a regexp@comma{} as an initialism@comma{} in the flex style@comma{} or as multiple word prefixes. By default@comma{} regexp and literal matches are enabled. A completion style is a back-end for completion and is used from a front-end that provides a completion UI@. Any completion style can be used with the default Emacs completion UI (sometimes called minibuffer tab completion)@comma{} with the built-in Icomplete package (which is similar to the more well-known Ido Mode)@comma{} the icomplete-vertical variant from Emacs 28@comma{} or with minibuffer completion frameworks such as @uref{https://gitlab.com/protesilaos/mct, Mct} or @uref{https://github.com/minad/vertico, Vertico}. All the completion UIs just mentioned are for minibuffer completion@comma{} used when Emacs commands prompt the user in the minibuffer for some input@comma{} but there is also completion at point in normal buffers@comma{} typically used for identifiers in programming languages. Completion styles can also be used for that purpose by completion at point UIs such as @uref{https://github.com/minad/corfu, Corfu}@comma{} @uref{https://company-mode.github.io/, Company} or the function @samp{consult-completion-in-region} from @uref{https://github.com/minad/consult, Consult}. To use a completion style with any of the above mentioned completion UIs simply add it as an entry in the variables @samp{completion-styles} and @samp{completion-category-overrides} and @samp{completion-category-defaults} (see their documentation). The @samp{completion-category-defaults} variable serves as a default value for @samp{completion-category-overrides}. If you want to use @samp{orderless} exclusively@comma{} set both variables to @samp{nil}@comma{} but be aware that @samp{completion-category-defaults} is modified by packages at load time. With a bit of effort@comma{} it might still be possible to use @samp{orderless} with other completion UIs@comma{} even if those UIs don't support the standard Emacs completion styles. Currently there is support for @uref{https://github.com/abo-abo/swiper, Ivy}@comma{} as documented below. Also@comma{} while Company does support completion styles directly@comma{} pressing @samp{SPC} takes you out of completion@comma{} so comfortably using @samp{orderless} with it takes a bit of configuration (see below). If you use ELPA or MELPA@comma{} the easiest way to install @samp{orderless} is via @samp{package-install}. If you use @samp{use-package}@comma{} you can use: @lisp (use-package orderless :ensure t :custom (completion-styles '(orderless basic)) (completion-category-overrides '((file (styles partial-completion)))) (completion-pcm-leading-wildcard t)) ;; Emacs 31: partial-completion behaves like substring @end lisp Alternatively@comma{} put @samp{orderless.el} somewhere on your @samp{load-path}@comma{} and use the following configuration: @lisp (require 'orderless) (setq completion-styles '(orderless basic) completion-category-overrides '((file (styles partial-completion))) completion-pcm-leading-wildcard t) ;; Emacs 31: partial-completion behaves like substring @end lisp The @samp{basic} completion style is specified as fallback in addition to @samp{orderless} in order to ensure that completion commands which rely on dynamic completion tables@comma{} e.g.@comma{} @code{completion-table-dynamic} or @code{completion-table-in-turn}@comma{} work correctly. Furthermore the @samp{basic} completion style needs to be tried @emph{first} (not as a fallback) for TRAMP hostname completion to work. In order to achieve that@comma{} we add an entry for the @samp{file} completion category in the @samp{completion-category-overrides} variable. In addition@comma{} the @samp{partial-completion} style allows you to use wildcards for file completion and partial paths@comma{} e.g.@comma{} @code{/u/s/l} for @code{/usr/share/local}. Bug reports are highly welcome and appreciated! @node Customization @chapter Customization @menu * Component matching styles:: * Component separator regexp:: * Defining custom orderless styles:: * Faces for component matches:: * Pattern compiler:: * Interactively changing the configuration:: @end menu @node Component matching styles @section Component matching styles Each component of a pattern can match in any of several matching styles. A matching style is a function from strings to regexps or predicates@comma{} so it is easy to define new matching styles. The value returned by a matching style can be either a regexp as a string@comma{} an s-expression in @samp{rx} syntax or a predicate function. The predefined matching styles are: @table @asis @item orderless-regexp the component is treated as a regexp that must match somewhere in the candidate. If the component is not a valid regexp@comma{} it is ignored. @item orderless-literal the component is treated as a literal string that must occur in the candidate. @item orderless-literal-prefix the component is treated as a literal string that must occur as a prefix of a candidate. @item orderless-prefixes the component is split at word endings and each piece must match at a word boundary in the candidate@comma{} occurring in that order. This is similar to the built-in @samp{partial-completion} completion-style. For example@comma{} @samp{re-re} matches @samp{query-replace-regexp}@comma{} @samp{recode-region} and @samp{magit-remote-list-refs}; @samp{f-d.t} matches @samp{final-draft.txt}. @item orderless-initialism each character of the component should appear as the beginning of a word in the candidate@comma{} in order. This maps @samp{abc} to @samp{\