Skip to content

Commit

Permalink
README: Document aggressive auto completion settings
Browse files Browse the repository at this point in the history
See minad/cape#52 for the discussion.
  • Loading branch information
minad committed Jun 26, 2022
1 parent dcc2ccf commit d2efee4
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,46 @@ unexpectedly.
corfu-quit-no-match 'separator) ;; or t
#+end_src

In general, I recommend to experiment a bit with the various settings and key
bindings to find a configuration which works for you. There is no one size fits
all solution. Some people like auto completion, some like manual completion,
some want to cycle with TAB and some with the arrow keys...
I recommend to experiment a bit with the various settings and key bindings to
find a configuration which works for you. There is no one size fits all
solution. Some people like auto completion, some like manual completion, some
want to cycle with TAB and some with the arrow keys.

In case you like aggressive auto completion settings, where the completion popup
appears immediately, I recommend to use a cheap completion style like =basic=,
which performs prefix filtering. In this case Corfu completion should still be
very fast in buffers with efficient completion backends. You can try the
following settings in an Elisp buffer.

#+begin_src emacs-lisp
;; Aggressive completion, cheap prefix filtering.
(setq-local corfu-auto t
corfu-auto-delay 0
corfu-auto-prefix 0
completion-styles '(basic))
#+end_src

If you want to combine fast prefix filtering and Orderless filtering you can
still do that by defining a custom Orderless completion style via
=orderless-define-completion-style=. We use a custom style dispatcher, which
enables prefix filtering for input shorter than 4 characters. Note that such a
setup is quite advanced. Please refer to the Orderless documentation and source
code for further details.

#+begin_src emacs-lisp
(defun orderless-fast-dispatch (word index total)
(and (= index 0) (= total 1) (length< word 4)
`(orderless-regexp . ,(concat "^" (regexp-quote word)))))

(orderless-define-completion-style orderless-fast
(orderless-dispatch '(orderless-fast-dispatch))
(orderless-matching-styles '(orderless-literal orderless-regexp)))

(setq-local corfu-auto t
corfu-auto-delay 0
corfu-auto-prefix 0
completion-styles '(orderless-fast))
#+end_src

** Completing with Corfu in the minibuffer

Expand Down

0 comments on commit d2efee4

Please sign in to comment.