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