summaryrefslogtreecommitdiff
path: root/README.org
blob: ed6ab171b99fdb74245e567ad69d6ad999afa791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
* Overview

This package provides an =orderless= completion style that divides the
pattern into space-separated components, treats each one as a regexp,
and matches canidates that match all of the component regexps in any
order.

Completion styles are used as entries in the variables
=completion-styles= and =completion-category-overrides=, see their
documentation.

So to test this completion method you can put =orderless.el= somewhere
on your =load-path=, and use the following configuration:

#+begin_src emacs-lisp
(require 'orderless)
(setq completion-styles '(orderless))
#+end_src

Bug reports are highly welcome and appreciated!

* Customization

** Component separator regexp

The regexp components by default are space-separated, but this is
controlled by the variable =orderless-regexp-separator=, which should be
set to a regexp that matches the desired component separator. The
default value matches a sequence of spaces. It may be useful to add
hypens or slashes (or both), to match symbols or file paths,
respectively.

If you are implementing a command for which you know you want a
different separator for the components, bind
=orderless-regexp-separator= in a =let= form.

** Faces for component matches 

The portions of a candidate matching each component get highlighted in
one of four faces, =orderless-math-face-?= where =?= is a number from 0
to 3. If the pattern has more than four components, the faces get
reused cyclically.

* Related packages

The well-known and hugely powerful completion frameworks [[https://github.com/abo-abo/swiper][Ivy]] and [[https://github.com/emacs-helm/helm][Helm]]
also provide for matching space-separated component regexps in any
order. In Ivy, this is done with the =ivy--regex-ignore-order= matcher.
In Helm, it is the default, called "multi pattern matching".

This package is significantly smaller than either of those because it
solely provides a completion style, meant to be used with the built-in
Icomplete completion UI, while both of those provide their own
completion UI (and many other cool features!).

It is worth pointing out that Helm does provide its multi pattern
matching as a completion style which could be used with Icomplete! So,
Icomplete users could, instead of using this package, instead install
Helm and configure Icomplete to use it as follows:

#+begin_src emacs-lisp
  (require 'helm)
  (setq completion-styles '(helm))
  (icomplete-mode)
#+end_src

(Of course, if you install Helm, you probably might as well use the
Helm UI in =helm-mode= rather than using Icomplete.)

The combination of [[https://github.com/raxod502/selectrum][Selectrum]] and [[https://github.com/raxod502/prescient.el][prescient.el]] also provides matching
of space-separated components in any order, but the components are
matched as either literal strings or initialisms rather than as
regexps.