Defining custom orderless styles
Orderless allows the definition of custom completion styles using the orderless-define-completion-style macro. Any Orderless configuration variable can be adjusted locally for the new style, e.g., orderless-matching-styles.
By default Orderless only enables the regexp and literal matching styles. In the following example an orderless+initialism style is defined, which additionally enables initialism matching. This completion style can then used when matching candidates of the symbol or command completion category.
(orderless-define-completion-style orderless+initialism
(orderless-matching-styles '(orderless-initialism
orderless-literal
orderless-regexp)))
(setq completion-category-overrides
'((command (styles orderless+initialism))
(symbol (styles orderless+initialism))
(variable (styles orderless+initialism))))Note that in order for the ‘orderless+initialism’ style to kick-in with the above configuration, you’d need to use commands whose metadata indicates that the completion candidates are commands or symbols. In Emacs 28, ‘execute-extended-command’ has metadata indicating you are selecting a command, but earlier versions of Emacs lack this metadata. Activating ‘marginalia-mode’ from the Marginalia package provides this metadata automatically for many built-in commands and is recommended if you use the above example configuration, or other similarly fine-grained control of completion styles according to completion category.