\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, Ido and Ivy: Restricting to current matches in Icicles 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, and matches candidates that match all of the components in any order. Each component can match in any one of several ways: literally, as a regexp, as an initialism, in the flex style, or as multiple word prefixes. By default, 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), with the built-in Icomplete package (which is similar to the more well-known Ido Mode), the icomplete-vertical variant from Emacs 28 (see the external @uref{https://github.com/oantolin/icomplete-vertical, icomplete-vertical} package to get that functionality on earlier versions of Emacs), or with some third party 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, used when Emacs commands prompt the user in the minibuffer for some input, but there is also completion at point in normal buffers, 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}, @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} (see their documentation). You may also want to modify the @samp{completion-category-defaults} variable, which serves as a default value for @samp{completion-category-overrides}: if you want to use @samp{orderless} exclusively, set both variables to @samp{nil}. With a bit of effort, it might still be possible to use @samp{orderless} with other completion UIs, 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} (see below). Also, while Company does support completion styles directly, pressing @samp{SPC} takes you out of completion, so comfortably using @samp{orderless} with it takes a bit of configuration (see below). If you use ELPA or MELPA, the easiest way to install @samp{orderless} is via @samp{package-install}. If you use @samp{use-package}, you can use: @lisp (use-package orderless :ensure t :custom (completion-styles '(orderless basic)) (completion-category-overrides '((file (styles basic partial-completion))))) @end lisp Alternatively, put @samp{orderless.el} somewhere on your @samp{load-path}, and use the following configuration: @lisp (require 'orderless) (setq completion-styles '(orderless basic) completion-category-overrides '((file (styles basic partial-completion)))) @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, e.g., @code{completion-table-dynamic} or @code{completion-table-in-turn}, 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, we add an entry for the @samp{file} completion category in the @samp{completion-category-overrides} variable. In addition, the @samp{partial-completion} style allows you to use wildcards for file completion and partial paths, e.g., @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, so it is easy to define new matching styles. The value returned by a matching style can be either a regexp as a string, 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, it is ignored. @item orderless-literal the component is treated as a literal string that must occur in the candidate. @item orderless-prefixes the component is split at word endings and each piece must match at a word boundary in the candidate, occurring in that order. This is similar to the built-in @samp{partial-completion} completion-style. For example, @samp{re-re} matches @samp{query-replace-regexp}, @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, in order. This maps @samp{abc} to @samp{\