dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

README.org (27559B)


      1 #+title: corfu.el - Completion Overlay Region FUnction
      2 #+author: Daniel Mendler
      3 #+language: en
      4 #+export_file_name: corfu.texi
      5 #+texinfo_dir_category: Emacs misc features
      6 #+texinfo_dir_title: Corfu: (corfu).
      7 #+texinfo_dir_desc: Completion Overlay Region FUnction
      8 
      9 #+html: <a href="https://www.gnu.org/software/emacs/"><img alt="GNU Emacs" src="https://github.com/minad/corfu/blob/screenshots/emacs.svg?raw=true"/></a>
     10 #+html: <a href="https://elpa.gnu.org/packages/corfu.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/corfu.svg"/></a>
     11 #+html: <a href="https://elpa.gnu.org/devel/corfu.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/corfu.svg"/></a>
     12 
     13 Corfu enhances completion at point with a small completion popup. The current
     14 candidates are shown in a popup below or above the point. Corfu is the
     15 minimalistic ~completion-in-region~ counterpart of the [[https://github.com/minad/vertico][Vertico]] minibuffer UI.
     16 
     17 Corfu is a small package, which relies on the Emacs completion facilities and
     18 concentrates on providing a polished completion UI. Completions are either
     19 provided by commands like ~dabbrev-completion~ or by pluggable backends
     20 (~completion-at-point-functions~, Capfs). Most programming language major modes
     21 implement a Capf. Furthermore the language server packages, Eglot and Lsp-mode,
     22 use Capfs which talk to the LSP server to retrieve the completions. Corfu does
     23 not include its own completion backends. The Emacs built-in Capfs and the Capfs
     24 provided by other programming language packages are usually sufficient. A few
     25 additional Capfs and completion utilities are provided by the [[https://github.com/minad/cape][Cape]] package.
     26 
     27 *NOTE*: Corfu uses child frames to show the popup and falls back to the default
     28 setting of the ~completion-in-region-function~ on non-graphical displays. If you
     29 want to use Corfu in the terminal, install the package [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]], which
     30 provides an alternative overlay-based display.
     31 
     32 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/light.png?raw=true">
     33 
     34 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/dark.png?raw=true">
     35 
     36 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/popupinfo-light.png?raw=true">
     37 
     38 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/popupinfo-dark.png?raw=true">
     39 
     40 #+toc: headlines 8
     41 
     42 * Features
     43 
     44 - Timer-based auto-completions (/off/ by default, set ~corfu-auto~).
     45 - Popup display with scrollbar indicator and arrow key navigation.
     46 - The popup can be summoned explicitly by pressing =TAB= at any time.
     47 - The current candidate is inserted with =TAB= and selected with =RET=.
     48 - Candidates sorting by prefix, string length and alphabetically.
     49 - The selected candidate is previewed (configurable via ~corfu-preview-current~).
     50 - The selected candidate automatically committed on further input by default.
     51   (configurable via ~corfu-preview-current~).
     52 - The [[https://github.com/oantolin/orderless][Orderless]] completion style is supported. The filter string can contain
     53   arbitrary characters, after inserting a space via =M-SPC= (configurable via
     54   ~corfu-quit-at-boundary~ and ~corfu-separator~).
     55 - Deferred completion style highlighting for performance.
     56 - Support for candidate annotations (=annotation-function=, =affixation-function=).
     57 - Deprecated candidates are crossed out in the display.
     58 - Icons can be provided by an external package via margin formatter functions.
     59 - Rich set of extensions: Quick keys, Index keys, Sorting by history, Candidate
     60   documentation in echo area, popup or separate buffer
     61 
     62 * Installation and Configuration
     63 
     64 Corfu is available from [[https://elpa.gnu.org/packages/corfu.html][GNU ELPA]], such that it can be installed directly via
     65 ~package-install~. After installation, the global minor mode can be enabled with
     66 =M-x global-corfu-mode=. In order to configure Corfu and other packages in your
     67 init.el, you may want to use ~use-package~.
     68 
     69 Corfu is highly flexible and customizable via ~corfu-*~ customization variables,
     70 such that you can adapt it precisely to your requirements. However in order to
     71 quickly try out the Corfu completion package, it should be sufficient to
     72 activate ~global-corfu-mode~. You can experiment with manual completion for
     73 example in an Elisp buffer or in an Eshell or Shell buffer. For auto completion,
     74 set ~corfu-auto=t~ before turning on ~global-corfu-mode~.
     75 
     76 Here is an example configuration:
     77 
     78 #+begin_src emacs-lisp
     79   (use-package corfu
     80     ;; Optional customizations
     81     ;; :custom
     82     ;; (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
     83     ;; (corfu-auto t)                 ;; Enable auto completion
     84     ;; (corfu-separator ?\s)          ;; Orderless field separator
     85     ;; (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
     86     ;; (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
     87     ;; (corfu-preview-current nil)    ;; Disable current candidate preview
     88     ;; (corfu-preselect-first nil)    ;; Disable candidate preselection
     89     ;; (corfu-on-exact-match nil)     ;; Configure handling of exact matches
     90     ;; (corfu-scroll-margin 5)        ;; Use scroll margin
     91 
     92     ;; Enable Corfu only for certain modes.
     93     ;; :hook ((prog-mode . corfu-mode)
     94     ;;        (shell-mode . corfu-mode)
     95     ;;        (eshell-mode . corfu-mode))
     96 
     97     ;; Recommended: Enable Corfu globally.
     98     ;; This is recommended since Dabbrev can be used globally (M-/).
     99     ;; See also `corfu-excluded-modes'.
    100     :init
    101     (global-corfu-mode))
    102 
    103   ;; A few more useful configurations...
    104   (use-package emacs
    105     :init
    106     ;; TAB cycle if there are only few candidates
    107     (setq completion-cycle-threshold 3)
    108 
    109     ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
    110     ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
    111     ;; (setq read-extended-command-predicate
    112     ;;       #'command-completion-default-include-p)
    113 
    114     ;; Enable indentation+completion using the TAB key.
    115     ;; `completion-at-point' is often bound to M-TAB.
    116     (setq tab-always-indent 'complete))
    117 #+end_src
    118 
    119 Dabbrev completion is based on =completion-in-region= and can be used with Corfu.
    120 You may want to swap the =dabbrev-completion= with the =dabbrev-expand= key for
    121 easier access, if you prefer completion. Also take a look at the =cape-dabbrev=
    122 completion at point function provided by my [[https://github.com/minad/cape][Cape]] package.
    123 
    124 #+begin_src emacs-lisp
    125   ;; Use Dabbrev with Corfu!
    126   (use-package dabbrev
    127     ;; Swap M-/ and C-M-/
    128     :bind (("M-/" . dabbrev-completion)
    129            ("C-M-/" . dabbrev-expand))
    130     ;; Other useful Dabbrev configurations.
    131     :custom
    132     (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
    133 #+end_src
    134 
    135 If you start to configure the package more deeply, I recommend to give the
    136 Orderless completion style a try for filtering. Orderless completion is
    137 different from the familiar prefix TAB completion. Corfu can be used with the
    138 default completion styles. The use of Orderless is not a necessity.
    139 
    140 #+begin_src emacs-lisp
    141   ;; Optionally use the `orderless' completion style.
    142   (use-package orderless
    143     :init
    144     ;; Configure a custom style dispatcher (see the Consult wiki)
    145     ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
    146     ;;       orderless-component-separator #'orderless-escapable-split-on-space)
    147     (setq completion-styles '(orderless basic)
    148           completion-category-defaults nil
    149           completion-category-overrides '((file (styles . (partial-completion))))))
    150 #+end_src
    151 
    152 The =basic= completion style is specified as fallback in addition to =orderless= in
    153 order to ensure that completion commands which rely on dynamic completion
    154 tables, e.g., ~completion-table-dynamic~ or ~completion-table-in-turn~, work
    155 correctly. See =+orderless-dispatch= in the [[https://github.com/minad/consult/wiki][Consult wiki]] for an advanced Orderless
    156 style dispatcher. Additionally enable =partial-completion= for file path
    157 expansion. =partial-completion= is important for file wildcard support. Multiple
    158 files can be opened at once with =find-file= if you enter a wildcard. You may also
    159 give the =initials= completion style a try.
    160 
    161 See also the [[https://github.com/minad/corfu/wiki][Corfu Wiki]] and the [[https://github.com/minad/cape][Cape manual]] for additional Capf configuration
    162 tips. The Eglot and Lsp-mode configurations are documented in the wiki. For more
    163 general documentation read the chapter about completion in the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html][Emacs manual]]. If
    164 you want to create your own Capfs, you can find documentation about completion
    165 in the [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html][Elisp manual]].
    166 
    167 ** Auto completion
    168 
    169 Auto completion is disabled by default, but can be enabled by setting
    170 ~corfu-auto=t~. Furthermore you may want to configure Corfu to quit completion
    171 eagerly, such that the completion popup stays out of your way when it appeared
    172 unexpectedly.
    173 
    174 #+begin_src emacs-lisp
    175   ;; Enable auto completion and configure quitting
    176   (setq corfu-auto t
    177         corfu-quit-no-match 'separator) ;; or t
    178 #+end_src
    179 
    180 I recommend to experiment a bit with the various settings and key bindings to
    181 find a configuration which works for you. There is no one size fits all
    182 solution. Some people like auto completion, some like manual completion, some
    183 want to cycle with TAB and some with the arrow keys.
    184 
    185 In case you like aggressive auto completion settings, where the completion popup
    186 appears immediately, I recommend to use a cheap completion style like =basic=,
    187 which performs prefix filtering. In this case Corfu completion should still be
    188 very fast in buffers with efficient completion backends. You can try the
    189 following settings in an Elisp buffer or the Emacs scratch buffer.
    190 
    191 #+begin_src emacs-lisp
    192   ;; Aggressive completion, cheap prefix filtering.
    193   (setq-local corfu-auto t
    194               corfu-auto-delay 0
    195               corfu-auto-prefix 0
    196               completion-styles '(basic))
    197 #+end_src
    198 
    199 If you want to combine fast prefix filtering and Orderless filtering you can
    200 still do that by defining a custom Orderless completion style via
    201 =orderless-define-completion-style=. We use a custom style dispatcher, which
    202 enables prefix filtering for input shorter than 4 characters. Note that such a
    203 setup is quite advanced. Please refer to the Orderless documentation and source
    204 code for further details.
    205 
    206 #+begin_src emacs-lisp
    207   (defun orderless-fast-dispatch (word index total)
    208     (and (= index 0) (= total 1) (length< word 4)
    209          `(orderless-regexp . ,(concat "^" (regexp-quote word)))))
    210 
    211   (orderless-define-completion-style orderless-fast
    212     (orderless-style-dispatchers '(orderless-fast-dispatch))
    213     (orderless-matching-styles '(orderless-literal orderless-regexp)))
    214 
    215   (setq-local corfu-auto t
    216               corfu-auto-delay 0
    217               corfu-auto-prefix 0
    218               completion-styles '(orderless-fast))
    219 #+end_src
    220 
    221 ** Completing in the minibuffer
    222 
    223 Corfu can be used for completion in the minibuffer, since it relies on child
    224 frames to display the candidates. By default, ~global-corfu-mode~ does not
    225 activate ~corfu-mode~ in the minibuffer, to avoid interference with specialised
    226 minibuffer completion UIs like Vertico or Mct. However you may still want to
    227 enable Corfu completion for commands like ~M-:~ (~eval-expression~) or ~M-!~
    228 (~shell-command~), which read from the minibuffer. Activate ~corfu-mode~ only if
    229 ~completion-at-point~ is bound in the minibuffer-local keymap to achieve this
    230 effect.
    231 
    232 #+begin_src emacs-lisp
    233     (defun corfu-enable-in-minibuffer ()
    234       "Enable Corfu in the minibuffer if `completion-at-point' is bound."
    235       (when (where-is-internal #'completion-at-point (list (current-local-map)))
    236         ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
    237         (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
    238                     corfu-popupinfo-delay nil)
    239         (corfu-mode 1)))
    240     (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
    241 #+end_src
    242 
    243 You can also enable Corfu more generally for every minibuffer, as long as no
    244 other completion UI is active. If you use Mct or Vertico as your main minibuffer
    245 completion UI, the following snippet should yield the desired result.
    246 
    247 #+begin_src emacs-lisp
    248   (defun corfu-enable-always-in-minibuffer ()
    249     "Enable Corfu in the minibuffer if Vertico/Mct are not active."
    250     (unless (or (bound-and-true-p mct--active)
    251                 (bound-and-true-p vertico--input))
    252       ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
    253       (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
    254                   corfu-popupinfo-delay nil)
    255       (corfu-mode 1)))
    256   (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
    257 #+end_src
    258 
    259 ** Completing in the Eshell or Shell
    260 
    261 When completing in the Eshell I recommend conservative local settings without
    262 auto completion, such that the completion behavior is similar to widely used
    263 shells like Bash, Zsh or Fish.
    264 
    265 #+begin_src emacs-lisp
    266   (add-hook 'eshell-mode-hook
    267             (lambda ()
    268               (setq-local corfu-auto nil)
    269               (corfu-mode)))
    270 #+end_src
    271 
    272 When pressing =RET= while the Corfu popup is visible, the ~corfu-insert~ command
    273 will be invoked. This command does inserts the currently selected candidate, but
    274 it does not send the prompt input to Eshell or the comint process. Therefore you
    275 often have to press =RET= twice which feels like an unnecessary double
    276 confirmation. Fortunately it is easy to improve this! In my configuration I
    277 define the advice ~corfu-send-shell~ which sends the candidate after insertion.
    278 
    279 #+begin_src emacs-lisp
    280   (defun corfu-send-shell (&rest _)
    281     "Send completion candidate when inside comint/eshell."
    282     (cond
    283      ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
    284       (eshell-send-input))
    285      ((and (derived-mode-p 'comint-mode)  (fboundp 'comint-send-input))
    286       (comint-send-input))))
    287 
    288   (advice-add #'corfu-insert :after #'corfu-send-shell)
    289 #+end_src
    290 
    291 Shell completion uses the flexible ~Pcomplete~ mechanism internally, which allows
    292 you to program the completions per shell command. If you want to know more, look
    293 into this [[https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs][blog post]], which shows how to configure Pcomplete for git commands. I
    294 recommend the [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]] package which extends Pcomplete with completion support
    295 and helpful annotation support for more commands. Similar to the Fish shell,
    296 pcmpl-args uses man page parsing and --help output parsing to dynamically
    297 generate completions. This package brings Eshell completion to another level!
    298 
    299 Unfortunately Pcomplete has a few technical issues, which we can work around
    300 with the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions). Cape provides wrappers,
    301 which sanitize the Pcomplete function. Ideally the bugs in Pcomplete should be
    302 fixed upstream. *For now these two advices are strongly recommended to achieve a
    303 sane Eshell experience.*
    304 
    305 #+begin_src emacs-lisp
    306   ;; Silence the pcomplete capf, no errors or messages!
    307   (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
    308 
    309   ;; Ensure that pcomplete does not write to the buffer
    310   ;; and behaves as a pure `completion-at-point-function'.
    311   (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
    312 #+end_src
    313 
    314 ** Orderless completion
    315 
    316 [[https://github.com/oantolin/orderless][Orderless]] is an advanced completion style that supports multi-component search
    317 filters separated by a configurable character (space, by default). Normally,
    318 entering characters like space which lie outside the completion region
    319 boundaries (words, typically) causes Corfu to quit. This behavior is helpful
    320 with auto-completion, which may pop-up when not desired, e.g. on entering a new
    321 variable name. Just keep typing and Corfu will get out of the way.
    322 
    323 But orderless search terms can contain arbitrary characters; they are also
    324 interpreted as regular expressions. To use orderless, set ~corfu-separator~ (a
    325 space, by default) to the primary character of your orderless component
    326 separator.
    327 
    328 Then, when a new orderless component is desired, use =M-SPC=
    329 (~corfu-insert-separator~) to enter the /first/ component separator in the input,
    330 and arbitrary orderless search terms and new separators can be entered
    331 thereafter.
    332 
    333 To treat the entire input as Orderless input, you can set the customization
    334 option ~corfu-quit-at-boundary=t~. This disables the predicate which checks if the
    335 current completion boundary has been left. In contrast, if you /always/ want to
    336 quit at the boundary, simply set ~corfu-quit-at-boundary=nil~. By default
    337 ~corfu-quit-at-boundary~ is set to ~separator~ which quits at completion boundaries
    338 as long as no separator has been inserted with ~corfu-insert-separator~.
    339 
    340 Finally, there exists the user option ~corfu-quit-no-match~ which is set to
    341 =separator= by default. With this setting Corfu stays alive as soon as you start
    342 advanced filtering with a ~corfu-separator~ even if there are no matches, for
    343 example due to a typo. As long as no separator character has been inserted with
    344 ~corfu-insert-separator~, Corfu will still quit if there are no matches. This
    345 ensures that the Corfu popup goes away quickly if completion is not possible.
    346 
    347 In the following we show two configurations, one which works best with auto
    348 completion and one which may work better with manual completion if you prefer to
    349 always use =SPC= to separate the Orderless components.
    350 
    351  #+begin_src emacs-lisp
    352    ;; Auto completion example
    353    (use-package corfu
    354      :custom
    355      (corfu-auto t)          ;; Enable auto completion
    356      ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
    357      :bind
    358      ;; Another key binding can be used, such as S-SPC.
    359      ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
    360      :init
    361      (global-corfu-mode))
    362 
    363    ;; Manual completion example
    364    (use-package corfu
    365      :custom
    366      ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
    367      :bind
    368      ;; Configure SPC for separator insertion
    369      (:map corfu-map ("SPC" . corfu-insert-separator))
    370      :init
    371      (global-corfu-mode))
    372 #+end_src
    373 
    374 ** TAB-and-Go completion
    375 
    376 You may be interested in configuring Corfu in TAB-and-Go style. Pressing TAB
    377 moves to the next candidate and further input will then commit the selection.
    378 Note that further input will not expand snippets or templates, which may not be
    379 desired but which leads overall to a more predictable behavior. In order to
    380 force snippet expansion, confirm a candidate explicitly with ~RET~.
    381 
    382 #+begin_src emacs-lisp
    383   (use-package corfu
    384     ;; TAB-and-Go customizations
    385     :custom
    386     (corfu-cycle t)             ;; Enable cycling for `corfu-next/previous'
    387     (corfu-preselect-first nil) ;; Disable candidate preselection
    388 
    389     ;; Use TAB for cycling, default is `corfu-complete'.
    390     :bind
    391     (:map corfu-map
    392           ("TAB" . corfu-next)
    393           ([tab] . corfu-next)
    394           ("S-TAB" . corfu-previous)
    395           ([backtab] . corfu-previous))
    396 
    397     :init
    398     (global-corfu-mode))
    399 #+end_src
    400 
    401 ** Transfer completion to the minibuffer
    402 
    403 Sometimes it is useful to transfer the Corfu completion session to the
    404 minibuffer, since the minibuffer offers richer interaction features. In
    405 particular, [[https://github.com/oantolin/embark][Embark]] is available in the minibuffer, such that you can act on the
    406 candidates or export/collect the candidates to a separate buffer. We could add
    407 Corfu support to Embark in the future, such that export/collect is possible
    408 directly from Corfu. But in my opinion having the ability to transfer the Corfu
    409 completion to the minibuffer is an even better feature, since further completion
    410 can be performed there.
    411 
    412 The command ~corfu-move-to-minibuffer~ is defined here in terms of
    413 ~consult-completion-in-region~, which uses the minibuffer completion UI via
    414 ~completing-read~.
    415 
    416 #+begin_src emacs-lisp
    417   (defun corfu-move-to-minibuffer ()
    418     (interactive)
    419     (let ((completion-extra-properties corfu--extra)
    420           completion-cycle-threshold completion-cycling)
    421       (apply #'consult-completion-in-region completion-in-region--data)))
    422   (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
    423 #+end_src
    424 
    425 * Key bindings
    426 
    427 Corfu uses a transient keymap ~corfu-map~ which is active while the popup is
    428 shown. The keymap defines the following remappings and bindings:
    429 
    430 - ~beginning-of-buffer~ -> ~corfu-first~
    431 - ~end-of-buffer~ -> ~corfu-last~
    432 - ~scroll-down-command~ -> ~corfu-scroll-down~
    433 - ~scroll-up-command~ -> ~corfu-scroll-up~
    434 - ~next-line~, =down=, =M-n= -> ~corfu-next~
    435 - ~previous-line~, =up=, =M-p= -> ~corfu-previous~
    436 - ~completion-at-point~, =TAB= -> ~corfu-complete~
    437 - =RET= -> ~corfu-insert~
    438 - =M-g= -> ~corfu-info-location~
    439 - =M-h= -> ~corfu-info-documentation~
    440 - =M-SPC= -> ~corfu-insert-separator~
    441 - =C-g= -> ~corfu-quit~
    442 - ~keyboard-escape-quit~ -> ~corfu-reset~
    443 
    444 * Extensions
    445 :properties:
    446 :custom_id: extensions
    447 :end:
    448 
    449 We maintain small extension packages to Corfu in this repository in the
    450 subdirectory [[https://github.com/minad/corfu/tree/main/extensions][extensions/]]. The extensions are installed together with Corfu if
    451 you pull the package from ELPA. The extensions are inactive by default and can
    452 be enabled manually if desired. Furthermore it is possible to install all of the
    453 files separately, both ~corfu.el~ and the ~corfu-*.el~ extensions. Currently the
    454 following extensions come with the Corfu ELPA package:
    455 
    456 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-echo.el][corfu-echo]]: =corfu-echo-mode= displays a brief candidate documentation in the
    457   echo area.
    458 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-history.el][corfu-history]]: =corfu-history-mode= remembers selected candidates and sorts the
    459   candidates by their history position.
    460 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el][corfu-indexed]]: =corfu-indexed-mode= allows you to select indexed candidates with
    461   prefix arguments.
    462 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-info.el][corfu-info]]: Actions to access the candidate location and documentation.
    463 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-popupinfo.el][corfu-popupinfo]]: Display candidate documentation or source in a popup next to
    464   the candidate menu.
    465 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el][corfu-quick]]: Commands to select using Avy-style quick keys.
    466 
    467 See the Commentary of those files for configuration details.
    468 
    469 * Complementary packages
    470 
    471 Corfu works well together with all packages providing code completion via the
    472 ~completion-at-point-functions~. Many modes and packages already provide a Capf
    473 out of the box. Nevertheless you may want to look into complementary packages to
    474 enhance your setup.
    475 
    476 - [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]]: The corfu-terminal package provides an overlay-based display
    477   for Corfu, such that you can use Corfu in terminal Emacs.
    478 
    479 - [[https://github.com/oantolin/orderless][Orderless]]: Corfu supports completion styles, including the advanced
    480   [[https://github.com/oantolin/orderless][Orderless]] completion style, where the filtering expressions are separated by
    481   spaces or another character (see ~corfu-separator~).
    482 
    483 - [[https://github.com/minad/cape][Cape]]: Additional Capf backends and =completion-in-region= commands
    484   are provided by the [[https://github.com/minad/cape][Cape]] package. Among others, the package supplies a file
    485   path and a Dabbrev completion backend. Cape provides the ~cape-company-to-capf~
    486   adapter to reuse Company backends in Corfu. Furthermore the function
    487   ~cape-super-capf~ can merge multiple Capfs, such that the candidates of multiple
    488   Capfs are displayed together at the same time.
    489 
    490 - [[https://github.com/jdtsmith/kind-icon][kind-icon]]: Icons are supported by Corfu via an external package. For example
    491   the [[https://github.com/jdtsmith/kind-icon][kind-icon]] package provides beautifully styled SVG icons based on
    492   monochromatic icon sets like material design.
    493 
    494 - [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]]: Extend the Eshell/Shell Pcomplete mechanism with support for many
    495   more commands. Similar to the Fish shell, Pcomplete uses man page parsing to
    496   dynamically retrieve the completions and helpful annotations. This package
    497   brings Eshell completions to another level!
    498 
    499 - [[https://github.com/minad/tempel][Tempel]]: Tiny template/snippet package with templates in Lisp syntax, which
    500   can be used in conjunction with Corfu.
    501 
    502 - [[https://github.com/minad/vertico][Vertico]]: You may also want to look into my [[https://github.com/minad/vertico][Vertico]] package. Vertico is the
    503   minibuffer completion counterpart of Corfu.
    504 
    505 * Alternatives
    506 
    507 - [[https://github.com/company-mode/company-mode][Company]]: Company is a widely used and mature completion package, which
    508   implements a similar interaction model and popup UI as Corfu. While Corfu
    509   relies exclusively on the standard Emacs completion API (Capfs), Company
    510   defines its own API for the backends. Company includes its completion
    511   backends, which are incompatible with the Emacs completion infrastructure. As
    512   a result of this design, Company is a more complex package than Corfu. Company
    513   by default uses overlays for the popup in contrast to the child frames used by
    514   Corfu. Overall both packages work well, but Company integrates less tightly
    515   with Emacs. The ~completion-styles~ support is more limited and the
    516   ~completion-at-point~ command and the ~completion-in-region~ function do not
    517   invoke Company.
    518 
    519 - [[https://git.sr.ht/~protesilaos/mct][Mct]]: Protesilaos' Minibuffer Confines Transcended package supports both
    520   minibuffer completion and completion in region. It reuses the default
    521   completion UI for this purpose and installs a timer which live updates the
    522   completion buffer. The main advantage of Mct is that you work with a regular
    523   Emacs buffer instead of with a popup. You can take advantage of the usual
    524   Emacs commands to navigate in the completions buffer. On top, Mct enhances the
    525   movement such that you can quickly switch between the completions buffer and
    526   the minibuffer or the region which is being completed. Mct does not support
    527   timer-based auto completion, but the integration into Emacs is naturally
    528   tight. Note that Mct development is currently [[https://protesilaos.com/codelog/2022-04-14-emacs-discontinue-mct/][discontinued]] due to recent
    529   changes of the default completion UI on the Emacs master branch.
    530 
    531 - [[https://github.com/minad/consult][consult-completion-in-region]]: The Consult package provides the function
    532   ~consult-completion-in-region~ which can be set as ~completion-in-region-function~
    533   such that it handles ~completion-at-point~. The function works by transferring
    534   the in-buffer completion to the minibuffer. In the minibuffer, the minibuffer
    535   completion UI, for example [[https://github.com/minad/vertico][Vertico]] takes over. If you prefer to perform all
    536   your completions in the minibuffer ~consult-completion-in-region~ is your best
    537   option.
    538 
    539 * Contributions
    540 
    541 Since this package is part of [[https://elpa.gnu.org/packages/corfu.html][GNU ELPA]] contributions require a copyright
    542 assignment to the FSF.