dotemacs

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

README-elpa (28656B)


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