summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-06-26 12:46:01 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2022-06-26 12:46:01 +0200
commitd2efee4da17e8af0f340865df69eada593f68553 (patch)
tree4500b8f97a1e6e8f1dfa894428e2fdeb131ec5b3
parentdcc2ccfa59ea1748b2c6145ec7d6450f54d8ece3 (diff)
README: Document aggressive auto completion settings
See https://github.com/minad/cape/issues/52 for the discussion.
-rw-r--r--README.org44
1 files changed, 40 insertions, 4 deletions
diff --git a/README.org b/README.org
index d7bdad7..9797f0a 100644
--- a/README.org
+++ b/README.org
@@ -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