commit dcb9557ef8108694a0176593e52540b346a7d10f
parent 0753ac9ab496a86373a1a1dfc3df9f870f845084
Author: Lukas Henkel <lh@entf.net>
Date: Sat, 8 Oct 2022 10:59:41 +0200
Update corfu
Diffstat:
23 files changed, 3827 insertions(+), 3030 deletions(-)
diff --git a/elpa/corfu-0.23.signed b/elpa/corfu-0.23.signed
@@ -1 +0,0 @@
-Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2022-05-06T11:05:01+0200 using RSA
-\ No newline at end of file
diff --git a/elpa/corfu-0.23/README.org b/elpa/corfu-0.23/README.org
@@ -1,488 +0,0 @@
-#+title: corfu.el - Completion Overlay Region FUnction
-#+author: Daniel Mendler
-#+language: en
-#+export_file_name: corfu.texi
-#+texinfo_dir_category: Emacs misc features
-#+texinfo_dir_title: Corfu: (corfu).
-#+texinfo_dir_desc: Completion Overlay Region FUnction
-
-#+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>
-#+html: <a href="http://elpa.gnu.org/packages/corfu.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/corfu.svg"/></a>
-#+html: <a href="http://elpa.gnu.org/devel/corfu.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/corfu.svg"/></a>
-
-* Introduction
-
-Corfu enhances completion at point with a small completion popup. The current
-candidates are shown in a popup below or above the point. Corfu is the
-minimalistic ~completion-in-region~ counterpart of the [[https://github.com/minad/vertico][Vertico]] minibuffer UI.
-
-Corfu is a small package, which relies on the Emacs completion facilities and
-concentrates on providing a polished completion UI. Completions are either
-provided by commands like ~dabbrev-completion~ or by pluggable backends
-(~completion-at-point-functions~, Capfs). Most programming language major modes
-implement a Capf. Furthermore the language server packages, [[https://github.com/joaotavora/eglot][Eglot]] and [[https://github.com/emacs-lsp/lsp-mode][Lsp-mode]],
-use Capfs which talk to the LSP server to retrieve the completions. Corfu does
-not include its own completion backends. The Emacs built-in Capfs and the Capfs
-provided by other programming language packages are usually sufficient. A few
-additional Capfs and completion utilities are provided by the [[https://github.com/minad/cape][Cape]] package.
-
-*NOTE*: Corfu uses child frames to show the popup and falls back to the default
-setting of the ~completion-in-region-function~ on non-graphical displays. There is
-a [[https://codeberg.org/akib/emacs-corfu-popup][package in the works]] which uses overlays for the popup such that Corfu can be
-used when Emacs is running in a terminal.
-
-[[https://github.com/minad/corfu/blob/screenshots/light.png?raw=true]]
-
-[[https://github.com/minad/corfu/blob/screenshots/dark.png?raw=true]]
-
-* Features
-
-- Timer-based auto-completions (/off/ by default, set ~corfu-auto~).
-- Popup display with scrollbar indicator and arrow key navigation.
-- The popup can be summoned explicitly by pressing =TAB= at any time.
-- The current candidate is inserted with =TAB= and selected with =RET=.
-- Candidates sorting by prefix, string length and alphabetically.
-- The selected candidate is previewed (configurable via ~corfu-preview-current~).
-- The selected candidate automatically committed on further input by default.
- (configurable via ~corfu-preview-current~).
-- The [[https://github.com/oantolin/orderless][Orderless]] completion style is supported. The filter string can contain
- arbitrary characters, after inserting a space via =M-SPC= (configurable via
- ~corfu-quit-at-boundary~ and ~corfu-separator~).
-- Deferred completion style highlighting for performance.
-- Support for candidate annotations and documentation in the echo area.
-- Deprecated candidates are crossed out in the display.
-- Icons can be provided by an external package via margin formatter functions.
-- Extensions: Quick keys, Index keys, Sorting by history, Candidate documentation
-
-* Installation and Configuration
-
-Corfu is available from [[http://elpa.gnu.org/packages/corfu.html][GNU ELPA]], such that it can be installed directly via
-~package-install~. After installation, the global minor mode can be enabled with
-=M-x global-corfu-mode=. In order to configure Corfu and other packages in your
-init.el, you may want to use ~use-package~.
-
-Corfu is highly flexible and customizable via ~corfu-*~ customization variables,
-such that you can adapt it precisely to your requirements. However in order to
-quickly try out the Corfu completion package, it should be sufficient to
-activate ~global-corfu-mode~. You can experiment with manual completion for
-example in an Elisp buffer or in an Eshell or Shell buffer. For auto completion,
-set ~corfu-auto=t~ before turning on ~global-corfu-mode~.
-
-Here is an example configuration:
-
-#+begin_src emacs-lisp
- (use-package corfu
- ;; Optional customizations
- ;; :custom
- ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- ;; (corfu-auto t) ;; Enable auto completion
- ;; (corfu-separator ?\s) ;; Orderless field separator
- ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
- ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
- ;; (corfu-preview-current nil) ;; Disable current candidate preview
- ;; (corfu-preselect-first nil) ;; Disable candidate preselection
- ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
- ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
- ;; (corfu-scroll-margin 5) ;; Use scroll margin
-
- ;; Enable Corfu only for certain modes.
- ;; :hook ((prog-mode . corfu-mode)
- ;; (shell-mode . corfu-mode)
- ;; (eshell-mode . corfu-mode))
-
- ;; Recommended: Enable Corfu globally.
- ;; This is recommended since Dabbrev can be used globally (M-/).
- ;; See also `corfu-excluded-modes'.
- :init
- (global-corfu-mode))
-
- ;; A few more useful configurations...
- (use-package emacs
- :init
- ;; TAB cycle if there are only few candidates
- (setq completion-cycle-threshold 3)
-
- ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
- ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
- ;; (setq read-extended-command-predicate
- ;; #'command-completion-default-include-p)
-
- ;; Enable indentation+completion using the TAB key.
- ;; `completion-at-point' is often bound to M-TAB.
- (setq tab-always-indent 'complete))
-#+end_src
-
-Dabbrev completion is based on =completion-in-region= and can be used with Corfu.
-You may want to swap the =dabbrev-completion= with the =dabbrev-expand= key for
-easier access, if you prefer completion. Also take a look at the =cape-dabbrev=
-completion at point function provided by my [[https://github.com/minad/cape][Cape]] package.
-
-#+begin_src emacs-lisp
- ;; Use Dabbrev with Corfu!
- (use-package dabbrev
- ;; Swap M-/ and C-M-/
- :bind (("M-/" . dabbrev-completion)
- ("C-M-/" . dabbrev-expand))
- ;; Other useful Dabbrev configurations.
- :custom
- (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
-#+end_src
-
-If you start to configure the package more deeply, I recommend to give the
-Orderless completion style a try for filtering. Orderless completion is
-different from the familiar prefix TAB completion. Corfu can be used with the
-default completion styles. The use of Orderless is not a necessity.
-
-#+begin_src emacs-lisp
- ;; Optionally use the `orderless' completion style.
- (use-package orderless
- :init
- ;; Configure a custom style dispatcher (see the Consult wiki)
- ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
- ;; orderless-component-separator #'orderless-escapable-split-on-space)
- (setq completion-styles '(orderless basic)
- completion-category-defaults nil
- completion-category-overrides '((file (styles . (partial-completion))))))
-#+end_src
-
-The =basic= completion style is specified as fallback in addition to =orderless= in
-order to ensure that completion commands which rely on dynamic completion
-tables, e.g., ~completion-table-dynamic~ or ~completion-table-in-turn~, work
-correctly. See =+orderless-dispatch= in the [[https://github.com/minad/consult/wiki][Consult wiki]] for an advanced Orderless
-style dispatcher. Additionally enable =partial-completion= for file path
-expansion. =partial-completion= is important for file wildcard support. Multiple
-files can be opened at once with =find-file= if you enter a wildcard. You may also
-give the =initials= completion style a try.
-
-See also the [[https://github.com/minad/corfu/wiki][Corfu Wiki]] for additional configuration tips. In particular the
-Lsp-mode configuration is documented in the wiki. For more general documentation
-read the chapter about completion in the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html][Emacs manual]]. If you want to create
-your own Capfs, you can find documentation about completion in the [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html][Elisp manual]].
-
-** Auto completion
-
-Auto completion is disabled by default, but can be enabled by setting
-~corfu-auto=t~. Furthermore you may want to configure Corfu to quit completion
-eagerly, such that the completion popup stays out of your way when it appeared
-unexpectedly.
-
-#+begin_src emacs-lisp
- ;; Enable auto completion and configure quitting
- (setq corfu-auto t
- corfu-quit-no-match 'separator) ;; or t
-#+end_src
-
-In general, I recommend to experiment a bit with the various settings and key
-bindings to find a configuration which works for you. There is no one size fits
-all solution. Some people like auto completion, some like manual completion,
-some want to cycle with TAB and some with the arrow keys...
-
-** Completing with Corfu in the minibuffer
-
-Corfu can be used for completion in the minibuffer, since it relies on child
-frames to display the candidates. By default, ~global-corfu-mode~ does not
-activate ~corfu-mode~ in the minibuffer, to avoid interference with specialised
-minibuffer completion UIs like Vertico or Mct. However you may still want to
-enable Corfu completion for commands like ~M-:~ (~eval-expression~) or ~M-!~
-(~shell-command~), which read from the minibuffer. Activate ~corfu-mode~ only if
-~completion-at-point~ is bound in the minibuffer-local keymap to achieve this
-effect.
-
-#+begin_src emacs-lisp
- (defun corfu-enable-in-minibuffer ()
- "Enable Corfu in the minibuffer if `completion-at-point' is bound."
- (when (where-is-internal #'completion-at-point (list (current-local-map)))
- ;; (setq-local corfu-auto nil) Enable/disable auto completion
- (corfu-mode 1)))
- (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
-#+end_src
-
-You can also enable Corfu more generally for every minibuffer, as long as no
-other completion UI is active. If you use Mct or Vertico as your main minibuffer
-completion UI, the following snippet should yield the desired result.
-
-#+begin_src emacs-lisp
- (defun corfu-enable-always-in-minibuffer ()
- "Enable Corfu in the minibuffer if Vertico/Mct are not active."
- (unless (or (bound-and-true-p mct--active)
- (bound-and-true-p vertico--input))
- ;; (setq-local corfu-auto nil) Enable/disable auto completion
- (corfu-mode 1)))
- (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
-#+end_src
-
-** Completing with Corfu in the Eshell or Shell
-
-When completing in the Eshell I recommend conservative local settings without
-auto completion, such that the completion behavior is similar to widely used
-shells like Bash, Zsh or Fish.
-
-#+begin_src emacs-lisp
- (add-hook 'eshell-mode-hook
- (lambda ()
- (setq-local corfu-auto nil)
- (corfu-mode)))
-#+end_src
-
-When pressing =RET= while the Corfu popup is visible, the ~corfu-insert~ command
-will be invoked. This command does inserts the currently selected candidate, but
-it does not send the prompt input to Eshell or the comint process. Therefore you
-often have to press =RET= twice which feels like an unnecessary double
-confirmation. Fortunately it is easy to improve this! In my configuration I
-define the advice ~corfu-send-shell~ which sends the candidate after insertion.
-
-#+begin_src emacs-lisp
- (defun corfu-send-shell (&rest _)
- "Send completion candidate when inside comint/eshell."
- (cond
- ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
- (eshell-send-input))
- ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
- (comint-send-input))))
-
- (advice-add #'corfu-insert :after #'corfu-send-shell)
-#+end_src
-
-Shell completion uses the flexible ~pcomplete~ mechanism internally, which allows
-you to program the completions per shell command. If you want to know more, look
-into this [[https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs][blog post]], which shows how to configure pcomplete for git commands. I
-recommend the [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]] package which extends Pcomplete with completion support
-and helpful annotation support for more commands. Similar to the Fish shell,
-pcmpl-args uses man page parsing and --help output parsing to dynamically
-generate completions. This package brings Eshell completion to another level!
-
-Unfortunately Pcomplete has a few technical issues, which we can work around
-with the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions). Cape provides wrappers,
-which sanitize the pcomplete function. Ideally the bugs in pcomplete should be
-fixed upstream. *For now these two advices are strongly recommended to achieve a
-sane Eshell experience.*
-
-#+begin_src emacs-lisp
- ;; Silence the pcomplete capf, no errors or messages!
- (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
-
- ;; Ensure that pcomplete does not write to the buffer
- ;; and behaves as a pure `completion-at-point-function'.
- (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
-#+end_src
-
-** Orderless completion
-
-[[https://github.com/oantolin/orderless][Orderless]] is an advanced completion style that supports multi-component search
-filters separated by a configurable character (space, by default). Normally,
-entering characters like space which lie outside the completion region
-boundaries (words, typically) causes Corfu to quit. This behavior is helpful
-with auto-completion, which may pop-up when not desired, e.g. on entering a new
-variable name. Just keep typing and Corfu will get out of the way.
-
-But orderless search terms can contain arbitrary characters; they are also
-interpreted as regular expressions. To use orderless, set ~corfu-separator~ (a
-space, by default) to the primary character of your orderless component
-separator.
-
-Then, when a new orderless component is desired, use =M-SPC=
-(~corfu-insert-separator~) to enter the /first/ component separator in the input,
-and arbitrary orderless search terms and new separators can be entered
-thereafter.
-
-To treat the entire input as Orderless input, you can set the customization
-option ~corfu-quit-at-boundary=t~. This disables the predicate which checks if the
-current completion boundary has been left. In contrast, if you /always/ want to
-quit at the boundary, simply set ~corfu-quit-at-boundary=nil~. By default
-~corfu-quit-at-boundary~ is set to ~separator~ which quits at completion boundaries
-as long as no separator has been inserted with ~corfu-insert-separator~.
-
-Finally, there exists the user option ~corfu-quit-no-match~ which is set to
-=separator= by default. With this setting Corfu stays alive as soon as you start
-advanced filtering with a ~corfu-separator~ even if there are no matches, for
-example due to a typo. As long as no separator character has been inserted with
-~corfu-insert-separator~, Corfu will still quit if there are no matches. This
-ensures that the Corfu popup goes away quickly if completion is not possible.
-
-In the following we show two configurations, one which works best with auto
-completion and one which may work better with manual completion if you prefer to
-always use =SPC= to separate the Orderless components.
-
- #+begin_src emacs-lisp
- ;; Auto completion example
- (use-package corfu
- :custom
- (corfu-auto t) ;; Enable auto completion
- ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
- :bind
- ;; Another key binding can be used, such as S-SPC.
- ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
- :init
- (global-corfu-mode))
-
- ;; Manual completion example
- (use-package corfu
- :custom
- ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
- :bind
- ;; Configure SPC for separator insertion
- (:map corfu-map ("SPC" . corfu-insert-separator))
- :init
- (global-corfu-mode))
-#+end_src
-
-** TAB-and-Go completion
-
-You may be interested in configuring Corfu in TAB-and-Go style. Pressing TAB
-moves to the next candidate and further input will then commit the selection.
-Note that further input will not expand snippets or templates, which may not be
-desired but which leads overall to a more predictable behavior. In order to
-force snippet expansion, confirm a candidate explicitly with ~RET~.
-
-#+begin_src emacs-lisp
- (use-package corfu
- ;; TAB-and-Go customizations
- :custom
- (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- (corfu-preselect-first nil) ;; Disable candidate preselection
-
- ;; Use TAB for cycling, default is `corfu-complete'.
- :bind
- (:map corfu-map
- ("TAB" . corfu-next)
- ([tab] . corfu-next)
- ("S-TAB" . corfu-previous)
- ([backtab] . corfu-previous))
-
- :init
- (global-corfu-mode))
-#+end_src
-
-** Transfer completion to the minibuffer
-
-Sometimes it is useful to transfer the Corfu completion session to the
-minibuffer, since the minibuffer offers richer interaction features. In
-particular, [[https://github.com/oantolin/embark][Embark]] is available in the minibuffer, such that you can act on the
-candidates or export/collect the candidates to a separate buffer. Hopefully we
-can also add Corfu-support to Embark in the future, such that at least
-export/collect is possible directly from Corfu. But in my opinion having the
-ability to transfer the Corfu completion to the minibuffer is an even better
-feature, since further completion can be performed there.
-
-The command ~corfu-move-to-minibuffer~ is defined here in terms of
-~consult-completion-in-region~, which uses the minibuffer completion UI via
-~completing-read~.
-
-#+begin_src emacs-lisp
- (defun corfu-move-to-minibuffer ()
- (interactive)
- (let ((completion-extra-properties corfu--extra)
- completion-cycle-threshold completion-cycling)
- (apply #'consult-completion-in-region completion-in-region--data)))
- (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
-#+end_src
-
-* Key bindings
-
-Corfu uses a transient keymap ~corfu-map~ which is active while the popup is
-shown. The keymap defines the following remappings and bindings:
-
-- ~beginning-of-buffer~ -> ~corfu-first~
-- ~end-of-buffer~ -> ~corfu-last~
-- ~scroll-down-command~ -> ~corfu-scroll-down~
-- ~scroll-up-command~ -> ~corfu-scroll-up~
-- ~next-line~, =down=, =M-n= -> ~corfu-next~
-- ~previous-line~, =up=, =M-p= -> ~corfu-previous~
-- ~completion-at-point~, =TAB= -> ~corfu-complete~
-- =RET= -> ~corfu-insert~
-- =M-g= -> ~corfu-info-location~
-- =M-h= -> ~corfu-info-documentation~
-- =M-SPC= -> ~corfu-insert-separator~
-- =C-g= -> ~corfu-quit~
-- ~keyboard-escape-quit~ -> ~corfu-reset~
-
-* Extensions
-:properties:
-:custom_id: extensions
-:end:
-
-We maintain small extension packages to Corfu in this repository in the
-subdirectory [[https://github.com/minad/corfu/tree/main/extensions][extensions/]]. The extensions are installed together with Corfu if
-you pull the package from ELPA. The extensions are inactive by default and can
-be enabled manually if desired. Furthermore it is possible to install all of the
-files separately, both ~corfu.el~ and the ~corfu-*.el~ extensions. Currently the
-following extensions come with the Corfu ELPA package:
-
-- [[https://github.com/minad/corfu/blob/main/extensions/corfu-history.el][corfu-history]]: =corfu-history-mode= to remember selected candidates and to improve sorting.
-- [[https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el][corfu-indexed]]: =corfu-indexed-mode= to select indexed candidates with prefix arguments.
-- [[https://github.com/minad/corfu/blob/main/extensions/corfu-info.el][corfu-info]]: Candidate actions to access the candidate location and documentation.
-- [[https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el][corfu-quick]]: Commands to select using Avy-style quick keys.
-
-* Complementary packages
-
-Corfu works well together with all packages providing code completion via the
-~completion-at-point-functions~. Many modes and packages already provide a Capf
-out of the box. Nevertheless you may want to look into complementary packages to
-enhance your setup.
-
-- [[https://github.com/oantolin/orderless][Orderless]]: Corfu supports completion styles, including the advanced
- [[https://github.com/oantolin/orderless][Orderless]] completion style, where the filtering expressions are separated by
- spaces or another character (see ~corfu-separator~).
-
-- [[https://github.com/minad/cape][Cape]]: Additional Capf backends and =completion-in-region= commands
- are provided by the [[https://github.com/minad/cape][Cape]] package. Among others, the package supplies a file
- path and a dabbrev completion backend. Cape provides the ~cape-company-to-capf~
- adapter to reuse Company backends in Corfu. Furthermore the function
- ~cape-super-capf~ can merge multiple Capfs, such that the candidates of multiple
- Capfs are displayed together at the same time.
-
-- [[https://github.com/jdtsmith/kind-icon][kind-icon]]: Icons are supported by Corfu via an external package. For example
- the [[https://github.com/jdtsmith/kind-icon][kind-icon]] package provides beautifully styled SVG icons based on
- monochromatic icon sets like material design.
-
-- [[https://github.com/galeo/corfu-doc][corfu-doc]]: The corfu-doc package displays the candidate documentation in a
- popup next to the Corfu popup, similar to =company-quickhelp=.
-
-- [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]]: Extend the Eshell/Shell Pcomplete mechanism with support for many
- more commands. Similar to the Fish shell, Pcomplete uses man page parsing to
- dynamically retrieve the completions and helpful annotations. This package
- brings Eshell completions to another level!
-
-- [[https://github.com/minad/tempel][Tempel]]: Tiny template/snippet package with templates in Lisp syntax, which
- can be used in conjunction with Corfu.
-
-- [[https://github.com/minad/vertico][Vertico]]: You may also want to look into my [[https://github.com/minad/vertico][Vertico]] package. Vertico is the
- minibuffer completion counterpart of Corfu.
-
-* Alternatives
-
-- [[https://github.com/company-mode/company-mode][Company]]: Company is a widely used and mature completion package, which
- implements a similar interaction model and popup UI as Corfu. While Corfu
- relies exclusively on the standard Emacs completion API (Capfs), Company
- defines its own API for the backends. Company includes its completion
- backends, which are incompatible with the Emacs completion infrastructure. As
- a result of this design, Company is a more complex package than Corfu. Company
- by default uses overlays for the popup in contrast to the child frames used by
- Corfu. Overall both packages work well, but Company integrates less tightly
- with Emacs. The ~completion-styles~ support is more limited and the
- ~completion-at-point~ command and the ~completion-in-region~ function do not
- invoke Company.
-
-- [[https://git.sr.ht/~protesilaos/mct][Mct]]: Protesilaos' Minibuffer Confines Transcended package supports both
- minibuffer completion and completion in region. It reuses the default
- completion UI for this purpose and installs a timer which live updates the
- completion buffer. The main advantage of Mct is that you work with a regular
- Emacs buffer instead of with a popup. You can take advantage of the usual
- Emacs commands to navigate in the completions buffer. On top, Mct enhances the
- movement such that you can quickly switch between the completions buffer and
- the minibuffer or the region which is being completed. Mct does not support
- timer-based auto completion, but the integration into Emacs is naturally
- tight.
-
-- [[https://github.com/minad/consult][consult-completion-in-region]]: The Consult package provides the function
- ~consult-completion-in-region~ which can be set as ~completion-in-region-function~
- such that it handles ~completion-at-point~. The function works by transferring
- the in-buffer completion to the minibuffer. In the minibuffer, the minibuffer
- completion UI, for example [[https://github.com/minad/vertico][Vertico]] takes over. If you prefer to perform all
- your completions in the minibuffer ~consult-completion-in-region~ is your best
- option.
-
-* Contributions
-
-Since this package is part of [[http://elpa.gnu.org/packages/corfu.html][GNU ELPA]] contributions require a copyright
-assignment to the FSF.
diff --git a/elpa/corfu-0.23/corfu-autoloads.el b/elpa/corfu-0.23/corfu-autoloads.el
@@ -1,173 +0,0 @@
-;;; corfu-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*-
-;;
-;;; Code:
-
-(add-to-list 'load-path (directory-file-name
- (or (file-name-directory #$) (car load-path))))
-
-
-;;;### (autoloads nil "corfu" "corfu.el" (0 0 0 0))
-;;; Generated autoloads from corfu.el
-
-(autoload 'corfu-mode "corfu" "\
-Completion Overlay Region FUnction.
-
-This is a minor mode. If called interactively, toggle the `Corfu
-mode' mode. If the prefix argument is positive, enable the mode,
-and if it is zero or negative, disable the mode.
-
-If called from Lisp, toggle the mode if ARG is `toggle'. Enable
-the mode if ARG is nil, omitted, or is a positive number.
-Disable the mode if ARG is a negative number.
-
-To check whether the minor mode is enabled in the current buffer,
-evaluate `corfu-mode'.
-
-The mode's hook is called both when the mode is enabled and when
-it is disabled.
-
-\(fn &optional ARG)" t nil)
-
-(put 'global-corfu-mode 'globalized-minor-mode t)
-
-(defvar global-corfu-mode nil "\
-Non-nil if Global Corfu mode is enabled.
-See the `global-corfu-mode' command
-for a description of this minor mode.
-Setting this variable directly does not take effect;
-either customize it (see the info node `Easy Customization')
-or call the function `global-corfu-mode'.")
-
-(custom-autoload 'global-corfu-mode "corfu" nil)
-
-(autoload 'global-corfu-mode "corfu" "\
-Toggle Corfu mode in all buffers.
-With prefix ARG, enable Global Corfu mode if ARG is positive;
-otherwise, disable it.
-
-If called from Lisp, toggle the mode if ARG is `toggle'.
-Enable the mode if ARG is nil, omitted, or is a positive number.
-Disable the mode if ARG is a negative number.
-
-Corfu mode is enabled in all buffers where `corfu--on' would do it.
-
-See `corfu-mode' for more information on Corfu mode.
-
-\(fn &optional ARG)" t nil)
-
-(register-definition-prefixes "corfu" '("corfu-"))
-
-;;;***
-
-;;;### (autoloads nil "corfu-history" "corfu-history.el" (0 0 0 0))
-;;; Generated autoloads from corfu-history.el
-
-(defvar corfu-history-mode nil "\
-Non-nil if Corfu-History mode is enabled.
-See the `corfu-history-mode' command
-for a description of this minor mode.
-Setting this variable directly does not take effect;
-either customize it (see the info node `Easy Customization')
-or call the function `corfu-history-mode'.")
-
-(custom-autoload 'corfu-history-mode "corfu-history" nil)
-
-(autoload 'corfu-history-mode "corfu-history" "\
-Update Corfu history and sort completions by history.
-
-This is a minor mode. If called interactively, toggle the
-`Corfu-History mode' mode. If the prefix argument is positive,
-enable the mode, and if it is zero or negative, disable the mode.
-
-If called from Lisp, toggle the mode if ARG is `toggle'. Enable
-the mode if ARG is nil, omitted, or is a positive number.
-Disable the mode if ARG is a negative number.
-
-To check whether the minor mode is enabled in the current buffer,
-evaluate `(default-value \\='corfu-history-mode)'.
-
-The mode's hook is called both when the mode is enabled and when
-it is disabled.
-
-\(fn &optional ARG)" t nil)
-
-(register-definition-prefixes "corfu-history" '("corfu-history"))
-
-;;;***
-
-;;;### (autoloads nil "corfu-indexed" "corfu-indexed.el" (0 0 0 0))
-;;; Generated autoloads from corfu-indexed.el
-
-(defvar corfu-indexed-mode nil "\
-Non-nil if Corfu-Indexed mode is enabled.
-See the `corfu-indexed-mode' command
-for a description of this minor mode.
-Setting this variable directly does not take effect;
-either customize it (see the info node `Easy Customization')
-or call the function `corfu-indexed-mode'.")
-
-(custom-autoload 'corfu-indexed-mode "corfu-indexed" nil)
-
-(autoload 'corfu-indexed-mode "corfu-indexed" "\
-Prefix candidates with indices.
-
-This is a minor mode. If called interactively, toggle the
-`Corfu-Indexed mode' mode. If the prefix argument is positive,
-enable the mode, and if it is zero or negative, disable the mode.
-
-If called from Lisp, toggle the mode if ARG is `toggle'. Enable
-the mode if ARG is nil, omitted, or is a positive number.
-Disable the mode if ARG is a negative number.
-
-To check whether the minor mode is enabled in the current buffer,
-evaluate `(default-value \\='corfu-indexed-mode)'.
-
-The mode's hook is called both when the mode is enabled and when
-it is disabled.
-
-\(fn &optional ARG)" t nil)
-
-(register-definition-prefixes "corfu-indexed" '("corfu-indexed--"))
-
-;;;***
-
-;;;### (autoloads nil "corfu-info" "corfu-info.el" (0 0 0 0))
-;;; Generated autoloads from corfu-info.el
-
-(autoload 'corfu-info-documentation "corfu-info" "\
-Show documentation of current candidate." t nil)
-
-(autoload 'corfu-info-location "corfu-info" "\
-Show location of current candidate." t nil)
-
-(register-definition-prefixes "corfu-info" '("corfu-info--restore-on-next-command"))
-
-;;;***
-
-;;;### (autoloads nil "corfu-quick" "corfu-quick.el" (0 0 0 0))
-;;; Generated autoloads from corfu-quick.el
-
-(autoload 'corfu-quick-jump "corfu-quick" "\
-Jump to candidate using quick keys." t nil)
-
-(autoload 'corfu-quick-insert "corfu-quick" "\
-Insert candidate using quick keys." t nil)
-
-(autoload 'corfu-quick-complete "corfu-quick" "\
-Complete candidate using quick keys." t nil)
-
-(register-definition-prefixes "corfu-quick" '("corfu-quick"))
-
-;;;***
-
-;;;### (autoloads nil nil ("corfu-pkg.el") (0 0 0 0))
-
-;;;***
-
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; coding: utf-8
-;; End:
-;;; corfu-autoloads.el ends here
diff --git a/elpa/corfu-0.23/corfu-history.el b/elpa/corfu-0.23/corfu-history.el
@@ -1,101 +0,0 @@
-;;; corfu-history.el --- Sorting by history for Corfu -*- lexical-binding: t -*-
-
-;; Copyright (C) 2022 Free Software Foundation, Inc.
-
-;; Author: Daniel Mendler <mail@daniel-mendler.de>
-;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
-;; Created: 2022
-;; Version: 0.1
-;; Package-Requires: ((emacs "27.1") (corfu "0.23"))
-;; Homepage: https://github.com/minad/corfu
-
-;; This file is part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Enable `corfu-history-mode' to sort candidates by their history
-;; position. Maintain a list of recently selected candidates. In order
-;; to save the history across Emacs sessions, enable `savehist-mode' and
-;; add `corfu-history' to `savehist-additional-variables'.
-
-;;; Code:
-
-(require 'corfu)
-(eval-when-compile
- (require 'cl-lib))
-
-(defcustom corfu-history-length nil
- "Corfu history length."
- :type '(choice (const nil) integer)
- :group 'corfu)
-
-(defvar corfu-history--hash nil
- "Hash table of Corfu candidates.")
-
-(defvar corfu-history nil
- "History of Corfu candidates.")
-
-(defun corfu-history--sort-predicate (x y)
- "Sorting predicate which compares X and Y."
- (pcase-let ((`(,sx . ,hx) x)
- (`(,sy . ,hy) y))
- (or (< hx hy)
- (and (= hx hy)
- (or (< (length sx) (length sy))
- (and (= (length sx) (length sy))
- (string< sx sy)))))))
-
-(defun corfu-history--sort (candidates)
- "Sort CANDIDATES by history."
- (unless corfu-history--hash
- (setq corfu-history--hash (make-hash-table :test #'equal :size (length corfu-history)))
- (cl-loop for elem in corfu-history for index from 0 do
- (unless (gethash elem corfu-history--hash)
- (puthash elem index corfu-history--hash))))
- ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by
- ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is
- ;; shorter than 2**16 entries.
- (cl-loop for cand on candidates do
- (setcar cand (cons (car cand)
- (+ (lsh (gethash (car cand) corfu-history--hash #xFFFF) 13)
- (length (car cand))))))
- (setq candidates (sort candidates #'corfu-history--sort-predicate))
- (cl-loop for cand on candidates do (setcar cand (caar cand)))
- candidates)
-
-(defun corfu-history--insert (&rest _)
- "Advice for `corfu--insert'."
- (when (>= corfu--index 0)
- (add-to-history 'corfu-history
- (nth corfu--index corfu--candidates)
- corfu-history-length)
- (setq corfu-history--hash nil)))
-
-;;;###autoload
-(define-minor-mode corfu-history-mode
- "Update Corfu history and sort completions by history."
- :global t
- :group 'corfu
- (cond
- (corfu-history-mode
- (setq corfu-sort-function #'corfu-history--sort)
- (advice-add #'corfu--insert :before #'corfu-history--insert))
- (t
- (setq corfu-sort-function #'corfu-sort-length-alpha)
- (advice-remove #'corfu--insert #'corfu-history--insert))))
-
-(provide 'corfu-history)
-;;; corfu-history.el ends here
diff --git a/elpa/corfu-0.23/corfu-indexed.el b/elpa/corfu-0.23/corfu-indexed.el
@@ -1,100 +0,0 @@
-;;; corfu-indexed.el --- Select indexed candidates -*- lexical-binding: t -*-
-
-;; Copyright (C) 2022 Free Software Foundation, Inc.
-
-;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de>
-;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
-;; Created: 2022
-;; Version: 0.1
-;; Package-Requires: ((emacs "27.1") (corfu "0.23"))
-;; Homepage: https://github.com/minad/corfu
-
-;; This file is part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This package is a Corfu extension, which prefixes candidates with indices and
-;; allows you to select with prefix arguments. This is designed to be a faster
-;; alternative to selecting a candidate with `corfu-next' and `corfu-previous'.
-
-;;; Code:
-
-(require 'corfu)
-(eval-when-compile
- (require 'cl-lib))
-
-(defface corfu-indexed
- '((default :height 0.75)
- (((class color) (min-colors 88) (background dark))
- :foreground "#f4f4f4" :background "#323232")
- (((class color) (min-colors 88) (background light))
- :foreground "#404148" :background "#d7d7d7")
- (t :background "black"))
- "Face used for the candidate index prefix."
- :group 'corfu-faces)
-
-(defvar corfu-indexed--commands
- '(corfu-insert corfu-complete)
- "Commands that should be indexed.")
-
-(defun corfu-indexed--affixate (cands)
- "Advice for `corfu--affixate' which prefixes the CANDS with an index."
- (setq cands (cdr cands))
- (let* ((space #(" " 0 1 (face (:height 0.5 :inherit corfu-indexed))))
- (width (if (> (length cands) 10) 2 1))
- (fmt (concat space
- (propertize (format "%%%ds" width)
- 'face 'corfu-indexed)
- space))
- (align
- (propertize (make-string width ?\s)
- 'display
- `(space :align-to (+ left ,(1+ width))))))
- (cl-loop for cand in cands for index from 0 do
- (setf (cadr cand)
- (concat
- (propertize " " 'display (format fmt index))
- align
- (cadr cand))))
- (cons t cands)))
-
-(defun corfu-indexed--handle-prefix (orig &rest args)
- "Handle prefix argument before calling ORIG function with ARGS."
- (if (and current-prefix-arg (called-interactively-p t))
- (let ((corfu--index (+ corfu--scroll (prefix-numeric-value current-prefix-arg))))
- (if (or (< corfu--index 0)
- (>= corfu--index corfu--total)
- (>= corfu--index (+ corfu--scroll corfu-count)))
- (message "Out of range")
- (funcall orig)))
- (apply orig args)))
-
-;;;###autoload
-(define-minor-mode corfu-indexed-mode
- "Prefix candidates with indices."
- :global t :group 'corfu
- (cond
- (corfu-indexed-mode
- (advice-add #'corfu--affixate :filter-return #'corfu-indexed--affixate)
- (dolist (cmd corfu-indexed--commands)
- (advice-add cmd :around #'corfu-indexed--handle-prefix)))
- (t
- (advice-remove #'corfu--affixate #'corfu-indexed--affixate)
- (dolist (cmd corfu-indexed--commands)
- (advice-remove cmd #'corfu-indexed--handle-prefix)))))
-
-(provide 'corfu-indexed)
-;;; corfu-indexed.el ends here
diff --git a/elpa/corfu-0.23/corfu-info.el b/elpa/corfu-0.23/corfu-info.el
@@ -1,95 +0,0 @@
-;;; corfu-info.el --- Show candidate information in separate buffer -*- lexical-binding: t -*-
-
-;; Copyright (C) 2022 Free Software Foundation, Inc.
-
-;; Author: Daniel Mendler <mail@daniel-mendler.de>
-;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
-;; Created: 2022
-;; Version: 0.1
-;; Package-Requires: ((emacs "27.1") (corfu "0.23"))
-;; Homepage: https://github.com/minad/corfu
-
-;; This file is part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This Corfu extension provides commands to show additional information
-;; to the candidates in a separate buffer.
-
-;;; Code:
-
-(require 'corfu)
-(eval-when-compile
- (require 'subr-x))
-
-(defun corfu-info--restore-on-next-command ()
- "Restore window configuration before next command."
- (let ((config (current-window-configuration))
- (other other-window-scroll-buffer)
- (restore (make-symbol "corfu--restore")))
- (fset restore
- (lambda ()
- (setq other-window-scroll-buffer other)
- (unless (memq this-command '(scroll-other-window scroll-other-window-down))
- (when (memq this-command '(corfu-quit corfu-reset))
- (setq this-command #'ignore))
- (remove-hook 'pre-command-hook restore)
- (set-window-configuration config))))
- (add-hook 'pre-command-hook restore)))
-
-;;;###autoload
-(defun corfu-info-documentation ()
- "Show documentation of current candidate."
- (interactive)
- ;; Company support, taken from `company.el', see `company-show-doc-buffer'.
- (when (< corfu--index 0)
- (user-error "No candidate selected"))
- (if-let* ((fun (plist-get corfu--extra :company-doc-buffer))
- (res (funcall fun (nth corfu--index corfu--candidates))))
- (let ((buf (or (car-safe res) res)))
- (corfu-info--restore-on-next-command)
- (setq other-window-scroll-buffer (get-buffer buf))
- (set-window-start (display-buffer buf t) (or (cdr-safe res) (point-min))))
- (user-error "No documentation available")))
-
-;;;###autoload
-(defun corfu-info-location ()
- "Show location of current candidate."
- (interactive)
- ;; Company support, taken from `company.el', see `company-show-location'.
- (when (< corfu--index 0)
- (user-error "No candidate selected"))
- (if-let* ((fun (plist-get corfu--extra :company-location))
- (loc (funcall fun (nth corfu--index corfu--candidates))))
- (let ((buf (or (and (bufferp (car loc)) (car loc)) (find-file-noselect (car loc) t))))
- (corfu-info--restore-on-next-command)
- (setq other-window-scroll-buffer buf)
- (with-selected-window (display-buffer buf t)
- (save-restriction
- (widen)
- (if (bufferp (car loc))
- (goto-char (cdr loc))
- (goto-char (point-min))
- (forward-line (1- (cdr loc))))
- (set-window-start nil (point)))))
- (user-error "No candidate location available")))
-
-;; Emacs 28: Do not show Corfu commands with M-X
-(put #'corfu-info-location 'completion-predicate #'ignore)
-(put #'corfu-info-documentation 'completion-predicate #'ignore)
-
-(provide 'corfu-info)
-;;; corfu-info.el ends here
diff --git a/elpa/corfu-0.23/corfu-pkg.el b/elpa/corfu-0.23/corfu-pkg.el
@@ -1,2 +0,0 @@
-;; Generated package description from corfu.el -*- no-byte-compile: t -*-
-(define-package "corfu" "0.23" "Completion Overlay Region FUnction" '((emacs "27.1")) :commit "bf9bb725f70fb3165e2831c5926217bd6a8bc68d" :authors '(("Daniel Mendler" . "mail@daniel-mendler.de")) :maintainer '("Daniel Mendler" . "mail@daniel-mendler.de") :url "https://github.com/minad/corfu")
diff --git a/elpa/corfu-0.23/corfu-quick.el b/elpa/corfu-0.23/corfu-quick.el
@@ -1,154 +0,0 @@
-;;; corfu-quick.el --- Quick keys for Corfu -*- lexical-binding: t -*-
-
-;; Copyright (C) 2022 Free Software Foundation, Inc.
-
-;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de>
-;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
-;; Created: 2022
-;; Version: 0.1
-;; Package-Requires: ((emacs "27.1") (corfu "0.23"))
-;; Homepage: https://github.com/minad/corfu
-
-;; This file is part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This package is a Corfu extension, which prefixes candidates with
-;; quick keys. Typing these quick keys allows you to select the
-;; candidate in front of them. This is designed to be a faster
-;; alternative to selecting a candidate with `corfu-next' and
-;; `corfu-previous'.
-;; (define-key corfu-map "\M-q" #'corfu-quick-complete)
-;; (define-key corfu-map "\C-q" #'corfu-quick-exit)
-
-;;; Code:
-
-(require 'corfu)
-(eval-when-compile
- (require 'cl-lib))
-
-(defcustom corfu-quick1 "asdfgh"
- "First level quick keys."
- :type 'string
- :group 'corfu)
-
-(defcustom corfu-quick2 "jkl"
- "Second level quick keys."
- :type 'string
- :group 'corfu)
-
-(defface corfu-quick1
- '((((class color) (min-colors 88) (background dark))
- :background "#0050af" :foreground "white" :inherit bold)
- (((class color) (min-colors 88) (background light))
- :background "#7feaff" :foreground "black" :inherit bold)
- (t :background "blue" :foreground "white" :inherit bold))
- "Face used for the first quick key."
- :group 'corfu-faces)
-
-(defface corfu-quick2
- '((((class color) (min-colors 88) (background dark))
- :background "#7f1f7f" :foreground "white" :inherit bold)
- (((class color) (min-colors 88) (background light))
- :background "#ffaaff" :foreground "black" :inherit bold)
- (t :background "magenta" :foreground "white" :inherit bold))
- "Face used for the second quick key."
- :group 'corfu-faces)
-
-(defun corfu-quick--keys (two idx) ;; See vertico-quick--keys
- "Format quick keys prefix.
-IDX is the current candidate index.
-TWO is non-nil if two keys should be displayed."
- (let* ((fst (length corfu-quick1))
- (snd (length corfu-quick2))
- (len (+ fst snd)))
- (if (>= idx fst)
- (let ((first (elt corfu-quick2 (mod (/ (- idx fst) len) snd)))
- (second (elt (concat corfu-quick1 corfu-quick2) (mod (- idx fst) len))))
- (cond
- ((eq first two)
- (list
- (concat " " (propertize (char-to-string second) 'face 'corfu-quick1))
- (cons second (+ corfu--scroll idx))))
- (two
- (list " "))
- (t
- (list
- (concat (propertize (char-to-string first) 'face 'corfu-quick1)
- (propertize (char-to-string second) 'face 'corfu-quick2))
- (cons first (list first))))))
- (let ((first (elt corfu-quick1 (mod idx fst))))
- (if two
- (list " ")
- (list
- (concat (propertize (char-to-string first) 'face 'corfu-quick1) " ")
- (cons first (+ corfu--scroll idx))))))))
-
-(defun corfu-quick--read (&optional first)
- "Read quick key given FIRST pressed key."
- (cl-letf* ((list nil)
- (space1 (propertize " " 'display
- `(space :width
- (+ 0.5 (,(alist-get
- 'child-frame-border-width
- corfu--frame-parameters))))))
- (space2 #(" " 0 1 (display (space :width 0.5))))
- (orig (symbol-function #'corfu--affixate))
- ((symbol-function #'corfu--affixate)
- (lambda (cands)
- (setq cands (cdr (funcall orig cands)))
- (cl-loop for cand in cands for index from 0 do
- (pcase-let ((`(,keys . ,events) (corfu-quick--keys first index)))
- (setq list (nconc events list))
- (setf (cadr cand) (concat space1 (propertize " " 'display keys) space2))))
- (cons t cands)))
- ;; Increase minimum width to avoid odd jumping
- (corfu-min-width (+ 3 corfu-min-width)))
- (corfu--candidates-popup (car completion-in-region--data))
- (alist-get (read-key) list)))
-
-;;;###autoload
-(defun corfu-quick-jump ()
- "Jump to candidate using quick keys."
- (interactive)
- (setq corfu--echo-message "")
- (corfu--echo-refresh)
- (if (= corfu--total 0)
- (and (message "No match") nil)
- (let ((idx (corfu-quick--read)))
- (when (consp idx) (setq idx (corfu-quick--read (car idx))))
- (when idx (setq corfu--index idx)))))
-
-;;;###autoload
-(defun corfu-quick-insert ()
- "Insert candidate using quick keys."
- (interactive)
- (when (corfu-quick-jump)
- (corfu-insert)))
-
-;;;###autoload
-(defun corfu-quick-complete ()
- "Complete candidate using quick keys."
- (interactive)
- (when (corfu-quick-jump)
- (corfu-complete)))
-
-;; Emacs 28: Do not show Corfu commands in M-X
-(dolist (sym '(corfu-quick-jump corfu-quick-insert corfu-quick-complete))
- (put sym 'completion-predicate #'ignore))
-
-(provide 'corfu-quick)
-;;; corfu-quick.el ends here
diff --git a/elpa/corfu-0.23/corfu.el b/elpa/corfu-0.23/corfu.el
@@ -1,1271 +0,0 @@
-;;; corfu.el --- Completion Overlay Region FUnction -*- lexical-binding: t -*-
-
-;; Copyright (C) 2021, 2022 Free Software Foundation, Inc.
-
-;; Author: Daniel Mendler <mail@daniel-mendler.de>
-;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
-;; Created: 2021
-;; Version: 0.23
-;; Package-Requires: ((emacs "27.1"))
-;; Homepage: https://github.com/minad/corfu
-
-;; This file is part of GNU Emacs.
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Corfu enhances the default completion in region function with a
-;; completion overlay. The current candidates are shown in a popup
-;; below or above the point. Corfu can be considered the minimalistic
-;; completion-in-region counterpart of Vertico.
-
-;;; Code:
-
-(require 'seq)
-(eval-when-compile
- (require 'cl-lib)
- (require 'subr-x))
-
-(defgroup corfu nil
- "Completion Overlay Region FUnction."
- :group 'convenience
- :prefix "corfu-")
-
-(defcustom corfu-count 10
- "Maximal number of candidates to show."
- :type 'integer)
-
-(defcustom corfu-scroll-margin 2
- "Number of lines at the top and bottom when scrolling.
-The value should lie between 0 and corfu-count/2."
- :type 'integer)
-
-(defcustom corfu-min-width 15
- "Popup minimum width in characters."
- :type 'integer)
-
-(defcustom corfu-max-width 100
- "Popup maximum width in characters."
- :type 'integer)
-
-(defcustom corfu-cycle nil
- "Enable cycling for `corfu-next' and `corfu-previous'."
- :type 'boolean)
-
-(defcustom corfu-on-exact-match 'insert
- "Configure how a single exact match should be handled."
- :type '(choice (const insert) (const quit) (const nil)))
-
-(defcustom corfu-continue-commands
- ;; nil is undefined command
- '(nil ignore universal-argument universal-argument-more digit-argument
- "\\`corfu-" "\\`scroll-other-window")
- "Continue Corfu completion after executing these commands."
- :type '(repeat (choice regexp symbol)))
-
-(defcustom corfu-preview-current 'insert
- "Preview currently selected candidate.
-If the variable has the value `insert', the candidate is automatically
-inserted on further input."
- :type '(choice boolean (const insert)))
-
-(defcustom corfu-preselect-first t
- "Preselect first candidate."
- :type 'boolean)
-
-(defcustom corfu-separator ?\s
- "Component separator character.
-The character used for separating components in the input. The presence
-of this separator character will inhibit quitting at completion
-boundaries, so that any further characters can be entered. To enter the
-first separator character, call `corfu-insert-separator' (bound to M-SPC
-by default). Useful for multi-component completion styles such as
-Orderless."
- :type 'character)
-
-(defcustom corfu-quit-at-boundary 'separator
- "Automatically quit at completion boundary.
-nil: Never quit at completion boundary.
-t: Always quit at completion boundary.
-separator: Quit at boundary if no `corfu-separator' has been inserted."
- :type '(choice boolean (const separator)))
-
-(defcustom corfu-quit-no-match 'separator
- "Automatically quit if no matching candidate is found.
-nil: Stay alive even if there is no match.
-t: Quit if there is no match.
-separator: Only stay alive if there is no match and
-`corfu-separator' has been inserted."
- :type '(choice boolean (const separator)))
-
-(defcustom corfu-excluded-modes nil
- "List of modes excluded by `global-corfu-mode'."
- :type '(repeat symbol))
-
-(defcustom corfu-left-margin-width 0.5
- "Width of the left margin in units of the character width."
- :type 'float)
-
-(defcustom corfu-right-margin-width 0.5
- "Width of the right margin in units of the character width."
- :type 'float)
-
-(defcustom corfu-bar-width 0.2
- "Width of the bar in units of the character width."
- :type 'float)
-
-(defcustom corfu-echo-documentation '(1.0 . 0.2)
- "Show documentation string in the echo area after that number of seconds.
-Set to nil to disable the echo message or to t for an instant message.
-The value can be a pair of two floats to specify initial and subsequent
-delay."
- :type '(choice (const :tag "Never" nil)
- (const :tag "Instant" t)
- (number :tag "Delay in seconds")
- (cons :tag "Two Delays"
- (choice :tag "Initial " number))
- (choice :tag "Subsequent" number)))
-
-(defcustom corfu-margin-formatters nil
- "Registry for margin formatter functions.
-Each function of the list is called with the completion metadata as
-argument until an appropriate formatter is found. The function should
-return a formatter function, which takes the candidate string and must
-return a string, possibly an icon."
- :type 'hook)
-
-(defcustom corfu-sort-function #'corfu-sort-length-alpha
- "Default sorting function, used if no `display-sort-function' is specified."
- :type `(choice
- (const :tag "No sorting" nil)
- (const :tag "By length and alpha" ,#'corfu-sort-length-alpha)
- (function :tag "Custom function")))
-
-(defcustom corfu-sort-override-function nil
- "Override sort function which overrides the `display-sort-function'."
- :type '(choice (const nil) function))
-
-(defcustom corfu-auto-prefix 3
- "Minimum length of prefix for auto completion.
-The completion backend can override this with
-:company-prefix-length."
- :type 'integer)
-
-(defcustom corfu-auto-delay 0.2
- "Delay for auto completion."
- :type 'float)
-
-(defcustom corfu-auto-commands
- '("self-insert-command\\'"
- c-electric-colon c-electric-lt-gt c-electric-slash c-scope-operator)
- "Commands which initiate auto completion."
- :type '(repeat (choice regexp symbol)))
-
-(defcustom corfu-auto nil
- "Enable auto completion."
- :type 'boolean)
-
-(defgroup corfu-faces nil
- "Faces used by Corfu."
- :group 'corfu
- :group 'faces)
-
-(defface corfu-default
- '((((class color) (min-colors 88) (background dark)) :background "#191a1b")
- (((class color) (min-colors 88) (background light)) :background "#f0f0f0")
- (t :background "gray"))
- "Default face used for the popup, in particular the background
- and foreground color.")
-
-(defface corfu-current
- '((((class color) (min-colors 88) (background dark))
- :background "#00415e" :foreground "white")
- (((class color) (min-colors 88) (background light))
- :background "#c0efff" :foreground "black")
- (t :background "blue" :foreground "white"))
- "Face used to highlight the currently selected candidate.")
-
-(defface corfu-bar
- '((((class color) (min-colors 88) (background dark)) :background "#a8a8a8")
- (((class color) (min-colors 88) (background light)) :background "#505050")
- (t :background "gray"))
- "The background color is used for the scrollbar indicator.")
-
-(defface corfu-border
- '((((class color) (min-colors 88) (background dark)) :background "#323232")
- (((class color) (min-colors 88) (background light)) :background "#d7d7d7")
- (t :background "gray"))
- "The background color used for the thin border.")
-
-(defface corfu-echo
- '((t :inherit completions-annotations))
- "Face used for echo area messages.")
-
-(defface corfu-annotations
- '((t :inherit completions-annotations))
- "Face used for annotations.")
-
-(defface corfu-deprecated
- '((t :inherit shadow :strike-through t))
- "Face used for deprecated candidates.")
-
-(defvar corfu-map
- (let ((map (make-sparse-keymap)))
- (define-key map [remap beginning-of-buffer] #'corfu-first)
- (define-key map [remap end-of-buffer] #'corfu-last)
- (define-key map [remap scroll-down-command] #'corfu-scroll-down)
- (define-key map [remap scroll-up-command] #'corfu-scroll-up)
- (define-key map [remap next-line] #'corfu-next)
- (define-key map [remap previous-line] #'corfu-previous)
- (define-key map [remap completion-at-point] #'corfu-complete)
- (define-key map [down] #'corfu-next)
- (define-key map [up] #'corfu-previous)
- (define-key map [remap keyboard-escape-quit] #'corfu-reset)
- ;; XXX [tab] is bound because of org-mode
- ;; The binding should be removed from org-mode-map.
- (define-key map [tab] #'corfu-complete)
- (define-key map "\M-n" #'corfu-next)
- (define-key map "\M-p" #'corfu-previous)
- (define-key map "\C-g" #'corfu-quit)
- (define-key map "\r" #'corfu-insert)
- (define-key map "\t" #'corfu-complete)
- (define-key map "\M-g" 'corfu-info-location)
- (define-key map "\M-h" 'corfu-info-documentation)
- (define-key map "\M- " #'corfu-insert-separator)
- map)
- "Corfu keymap used when popup is shown.")
-
-(defvar corfu--auto-timer nil
- "Auto completion timer.")
-
-(defvar-local corfu--candidates nil
- "List of candidates.")
-
-(defvar-local corfu--metadata nil
- "Completion metadata.")
-
-(defvar-local corfu--base ""
- "Base string, which is concatenated with the candidate.")
-
-(defvar-local corfu--total 0
- "Length of the candidate list `corfu--candidates'.")
-
-(defvar-local corfu--highlight #'identity
- "Deferred candidate highlighting function.")
-
-(defvar-local corfu--index -1
- "Index of current candidate or negative for prompt selection.")
-
-(defvar-local corfu--preselect -1
- "Index of preselected candidate, negative for prompt selection.")
-
-(defvar-local corfu--scroll 0
- "Scroll position.")
-
-(defvar-local corfu--input nil
- "Cons of last prompt contents and point.")
-
-(defvar-local corfu--preview-ov nil
- "Current candidate overlay.")
-
-(defvar-local corfu--extra nil
- "Extra completion properties.")
-
-(defvar-local corfu--change-group nil
- "Undo change group.")
-
-(defvar-local corfu--echo-timer nil
- "Echo area message timer.")
-
-(defvar-local corfu--echo-message nil
- "Last echo message.")
-
-(defvar corfu--frame nil
- "Popup frame.")
-
-(defconst corfu--state-vars
- '(corfu--base
- corfu--candidates
- corfu--highlight
- corfu--index
- corfu--preselect
- corfu--scroll
- corfu--input
- corfu--total
- corfu--preview-ov
- corfu--extra
- corfu--echo-timer
- corfu--echo-message
- corfu--change-group
- corfu--metadata)
- "Buffer-local state variables used by Corfu.")
-
-(defvar corfu--frame-parameters
- '((no-accept-focus . t)
- (no-focus-on-map . t)
- (min-width . t)
- (min-height . t)
- (width . 0)
- (height . 0)
- (border-width . 0)
- (child-frame-border-width . 1)
- (left-fringe . 0)
- (right-fringe . 0)
- (vertical-scroll-bars . nil)
- (horizontal-scroll-bars . nil)
- (menu-bar-lines . 0)
- (tool-bar-lines . 0)
- (tab-bar-lines . 0)
- (no-other-frame . t)
- (no-other-window . t)
- (no-delete-other-windows . t)
- (unsplittable . t)
- (undecorated . t)
- (cursor-type . nil)
- (visibility . nil)
- (no-special-glyphs . t)
- (desktop-dont-save . t))
- "Default child frame parameters.")
-
-(defvar corfu--buffer-parameters
- '((mode-line-format . nil)
- (header-line-format . nil)
- (tab-line-format . nil)
- (tab-bar-format . nil) ;; Emacs 28 tab-bar-format
- (frame-title-format . "")
- (truncate-lines . t)
- (cursor-in-non-selected-windows . nil)
- (cursor-type . nil)
- (show-trailing-whitespace . nil)
- (display-line-numbers . nil)
- (left-fringe-width . nil)
- (right-fringe-width . nil)
- (left-margin-width . 0)
- (right-margin-width . 0)
- (fringes-outside-margins . 0)
- (buffer-read-only . t))
- "Default child frame buffer parameters.")
-
-(defvar corfu--mouse-ignore-map
- (let ((map (make-sparse-keymap)))
- (dotimes (i 7)
- (dolist (k '(mouse down-mouse drag-mouse double-mouse triple-mouse))
- (define-key map (vector (intern (format "%s-%s" k (1+ i)))) #'ignore)))
- map)
- "Ignore all mouse clicks.")
-
-(defun corfu--popup-redirect-focus ()
- "Redirect focus from popup."
- (redirect-frame-focus corfu--frame (frame-parent corfu--frame)))
-
-(defun corfu--make-buffer (content)
- "Create corfu buffer with CONTENT."
- (let ((fr face-remapping-alist)
- (ls line-spacing)
- (buffer (get-buffer-create " *corfu*")))
- (with-current-buffer buffer
- ;;; XXX HACK install redirect focus hook
- (add-hook 'pre-command-hook #'corfu--popup-redirect-focus nil 'local)
- ;;; XXX HACK install mouse ignore map
- (use-local-map corfu--mouse-ignore-map)
- (dolist (var corfu--buffer-parameters)
- (set (make-local-variable (car var)) (cdr var)))
- (setq-local face-remapping-alist (copy-tree fr)
- line-spacing ls)
- (cl-pushnew 'corfu-default (alist-get 'default face-remapping-alist))
- (let ((inhibit-modification-hooks t)
- (inhibit-read-only t))
- (erase-buffer)
- (insert content)
- (goto-char (point-min))))
- buffer))
-
-;; Function adapted from posframe.el by tumashu
-(defvar x-gtk-resize-child-frames) ;; Not present on non-gtk builds
-(defun corfu--make-frame (x y width height content)
- "Show child frame at X/Y with WIDTH/HEIGHT and CONTENT."
- (let* ((window-min-height 1)
- (window-min-width 1)
- (x-gtk-resize-child-frames
- (let ((case-fold-search t))
- (and
- ;; XXX HACK to fix resizing on gtk3/gnome taken from posframe.el
- ;; More information:
- ;; * https://github.com/minad/corfu/issues/17
- ;; * https://gitlab.gnome.org/GNOME/mutter/-/issues/840
- ;; * https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00001.html
- (string-match-p "gtk3" system-configuration-features)
- (string-match-p "gnome\\|cinnamon"
- (or (getenv "XDG_CURRENT_DESKTOP")
- (getenv "DESKTOP_SESSION") ""))
- 'resize-mode)))
- (after-make-frame-functions)
- (edge (window-inside-pixel-edges))
- (ch (default-line-height))
- (border (alist-get 'child-frame-border-width corfu--frame-parameters))
- (x (max border (min (+ (car edge) x (- border))
- (- (frame-pixel-width) width))))
- (yb (+ (cadr edge) (window-tab-line-height) y ch))
- (y (if (> (+ yb (* corfu-count ch) ch ch) (frame-pixel-height))
- (- yb height ch 1)
- yb))
- (buffer (corfu--make-buffer content)))
- (unless (and (frame-live-p corfu--frame)
- (eq (frame-parent corfu--frame) (window-frame)))
- (when corfu--frame (delete-frame corfu--frame))
- (setq corfu--frame (make-frame
- `((parent-frame . ,(window-frame))
- (minibuffer . ,(minibuffer-window (window-frame)))
- ;; Set `internal-border-width' for Emacs 27
- (internal-border-width . ,border)
- ,@corfu--frame-parameters))))
- ;; XXX HACK Setting the same frame-parameter/face-background is not a nop.
- ;; Check explicitly before applying the setting. Without the check, the
- ;; frame flickers on Mac.
- ;; XXX HACK We have to apply the face background before adjusting the frame
- ;; parameter, otherwise the border is not updated (BUG!).
- (let* ((face (if (facep 'child-frame-border) 'child-frame-border 'internal-border))
- (new (face-attribute 'corfu-border :background nil 'default)))
- (unless (equal (face-attribute face :background corfu--frame 'default) new)
- (set-face-background face new corfu--frame)))
- (let ((new (face-attribute 'corfu-default :background nil 'default)))
- (unless (equal (frame-parameter corfu--frame 'background-color) new)
- (set-frame-parameter corfu--frame 'background-color new)))
- (let ((win (frame-root-window corfu--frame)))
- (set-window-buffer win buffer)
- ;; Mark window as dedicated to prevent frame reuse (#60)
- (set-window-dedicated-p win t))
- (set-frame-size corfu--frame width height t)
- (if (frame-visible-p corfu--frame)
- ;; XXX HACK Avoid flicker when frame is already visible.
- ;; Redisplay, wait for resize and then move the frame.
- (unless (equal (frame-position corfu--frame) (cons x y))
- (redisplay 'force)
- (sleep-for 0.01)
- (set-frame-position corfu--frame x y))
- ;; XXX HACK: Force redisplay, otherwise the popup sometimes does not
- ;; display content.
- (set-frame-position corfu--frame x y)
- (redisplay 'force)
- (make-frame-visible corfu--frame))))
-
-(defun corfu--popup-show (pos off width lines &optional curr lo bar)
- "Show LINES as popup at POS - OFF.
-WIDTH is the width of the popup.
-The current candidate CURR is highlighted.
-A scroll bar is displayed from LO to LO+BAR."
- (let* ((ch (default-line-height))
- (cw (default-font-width))
- (ml (ceiling (* cw corfu-left-margin-width)))
- (mr (ceiling (* cw corfu-right-margin-width)))
- (bw (ceiling (min mr (* cw corfu-bar-width))))
- (marginl (and (> ml 0) (propertize " " 'display `(space :width (,ml)))))
- (marginr (and (> mr 0) (propertize " " 'display `(space :align-to right))))
- (sbar (when (> bw 0)
- (concat (propertize " " 'display `(space :align-to (- right (,mr))))
- (propertize " " 'display `(space :width (,(- mr bw))))
- (propertize " " 'face 'corfu-bar 'display `(space :width (,bw))))))
- (row 0)
- (pos (posn-x-y (posn-at-point pos)))
- (x (or (car pos) 0))
- (y (or (cdr pos) 0)))
- (corfu--make-frame
- (- x ml (* cw off)) y
- (+ (* width cw) ml mr) (* (length lines) ch)
- (mapconcat (lambda (line)
- (let ((str (concat marginl line
- (if (and lo (<= lo row (+ lo bar))) sbar marginr))))
- (when (eq row curr)
- (add-face-text-property
- 0 (length str) 'corfu-current 'append str))
- (setq row (1+ row))
- str))
- lines "\n"))))
-
-(defun corfu--popup-hide ()
- "Hide Corfu popup."
- (when (frame-live-p corfu--frame)
- (make-frame-invisible corfu--frame)
- (with-current-buffer (window-buffer (frame-root-window corfu--frame))
- (let ((inhibit-read-only t))
- (erase-buffer)))))
-
-(defun corfu--move-to-front (elem list)
- "Move ELEM to front of LIST."
- (if-let (found (member elem list))
- (let ((head (list (car found))))
- (nconc head (delq (setcar found nil) list)))
- list))
-
-;; bug#47711: Deferred highlighting for `completion-all-completions'
-;; XXX There is one complication: `completion--twq-all' already adds
-;; `completions-common-part'.
-(defun corfu--all-completions (&rest args)
- "Compute all completions for ARGS with deferred highlighting."
- (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality))
- (orig-flex (symbol-function #'completion-flex-all-completions))
- ((symbol-function #'completion-flex-all-completions)
- (lambda (&rest args)
- ;; Unfortunately for flex we have to undo the deferred
- ;; highlighting, since flex uses the completion-score for
- ;; sorting, which is applied during highlighting.
- (cl-letf (((symbol-function #'completion-pcm--hilit-commonality) orig-pcm))
- (apply orig-flex args))))
- ;; Defer the following highlighting functions
- (hl #'identity)
- ((symbol-function #'completion-hilit-commonality)
- (lambda (cands prefix &optional base)
- (setq hl (lambda (x) (nconc (completion-hilit-commonality x prefix base) nil)))
- (and cands (nconc cands base))))
- ((symbol-function #'completion-pcm--hilit-commonality)
- (lambda (pattern cands)
- (setq hl (lambda (x)
- ;; `completion-pcm--hilit-commonality' sometimes
- ;; throws an internal error for example when entering
- ;; "/sudo:://u".
- (condition-case nil
- (completion-pcm--hilit-commonality pattern x)
- (t x))))
- cands)))
- ;; Only advise orderless after it has been loaded to avoid load order issues
- (if (and (fboundp 'orderless-highlight-matches)
- (fboundp 'orderless-pattern-compiler))
- (cl-letf (((symbol-function 'orderless-highlight-matches)
- (lambda (pattern cands)
- (let ((regexps (orderless-pattern-compiler pattern)))
- (setq hl (lambda (x) (orderless-highlight-matches regexps x))))
- cands)))
- (cons (apply #'completion-all-completions args) hl))
- (cons (apply #'completion-all-completions args) hl))))
-
-(defun corfu--sort-predicate (x y)
- "Sorting predicate which compares X and Y."
- (or (< (length x) (length y)) (and (= (length x) (length y)) (string< x y))))
-
-(defun corfu-sort-length-alpha (list)
- "Sort LIST by length and alphabetically."
- (sort list #'corfu--sort-predicate))
-
-(defmacro corfu--partition! (list form)
- "Evaluate FORM for every element and partition LIST."
- (let ((head1 (make-symbol "head1"))
- (head2 (make-symbol "head2"))
- (tail1 (make-symbol "tail1"))
- (tail2 (make-symbol "tail2")))
- `(let* ((,head1 (cons nil nil))
- (,head2 (cons nil nil))
- (,tail1 ,head1)
- (,tail2 ,head2))
- (while ,list
- (if (let ((it (car ,list))) ,form)
- (progn
- (setcdr ,tail1 ,list)
- (pop ,tail1))
- (setcdr ,tail2 ,list)
- (pop ,tail2))
- (pop ,list))
- (setcdr ,tail1 (cdr ,head2))
- (setcdr ,tail2 nil)
- (setq ,list (cdr ,head1)))))
-
-(defun corfu--move-prefix-candidates-to-front (field candidates)
- "Move CANDIDATES which match prefix of FIELD to the beginning."
- (let* ((word (substring field 0
- (seq-position field corfu-separator)))
- (len (length word)))
- (corfu--partition!
- candidates
- (and (>= (length it) len)
- (eq t (compare-strings word 0 len it 0 len
- completion-ignore-case))))))
-
-(defun corfu--filter-files (files)
- "Filter FILES by `completion-ignored-extensions'."
- (let ((re (concat "\\(?:\\(?:\\`\\|/\\)\\.\\.?/\\|"
- (regexp-opt completion-ignored-extensions)
- "\\)\\'")))
- (or (seq-remove (lambda (x) (string-match-p re x)) files) files)))
-
-(defun corfu--sort-function ()
- "Return the sorting function."
- (or corfu-sort-override-function
- (corfu--metadata-get 'display-sort-function)
- corfu-sort-function))
-
-(defun corfu--recompute-candidates (str pt table pred)
- "Recompute candidates from STR, PT, TABLE and PRED."
- (pcase-let* ((before (substring str 0 pt))
- (after (substring str pt))
- (corfu--metadata (completion-metadata before table pred))
- ;; bug#47678: `completion-boundaries` fails for `partial-completion`
- ;; if the cursor is moved between the slashes of "~//".
- ;; See also vertico.el which has the same issue.
- (bounds (or (condition-case nil
- (completion-boundaries before table pred after)
- (t (cons 0 (length after))))))
- (field (substring str (car bounds) (+ pt (cdr bounds))))
- (completing-file (eq (corfu--metadata-get 'category) 'file))
- (`(,all . ,hl) (corfu--all-completions str table pred pt corfu--metadata))
- (base (or (when-let (z (last all)) (prog1 (cdr z) (setcdr z nil))) 0))
- (corfu--base (substring str 0 base)))
- ;; Filter the ignored file extensions. We cannot use modified predicate for
- ;; this filtering, since this breaks the special casing in the
- ;; `completion-file-name-table' for `file-exists-p' and `file-directory-p'.
- (when completing-file (setq all (corfu--filter-files all)))
- (setq all (delete-consecutive-dups (funcall (or (corfu--sort-function) #'identity) all)))
- (setq all (corfu--move-prefix-candidates-to-front field all))
- (when (and completing-file (not (string-suffix-p "/" field)))
- (setq all (corfu--move-to-front (concat field "/") all)))
- (setq all (corfu--move-to-front field all))
- (list corfu--base all (length all) hl corfu--metadata
- ;; Select the prompt when the input is a valid completion
- ;; and if it is not equal to the first candidate.
- (if (or (not corfu-preselect-first) (not all)
- (and (not (equal field (car all)))
- (not (and completing-file (equal (concat field "/") (car all))))
- (test-completion str table pred)))
- -1 0))))
-
-(defun corfu--update-candidates (str pt table pred)
- "Update candidates from STR, PT, TABLE and PRED."
- ;; Redisplay such that the input becomes immediately visible before the
- ;; expensive candidate recomputation is performed (Issue #48). See also
- ;; corresponding vertico#89.
- (redisplay)
- (pcase (while-no-input (corfu--recompute-candidates str pt table pred))
- ('nil (keyboard-quit))
- (`(,base ,candidates ,total ,hl ,metadata ,preselect)
- (setq corfu--input (cons str pt)
- corfu--candidates candidates
- corfu--base base
- corfu--total total
- corfu--preselect preselect
- corfu--index preselect
- corfu--highlight hl
- corfu--metadata metadata))))
-
-(defun corfu--match-symbol-p (pattern sym)
- "Return non-nil if SYM is matching an element of the PATTERN list."
- (and (symbolp sym)
- (cl-loop for x in pattern
- thereis (if (symbolp x)
- (eq sym x)
- (string-match-p x (symbol-name sym))))))
-
-(defun corfu-quit ()
- "Quit Corfu completion."
- (interactive)
- (completion-in-region-mode -1))
-
-(defun corfu-reset ()
- "Reset Corfu completion.
-This command can be executed multiple times by hammering the ESC key. If a
-candidate is selected, unselect the candidate. Otherwise reset the input. If
-there hasn't been any input, then quit."
- (interactive)
- (if (/= corfu--index corfu--preselect)
- (progn
- (corfu--goto -1)
- (setq this-command #'corfu-first))
- ;; Cancel all changes and start new change group.
- (cancel-change-group corfu--change-group)
- (activate-change-group (setq corfu--change-group (prepare-change-group)))
- (when (eq last-command #'corfu-reset) (corfu-quit))))
-
-(defun corfu--affixate (cands)
- "Annotate CANDS with annotation function."
- (setq cands
- (if-let (aff (or (corfu--metadata-get 'affixation-function)
- (plist-get corfu--extra :affixation-function)))
- (funcall aff cands)
- (if-let (ann (or (corfu--metadata-get 'annotation-function)
- (plist-get corfu--extra :annotation-function)))
- (cl-loop for cand in cands collect
- (let ((suffix (or (funcall ann cand) "")))
- ;; The default completion UI adds the
- ;; `completions-annotations' face if no other faces are
- ;; present. We use a custom `corfu-annotations' face to
- ;; allow further styling which fits better for popups.
- (unless (text-property-not-all 0 (length suffix) 'face nil suffix)
- (setq suffix (propertize suffix 'face 'corfu-annotations)))
- (list cand "" suffix)))
- (cl-loop for cand in cands collect (list cand "" "")))))
- (let* ((dep (plist-get corfu--extra :company-deprecated))
- (completion-extra-properties corfu--extra)
- (mf (run-hook-with-args-until-success 'corfu-margin-formatters corfu--metadata)))
- (cl-loop for x in cands for (c . _) = x do
- (when mf
- (setf (cadr x) (funcall mf c)))
- (when (and dep (funcall dep c))
- (setcar x (setq c (substring c)))
- (add-face-text-property 0 (length c) 'corfu-deprecated 'append c)))
- (cons mf cands)))
-
-(defun corfu--metadata-get (prop)
- "Return PROP from completion metadata."
- ;; Note: Do not use `completion-metadata-get' in order to avoid Marginalia.
- ;; The Marginalia annotators are too heavy for the Corfu popup!
- (cdr (assq prop corfu--metadata)))
-
-(defun corfu--format-candidates (cands)
- "Format annotated CANDS."
- (setq cands
- (cl-loop for c in cands collect
- (cl-loop for s in c collect
- (replace-regexp-in-string "[ \t]*\n[ \t]*" " " s))))
- (let* ((cw (cl-loop for x in cands maximize (string-width (car x))))
- (pw (cl-loop for x in cands maximize (string-width (cadr x))))
- (sw (cl-loop for x in cands maximize (string-width (caddr x))))
- (width (+ pw cw sw))
- ;; -4 because of margins and some additional safety
- (max-width (min corfu-max-width (- (frame-width) 4))))
- (when (> width max-width)
- (setq sw (max 0 (- max-width pw cw))
- width (+ pw cw sw)))
- (when (< width corfu-min-width)
- (setq cw (+ cw (- corfu-min-width width))
- width corfu-min-width))
- (setq width (min width max-width))
- (list pw width
- (cl-loop for (cand prefix suffix) in cands collect
- (truncate-string-to-width
- (concat prefix
- (make-string (max 0 (- pw (string-width prefix))) ?\s)
- cand
- (when (/= sw 0)
- (make-string
- (+ (max 0 (- cw (string-width cand)))
- (max 0 (- sw (string-width suffix))))
- ?\s))
- suffix)
- width)))))
-
-(defun corfu--update-scroll ()
- "Update scroll position."
- (let ((off (max (min corfu-scroll-margin (/ corfu-count 2)) 0))
- (corr (if (= corfu-scroll-margin (/ corfu-count 2)) (1- (mod corfu-count 2)) 0)))
- (setq corfu--scroll (min (max 0 (- corfu--total corfu-count))
- (max 0 (+ corfu--index off 1 (- corfu-count))
- (min (- corfu--index off corr) corfu--scroll))))))
-
-(defun corfu--candidates-popup (pos)
- "Show candidates popup at POS."
- (corfu--update-scroll)
- (pcase-let* ((last (min (+ corfu--scroll corfu-count) corfu--total))
- (bar (ceiling (* corfu-count corfu-count) corfu--total))
- (lo (min (- corfu-count bar 1) (floor (* corfu-count corfu--scroll) corfu--total)))
- (`(,mf . ,acands) (corfu--affixate (funcall corfu--highlight
- (seq-subseq corfu--candidates corfu--scroll last))))
- (`(,pw ,width ,fcands) (corfu--format-candidates acands))
- ;; Disable the left margin if a margin formatter is active.
- (corfu-left-margin-width (if mf 0 corfu-left-margin-width)))
- ;; Nonlinearity at the end and the beginning
- (when (/= corfu--scroll 0)
- (setq lo (max 1 lo)))
- (when (/= last corfu--total)
- (setq lo (min (- corfu-count bar 2) lo)))
- (corfu--popup-show (+ pos (length corfu--base)) pw width fcands (- corfu--index corfu--scroll)
- (and (> corfu--total corfu-count) lo) bar)))
-
-(defun corfu--preview-current (beg end)
- "Show current candidate as overlay given BEG and END."
- (when-let (cand (and corfu-preview-current (>= corfu--index 0)
- (/= corfu--index corfu--preselect)
- (nth corfu--index corfu--candidates)))
- (setq corfu--preview-ov (make-overlay beg end nil t t))
- (overlay-put corfu--preview-ov 'priority 1000)
- (overlay-put corfu--preview-ov 'window (selected-window))
- (overlay-put corfu--preview-ov
- (if (= beg end) 'after-string 'display)
- (concat corfu--base cand))))
-
-(defun corfu--echo-refresh ()
- "Refresh echo message to prevent flicker during redisplay."
- (when corfu--echo-timer
- (cancel-timer corfu--echo-timer)
- (setq corfu--echo-timer nil))
- (corfu--echo-show corfu--echo-message))
-
-(defun corfu--echo-show (&optional msg)
- "Show MSG in echo area."
- (when (or msg corfu--echo-message)
- (setq msg (or msg "")
- corfu--echo-message msg)
- (corfu--message "%s" (if (text-property-not-all 0 (length msg) 'face nil msg)
- msg
- (propertize msg 'face 'corfu-echo)))))
-
-(defun corfu--echo-documentation ()
- "Show documentation string of current candidate in echo area."
- (if-let* ((delay (if (consp corfu-echo-documentation)
- (funcall (if corfu--echo-message #'cdr #'car)
- corfu-echo-documentation)
- corfu-echo-documentation))
- (fun (plist-get corfu--extra :company-docsig))
- (cand (and (>= corfu--index 0)
- (nth corfu--index corfu--candidates))))
- (if (or (eq delay t) (<= delay 0))
- (corfu--echo-show (funcall fun cand))
- (when corfu--echo-timer (cancel-timer corfu--echo-timer))
- (setq corfu--echo-timer
- (run-at-time delay nil
- (lambda ()
- (corfu--echo-show (funcall fun cand)))))
- (corfu--echo-show))
- (corfu--echo-show)))
-
-(defun corfu--update ()
- "Refresh Corfu UI."
- (pcase-let* ((`(,beg ,end ,table ,pred) completion-in-region--data)
- (pt (- (point) beg))
- (str (buffer-substring-no-properties beg end))
- (initializing (not corfu--input)))
- (corfu--echo-refresh)
- (cond
- ;; XXX Guard against errors during candidate generation.
- ;; Turn off completion immediately if there are errors
- ;; For example dabbrev throws error "No dynamic expansion ... found".
- ;; TODO Report this as a bug? Are completion tables supposed to throw errors?
- ((condition-case err
- ;; Only recompute when input changed
- (unless (equal corfu--input (cons str pt))
- (corfu--update-candidates str pt table pred)
- nil)
- (error (corfu-quit)
- (message "Corfu completion error: %s" (error-message-string err)))))
- ;; 1) Initializing, no candidates => Quit. Happens during auto completion.
- ((and initializing (not corfu--candidates))
- (corfu-quit))
- ;; 2) Single exactly matching candidate and no further completion is possible.
- ((and (not (equal str ""))
- (equal (car corfu--candidates) str) (not (cdr corfu--candidates))
- (not (consp (completion-try-completion str table pred pt corfu--metadata)))
- (or initializing corfu-on-exact-match))
- ;; Quit directly when initializing. This happens during auto completion.
- (if (or initializing (eq corfu-on-exact-match 'quit))
- (corfu-quit)
- (corfu--done str 'finished)))
- ;; 3) There exist candidates => Show candidates popup.
- (corfu--candidates
- (corfu--candidates-popup beg)
- (corfu--preview-current beg end)
- (corfu--echo-documentation)
- (redisplay 'force)) ;; XXX HACK Ensure that popup is redisplayed
- ;; 4) There are no candidates & corfu-quit-no-match => Confirmation popup.
- ((and (not corfu--candidates)
- (pcase-exhaustive corfu-quit-no-match
- ('t nil)
- ('nil t)
- ('separator (seq-contains-p (car corfu--input) corfu-separator))))
- (corfu--popup-show beg 0 8 '(#("No match" 0 8 (face italic))))
- (redisplay 'force)) ;; XXX HACK Ensure that popup is redisplayed
- (t (corfu-quit)))))
-
-(defun corfu--pre-command ()
- "Insert selected candidate unless command is marked to continue completion."
- (when corfu--preview-ov
- (delete-overlay corfu--preview-ov)
- (setq corfu--preview-ov nil))
- (when (and (eq corfu-preview-current 'insert)
- (/= corfu--index corfu--preselect)
- ;; See the comment about `overriding-local-map' in `corfu--post-command'.
- (not (or overriding-terminal-local-map
- (corfu--match-symbol-p corfu-continue-commands this-command))))
- (corfu--insert 'exact)))
-
-(defun corfu-insert-separator ()
- "Insert a separator character, inhibiting quit on completion boundary.
-See `corfu-separator' for more details."
- (interactive)
- (insert corfu-separator))
-
-(defun corfu--post-command ()
- "Refresh Corfu after last command."
- (or (pcase completion-in-region--data
- (`(,beg ,end . ,_)
- (when (let ((pt (point)))
- (and (eq (marker-buffer beg) (current-buffer))
- ;; Check ranges
- (<= beg pt end)
- (save-excursion
- (goto-char beg)
- (let ((inhibit-field-text-motion t))
- (<= (line-beginning-position) pt (line-end-position))))
- (or
- ;; TODO We keep alive Corfu if a `overriding-terminal-local-map' is
- ;; installed, for example the `universal-argument-map'. It would be good to
- ;; think about a better criterion instead. Unfortunately relying on
- ;; `this-command' alone is not sufficient, since the value of `this-command'
- ;; gets clobbered in the case of transient keymaps.
- overriding-terminal-local-map
- ;; Check if it is an explicitly listed continue command
- (corfu--match-symbol-p corfu-continue-commands this-command)
- (and
- ;; Check for empty input
- (or (not corfu--input) (< beg end))
- ;; Check separator or predicate
- (or (not corfu-quit-at-boundary)
- (and (eq corfu-quit-at-boundary 'separator)
- (or (eq this-command #'corfu-insert-separator)
- ;; with separator, any further chars allowed
- (seq-contains-p (car corfu--input) corfu-separator)))
- (funcall completion-in-region-mode--predicate))))))
- (corfu--update)
- t)))
- (corfu-quit)))
-
-(defun corfu--goto (index)
- "Go to candidate with INDEX."
- (setq corfu--index (max corfu--preselect (min index (1- corfu--total)))))
-
-(defun corfu-next (&optional n)
- "Go forward N candidates."
- (interactive "p")
- (let ((index (+ corfu--index (or n 1))))
- (corfu--goto
- (cond
- ((not corfu-cycle) index)
- ((= corfu--total 0) -1)
- ((< corfu--preselect 0) (1- (mod (1+ index) (1+ corfu--total))))
- (t (mod index corfu--total))))))
-
-(defun corfu-previous (&optional n)
- "Go backward N candidates."
- (interactive "p")
- (corfu-next (- (or n 1))))
-
-(defun corfu-scroll-down (&optional n)
- "Go back by N pages."
- (interactive "p")
- (corfu--goto (max 0 (- corfu--index (* (or n 1) corfu-count)))))
-
-(defun corfu-scroll-up (&optional n)
- "Go forward by N pages."
- (interactive "p")
- (corfu-scroll-down (- (or n 1))))
-
-(defun corfu-first ()
- "Go to first candidate, or to the prompt when the first candidate is selected."
- (interactive)
- (corfu--goto (if (> corfu--index 0) 0 -1)))
-
-(defun corfu-last ()
- "Go to last candidate."
- (interactive)
- (corfu--goto (1- corfu--total)))
-
-(defun corfu-complete ()
- "Try to complete current input.
-If a candidate is selected, insert it."
- (interactive)
- (pcase-let ((`(,beg ,end ,table ,pred) completion-in-region--data))
- (if (>= corfu--index 0)
- ;; Continue completion with selected candidate
- (progn
- (corfu--insert nil)
- ;; Exit with status 'finished if input is a valid match and no further
- ;; completion is possible. Furthermore treat the completion as
- ;; finished if we are at the end of a boundary, even if other longer
- ;; candidates would still match, since the user invoked `corfu-complete'
- ;; with an explicitly selected candidate!
- (let ((newstr (buffer-substring-no-properties beg end)))
- (when (and (test-completion newstr table pred)
- (or
- (not (consp (completion-try-completion
- newstr table pred (length newstr)
- (completion-metadata newstr table pred))))
- (equal (completion-boundaries newstr table pred "") '(0 . 0))))
- (corfu--done newstr 'finished))))
- ;; Try to complete the current input string
- (let* ((pt (max 0 (- (point) beg)))
- (str (buffer-substring-no-properties beg end))
- (metadata (completion-metadata (substring str 0 pt) table pred)))
- (pcase (completion-try-completion str table pred pt metadata)
- ('t
- (goto-char end)
- (corfu--done str 'finished))
- (`(,newstr . ,newpt)
- (unless (equal str newstr)
- ;; bug#55205: completion--replace removes properties!
- (completion--replace beg end (concat newstr)))
- (goto-char (+ beg newpt))
- ;; Exit with status 'finished if input is a valid match
- ;; and no further completion is possible.
- (when (and (test-completion newstr table pred)
- (not (consp (completion-try-completion
- newstr table pred newpt
- (completion-metadata newstr table pred)))))
- (corfu--done newstr 'finished))))))))
-
-(defun corfu--insert (status)
- "Insert current candidate, exit with STATUS if non-nil."
- (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data)
- (str (buffer-substring-no-properties beg end)))
- ;; XXX There is a small bug here, depending on interpretation.
- ;; When completing "~/emacs/master/li|/calc" where "|" is the
- ;; cursor, then the candidate only includes the prefix
- ;; "~/emacs/master/lisp/", but not the suffix "/calc". Default
- ;; completion has the same problem when selecting in the
- ;; *Completions* buffer. See bug#48356.
- (setq str (concat corfu--base (substring-no-properties
- (nth corfu--index corfu--candidates))))
- ;; bug#55205: completion--replace removes properties!
- (completion--replace beg end (concat str))
- (corfu--goto -1) ;; Reset selection, but continue completion.
- (when status (corfu--done str status)))) ;; Exit with status
-
-(defun corfu--done (str status)
- "Call the `:exit-function' with STR and STATUS and exit completion."
- (let ((exit (plist-get corfu--extra :exit-function)))
- ;; For successfull completions, amalgamate undo operations,
- ;; such that completion can be undone in a single step.
- (undo-amalgamate-change-group corfu--change-group)
- (corfu-quit)
- ;; XXX Is the :exit-function handling sufficient?
- (when exit (funcall exit str status))))
-
-(defun corfu-insert ()
- "Insert current candidate.
-Quit if no candidate is selected."
- (interactive)
- (if (>= corfu--index 0)
- (corfu--insert 'finished)
- (corfu-quit)))
-
-(defun corfu--setup ()
- "Setup Corfu completion state."
- (setq corfu--extra completion-extra-properties)
- (completion-in-region-mode 1)
- (undo-boundary) ;; Necessary to support `corfu-reset'
- (activate-change-group (setq corfu--change-group (prepare-change-group)))
- (setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map)
- (add-hook 'pre-command-hook #'corfu--pre-command nil 'local)
- (add-hook 'post-command-hook #'corfu--post-command)
- ;; Disable default post-command handling, since we have our own
- ;; checks in `corfu--post-command'.
- (remove-hook 'post-command-hook #'completion-in-region--postch)
- (let ((sym (make-symbol "corfu--teardown"))
- (buf (current-buffer)))
- (fset sym (lambda ()
- ;; Ensure that the teardown runs in the correct buffer, if still alive.
- (unless completion-in-region-mode
- (remove-hook 'completion-in-region-mode-hook sym)
- (with-current-buffer (if (buffer-live-p buf) buf (current-buffer))
- (corfu--teardown)))))
- (add-hook 'completion-in-region-mode-hook sym)))
-
-(defun corfu--teardown ()
- "Teardown Corfu."
- ;; Redisplay such that the input becomes immediately visible before the popup
- ;; hiding, which is slow (Issue #48). See also corresponding vertico#89.
- (redisplay)
- (corfu--popup-hide)
- (remove-hook 'pre-command-hook #'corfu--pre-command 'local)
- (remove-hook 'post-command-hook #'corfu--post-command)
- (when corfu--preview-ov (delete-overlay corfu--preview-ov))
- (when corfu--echo-timer (cancel-timer corfu--echo-timer))
- (corfu--echo-show)
- (accept-change-group corfu--change-group)
- (mapc #'kill-local-variable corfu--state-vars))
-
-(defun corfu--in-region (beg end table &optional pred)
- "Corfu completion in region function.
-See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
- (barf-if-buffer-read-only)
- (if (not (display-graphic-p))
- ;; XXX Warning this can result in an endless loop when
- ;; `completion-in-region-function' is set *globally* to
- ;; `corfu--in-region'. This should never happen.
- (funcall (default-value 'completion-in-region-function) beg end table pred)
- ;; Restart the completion. This can happen for example if C-M-/
- ;; (`dabbrev-completion') is pressed while the Corfu popup is already open.
- (when completion-in-region-mode (corfu-quit))
- (let* ((pt (max 0 (- (point) beg)))
- (str (buffer-substring-no-properties beg end))
- (before (substring str 0 pt))
- (metadata (completion-metadata before table pred))
- (exit (plist-get completion-extra-properties :exit-function))
- (threshold (completion--cycle-threshold metadata))
- (completion-in-region-mode-predicate
- (or completion-in-region-mode-predicate (lambda () t))))
- (pcase (completion-try-completion str table pred pt metadata)
- ('nil (corfu--message "No match") nil)
- ('t
- (goto-char end)
- (corfu--message "Sole match")
- (when exit (funcall exit str 'finished))
- t)
- (`(,newstr . ,newpt)
- (pcase-let ((`(,base ,candidates ,total . ,_)
- (corfu--recompute-candidates str pt table pred)))
- (unless (markerp beg) (setq beg (copy-marker beg)))
- (setq end (copy-marker end t)
- completion-in-region--data (list beg end table pred))
- (unless (equal str newstr)
- ;; bug#55205: completion--replace removes properties!
- (completion--replace beg end (concat newstr)))
- (goto-char (+ beg newpt))
- (if (= total 1)
- ;; If completion is finished and cannot be further completed,
- ;; return 'finished. Otherwise setup the Corfu popup.
- (cond
- ((consp (completion-try-completion
- newstr table pred newpt
- (completion-metadata newstr table pred)))
- (corfu--setup))
- (exit (funcall exit newstr 'finished)))
- (if (or (= total 0) (not threshold)
- (and (not (eq threshold t)) (< threshold total)))
- (corfu--setup)
- (corfu--cycle-candidates total candidates (+ (length base) beg) end)
- ;; Do not show Corfu when "trivially" cycling, i.e.,
- ;; when the completion is finished after the candidate.
- (unless (equal (completion-boundaries (car candidates) table pred "")
- '(0 . 0))
- (corfu--setup)))))
- t)))))
-
-(defun corfu--message (&rest msg)
- "Show completion MSG."
- (let (message-log-max) (apply #'message msg)))
-
-(defun corfu--cycle-candidates (total cands beg end)
- "Cycle between TOTAL number of CANDS.
-See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
- (let* ((idx 0)
- (map (make-sparse-keymap))
- (replace (lambda ()
- (interactive)
- ;; bug#55205: completion--replace removes properties!
- (completion--replace beg end (concat (nth idx cands)))
- (corfu--message "Cycling %d/%d..." (1+ idx) total)
- (setq idx (mod (1+ idx) total))
- (set-transient-map map))))
- (define-key map [remap completion-at-point] replace)
- (define-key map [remap corfu-complete] replace)
- (define-key map (vector last-command-event) replace)
- (funcall replace)))
-
-(defun corfu--auto-complete (tick)
- "Initiate auto completion if TICK did not change."
- (setq corfu--auto-timer nil)
- (when (and (not completion-in-region-mode) (equal tick (corfu--auto-tick)))
- (pcase (while-no-input ;; Interruptible capf query
- (run-hook-wrapped 'completion-at-point-functions #'corfu--capf-wrapper))
- (`(,fun ,beg ,end ,table . ,plist)
- (let ((completion-in-region-mode-predicate
- (lambda () (eq beg (car-safe (funcall fun)))))
- (completion-extra-properties plist))
- (setq completion-in-region--data
- (list (if (markerp beg) beg (copy-marker beg))
- (copy-marker end t)
- table
- (plist-get plist :predicate)))
- (corfu--setup)
- (corfu--update))))))
-
-(defun corfu--auto-post-command ()
- "Post command hook which initiates auto completion."
- (when corfu--auto-timer
- (cancel-timer corfu--auto-timer)
- (setq corfu--auto-timer nil))
- (when (and (not completion-in-region-mode)
- (not defining-kbd-macro)
- (corfu--match-symbol-p corfu-auto-commands this-command)
- (display-graphic-p))
- ;; NOTE: Do not use idle timer since this leads to unacceptable slowdowns,
- ;; in particular if flyspell-mode is enabled.
- (setq corfu--auto-timer
- (run-at-time corfu-auto-delay nil
- #'corfu--auto-complete (corfu--auto-tick)))))
-
-(defun corfu--auto-tick ()
- "Return the current tick/status of the buffer.
-Auto completion is only performed if the tick did not change."
- (list (current-buffer) (buffer-chars-modified-tick) (point)))
-
-;;;###autoload
-(define-minor-mode corfu-mode
- "Completion Overlay Region FUnction."
- :global nil :group 'corfu
- (cond
- (corfu-mode
- ;; FIXME: Install advice which fixes `completion--capf-wrapper', such that
- ;; it respects the completion styles for non-exclusive capfs. See FIXME in
- ;; the `completion--capf-wrapper' function in minibuffer.el, where the
- ;; issue has been mentioned. We never uninstall this advice since the
- ;; advice is active *globally*.
- (advice-add #'completion--capf-wrapper :around #'corfu--capf-wrapper-advice)
- (advice-add #'eldoc-display-message-no-interference-p :before-while #'corfu--allow-eldoc)
- (and corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local))
- (setq-local completion-in-region-function #'corfu--in-region))
- (t
- (remove-hook 'post-command-hook #'corfu--auto-post-command 'local)
- (kill-local-variable 'completion-in-region-function))))
-
-(defun corfu--capf-wrapper (fun &optional prefix)
- "Wrapper for `completion-at-point' FUN.
-The wrapper determines if the capf is applicable at the current position
-and performs sanity checking on the returned result. PREFIX is a prefix
-length override, set to t for manual completion."
- (pcase (funcall fun)
- ((and res `(,beg ,end ,table . ,plist))
- (and (integer-or-marker-p beg) ;; Valid capf result
- (<= beg (point) end) ;; Sanity checking
- ;; When auto completing, check the prefix length!
- (let ((len (or prefix
- (plist-get plist :company-prefix-length)
- (- (point) beg))))
- (or (eq len t) (>= len corfu-auto-prefix)))
- ;; For non-exclusive capfs, check for valid completion.
- (or (not (eq 'no (plist-get plist :exclusive)))
- (let* ((str (buffer-substring-no-properties beg end))
- (pt (- (point) beg))
- (pred (plist-get plist :predicate))
- (md (completion-metadata (substring str 0 pt) table pred)))
- ;; We use `completion-try-completion' to check if there are
- ;; completions. The upstream `completion--capf-wrapper' uses
- ;; `try-completion' which is incorrect since it only checks for
- ;; prefix completions.
- (completion-try-completion str table pred pt md)))
- (cons fun res)))))
-
-(defun corfu--capf-wrapper-advice (orig fun which)
- "Around advice for `completion--capf-wrapper'.
-The ORIG function takes the FUN and WHICH arguments."
- (if corfu-mode (corfu--capf-wrapper fun t) (funcall orig fun which)))
-
-;;;###autoload
-(define-globalized-minor-mode global-corfu-mode corfu-mode corfu--on :group 'corfu)
-
-(defun corfu--on ()
- "Turn `corfu-mode' on."
- (unless (or noninteractive
- (eq (aref (buffer-name) 0) ?\s)
- (memq major-mode corfu-excluded-modes))
- (corfu-mode 1)))
-
-(defun corfu--allow-eldoc ()
- "Return non-nil if Corfu is currently not active."
- (not (and corfu-mode completion-in-region-mode)))
-
-;; Emacs 28: Do not show Corfu commands with M-X
-(dolist (sym '(corfu-next corfu-previous corfu-first corfu-last corfu-quit corfu-reset
- corfu-complete corfu-insert corfu-scroll-up corfu-scroll-down
- corfu-insert-separator))
- (put sym 'completion-predicate #'ignore))
-
-(provide 'corfu)
-;;; corfu.el ends here
diff --git a/elpa/corfu-0.23/corfu.info b/elpa/corfu-0.23/corfu.info
@@ -1,644 +0,0 @@
-This is corfu.info, produced by makeinfo version 6.7 from corfu.texi.
-
-INFO-DIR-SECTION Emacs misc features
-START-INFO-DIR-ENTRY
-* Corfu: (corfu). Completion Overlay Region FUnction.
-END-INFO-DIR-ENTRY
-
-
-File: corfu.info, Node: Top, Next: Introduction, Up: (dir)
-
-corfu.el - Completion Overlay Region FUnction
-*********************************************
-
-* Menu:
-
-* Introduction::
-* Features::
-* Installation and Configuration::
-* Key bindings::
-* Extensions::
-* Complementary packages::
-* Alternatives::
-* Contributions::
-
-— The Detailed Node Listing —
-
-Installation and Configuration
-
-* Auto completion::
-* Completing with Corfu in the minibuffer::
-* Completing with Corfu in the Eshell or Shell::
-* Orderless completion::
-* TAB-and-Go completion::
-* Transfer completion to the minibuffer::
-
-
-
-File: corfu.info, Node: Introduction, Next: Features, Prev: Top, Up: Top
-
-1 Introduction
-**************
-
-Corfu enhances completion at point with a small completion popup. The
-current candidates are shown in a popup below or above the point. Corfu
-is the minimalistic ‘completion-in-region’ counterpart of the Vertico
-(https://github.com/minad/vertico) minibuffer UI.
-
- Corfu is a small package, which relies on the Emacs completion
-facilities and concentrates on providing a polished completion UI.
-Completions are either provided by commands like ‘dabbrev-completion’ or
-by pluggable backends (‘completion-at-point-functions’, Capfs). Most
-programming language major modes implement a Capf. Furthermore the
-language server packages, Eglot (https://github.com/joaotavora/eglot)
-and Lsp-mode (https://github.com/emacs-lsp/lsp-mode), use Capfs which
-talk to the LSP server to retrieve the completions. Corfu does not
-include its own completion backends. The Emacs built-in Capfs and the
-Capfs provided by other programming language packages are usually
-sufficient. A few additional Capfs and completion utilities are
-provided by the Cape (https://github.com/minad/cape) package.
-
- *NOTE*: Corfu uses child frames to show the popup and falls back to
-the default setting of the ‘completion-in-region-function’ on
-non-graphical displays. There is a package in the works
-(https://codeberg.org/akib/emacs-corfu-popup) which uses overlays for
-the popup such that Corfu can be used when Emacs is running in a
-terminal.
-
- <https://github.com/minad/corfu/blob/screenshots/light.png?raw=true>
-
- <https://github.com/minad/corfu/blob/screenshots/dark.png?raw=true>
-
-
-File: corfu.info, Node: Features, Next: Installation and Configuration, Prev: Introduction, Up: Top
-
-2 Features
-**********
-
- • Timer-based auto-completions (_off_ by default, set ‘corfu-auto’).
- • Popup display with scrollbar indicator and arrow key navigation.
- • The popup can be summoned explicitly by pressing ‘TAB’ at any time.
- • The current candidate is inserted with ‘TAB’ and selected with
- ‘RET’.
- • Candidates sorting by prefix, string length and alphabetically.
- • The selected candidate is previewed (configurable via
- ‘corfu-preview-current’).
- • The selected candidate automatically committed on further input by
- default. (configurable via ‘corfu-preview-current’).
- • The Orderless (https://github.com/oantolin/orderless) completion
- style is supported. The filter string can contain arbitrary
- characters, after inserting a space via ‘M-SPC’ (configurable via
- ‘corfu-quit-at-boundary’ and ‘corfu-separator’).
- • Deferred completion style highlighting for performance.
- • Support for candidate annotations and documentation in the echo
- area.
- • Deprecated candidates are crossed out in the display.
- • Icons can be provided by an external package via margin formatter
- functions.
- • Extensions: Quick keys, Index keys, Sorting by history, Candidate
- documentation
-
-
-File: corfu.info, Node: Installation and Configuration, Next: Key bindings, Prev: Features, Up: Top
-
-3 Installation and Configuration
-********************************
-
-Corfu is available from GNU ELPA
-(http://elpa.gnu.org/packages/corfu.html), such that it can be installed
-directly via ‘package-install’. After installation, the global minor
-mode can be enabled with ‘M-x global-corfu-mode’. In order to configure
-Corfu and other packages in your init.el, you may want to use
-‘use-package’.
-
- Corfu is highly flexible and customizable via ‘corfu-*’ customization
-variables, such that you can adapt it precisely to your requirements.
-However in order to quickly try out the Corfu completion package, it
-should be sufficient to activate ‘global-corfu-mode’. You can
-experiment with manual completion for example in an Elisp buffer or in
-an Eshell or Shell buffer. For auto completion, set ‘corfu-auto=t’
-before turning on ‘global-corfu-mode’.
-
- Here is an example configuration:
-
- (use-package corfu
- ;; Optional customizations
- ;; :custom
- ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- ;; (corfu-auto t) ;; Enable auto completion
- ;; (corfu-separator ?\s) ;; Orderless field separator
- ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
- ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
- ;; (corfu-preview-current nil) ;; Disable current candidate preview
- ;; (corfu-preselect-first nil) ;; Disable candidate preselection
- ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
- ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
- ;; (corfu-scroll-margin 5) ;; Use scroll margin
-
- ;; Enable Corfu only for certain modes.
- ;; :hook ((prog-mode . corfu-mode)
- ;; (shell-mode . corfu-mode)
- ;; (eshell-mode . corfu-mode))
-
- ;; Recommended: Enable Corfu globally.
- ;; This is recommended since Dabbrev can be used globally (M-/).
- ;; See also `corfu-excluded-modes'.
- :init
- (global-corfu-mode))
-
- ;; A few more useful configurations...
- (use-package emacs
- :init
- ;; TAB cycle if there are only few candidates
- (setq completion-cycle-threshold 3)
-
- ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
- ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
- ;; (setq read-extended-command-predicate
- ;; #'command-completion-default-include-p)
-
- ;; Enable indentation+completion using the TAB key.
- ;; `completion-at-point' is often bound to M-TAB.
- (setq tab-always-indent 'complete))
-
- Dabbrev completion is based on ‘completion-in-region’ and can be used
-with Corfu. You may want to swap the ‘dabbrev-completion’ with the
-‘dabbrev-expand’ key for easier access, if you prefer completion. Also
-take a look at the ‘cape-dabbrev’ completion at point function provided
-by my Cape (https://github.com/minad/cape) package.
-
- ;; Use Dabbrev with Corfu!
- (use-package dabbrev
- ;; Swap M-/ and C-M-/
- :bind (("M-/" . dabbrev-completion)
- ("C-M-/" . dabbrev-expand))
- ;; Other useful Dabbrev configurations.
- :custom
- (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
-
- If you start to configure the package more deeply, I recommend to
-give the Orderless completion style a try for filtering. Orderless
-completion is different from the familiar prefix TAB completion. Corfu
-can be used with the default completion styles. The use of Orderless is
-not a necessity.
-
- ;; Optionally use the `orderless' completion style.
- (use-package orderless
- :init
- ;; Configure a custom style dispatcher (see the Consult wiki)
- ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
- ;; orderless-component-separator #'orderless-escapable-split-on-space)
- (setq completion-styles '(orderless basic)
- completion-category-defaults nil
- completion-category-overrides '((file (styles . (partial-completion))))))
-
- The ‘basic’ completion style is specified as fallback in addition to
-‘orderless’ in order to ensure that completion commands which rely on
-dynamic completion tables, e.g., ‘completion-table-dynamic’ or
-‘completion-table-in-turn’, work correctly. See ‘+orderless-dispatch’
-in the Consult wiki (https://github.com/minad/consult/wiki) for an
-advanced Orderless style dispatcher. Additionally enable
-‘partial-completion’ for file path expansion. ‘partial-completion’ is
-important for file wildcard support. Multiple files can be opened at
-once with ‘find-file’ if you enter a wildcard. You may also give the
-‘initials’ completion style a try.
-
- See also the Corfu Wiki (https://github.com/minad/corfu/wiki) for
-additional configuration tips. In particular the Lsp-mode configuration
-is documented in the wiki. For more general documentation read the
-chapter about completion in the Emacs manual
-(https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html).
-If you want to create your own Capfs, you can find documentation about
-completion in the Elisp manual
-(https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html).
-
-* Menu:
-
-* Auto completion::
-* Completing with Corfu in the minibuffer::
-* Completing with Corfu in the Eshell or Shell::
-* Orderless completion::
-* TAB-and-Go completion::
-* Transfer completion to the minibuffer::
-
-
-File: corfu.info, Node: Auto completion, Next: Completing with Corfu in the minibuffer, Up: Installation and Configuration
-
-3.1 Auto completion
-===================
-
-Auto completion is disabled by default, but can be enabled by setting
-‘corfu-auto=t’. Furthermore you may want to configure Corfu to quit
-completion eagerly, such that the completion popup stays out of your way
-when it appeared unexpectedly.
-
- ;; Enable auto completion and configure quitting
- (setq corfu-auto t
- corfu-quit-no-match 'separator) ;; or t
-
- In general, I recommend to experiment a bit with the various settings
-and key bindings to find a configuration which works for you. There is
-no one size fits all solution. Some people like auto completion, some
-like manual completion, some want to cycle with TAB and some with the
-arrow keys...
-
-
-File: corfu.info, Node: Completing with Corfu in the minibuffer, Next: Completing with Corfu in the Eshell or Shell, Prev: Auto completion, Up: Installation and Configuration
-
-3.2 Completing with Corfu in the minibuffer
-===========================================
-
-Corfu can be used for completion in the minibuffer, since it relies on
-child frames to display the candidates. By default, ‘global-corfu-mode’
-does not activate ‘corfu-mode’ in the minibuffer, to avoid interference
-with specialised minibuffer completion UIs like Vertico or Mct. However
-you may still want to enable Corfu completion for commands like ‘M-:’
-(‘eval-expression’) or ‘M-!’ (‘shell-command’), which read from the
-minibuffer. Activate ‘corfu-mode’ only if ‘completion-at-point’ is
-bound in the minibuffer-local keymap to achieve this effect.
-
- (defun corfu-enable-in-minibuffer ()
- "Enable Corfu in the minibuffer if `completion-at-point' is bound."
- (when (where-is-internal #'completion-at-point (list (current-local-map)))
- ;; (setq-local corfu-auto nil) Enable/disable auto completion
- (corfu-mode 1)))
- (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
-
- You can also enable Corfu more generally for every minibuffer, as
-long as no other completion UI is active. If you use Mct or Vertico as
-your main minibuffer completion UI, the following snippet should yield
-the desired result.
-
- (defun corfu-enable-always-in-minibuffer ()
- "Enable Corfu in the minibuffer if Vertico/Mct are not active."
- (unless (or (bound-and-true-p mct--active)
- (bound-and-true-p vertico--input))
- ;; (setq-local corfu-auto nil) Enable/disable auto completion
- (corfu-mode 1)))
- (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
-
-
-File: corfu.info, Node: Completing with Corfu in the Eshell or Shell, Next: Orderless completion, Prev: Completing with Corfu in the minibuffer, Up: Installation and Configuration
-
-3.3 Completing with Corfu in the Eshell or Shell
-================================================
-
-When completing in the Eshell I recommend conservative local settings
-without auto completion, such that the completion behavior is similar to
-widely used shells like Bash, Zsh or Fish.
-
- (add-hook 'eshell-mode-hook
- (lambda ()
- (setq-local corfu-auto nil)
- (corfu-mode)))
-
- When pressing ‘RET’ while the Corfu popup is visible, the
-‘corfu-insert’ command will be invoked. This command does inserts the
-currently selected candidate, but it does not send the prompt input to
-Eshell or the comint process. Therefore you often have to press ‘RET’
-twice which feels like an unnecessary double confirmation. Fortunately
-it is easy to improve this! In my configuration I define the advice
-‘corfu-send-shell’ which sends the candidate after insertion.
-
- (defun corfu-send-shell (&rest _)
- "Send completion candidate when inside comint/eshell."
- (cond
- ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
- (eshell-send-input))
- ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
- (comint-send-input))))
-
- (advice-add #'corfu-insert :after #'corfu-send-shell)
-
- Shell completion uses the flexible ‘pcomplete’ mechanism internally,
-which allows you to program the completions per shell command. If you
-want to know more, look into this blog post
-(https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs),
-which shows how to configure pcomplete for git commands. I recommend
-the pcmpl-args (https://github.com/JonWaltman/pcmpl-args.el) package
-which extends Pcomplete with completion support and helpful annotation
-support for more commands. Similar to the Fish shell, pcmpl-args uses
-man page parsing and –help output parsing to dynamically generate
-completions. This package brings Eshell completion to another level!
-
- Unfortunately Pcomplete has a few technical issues, which we can work
-around with the Cape (https://github.com/minad/cape) library (Completion
-at point extensions). Cape provides wrappers, which sanitize the
-pcomplete function. Ideally the bugs in pcomplete should be fixed
-upstream. *For now these two advices are strongly recommended to
-achieve a sane Eshell experience.*
-
- ;; Silence the pcomplete capf, no errors or messages!
- (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
-
- ;; Ensure that pcomplete does not write to the buffer
- ;; and behaves as a pure `completion-at-point-function'.
- (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
-
-
-File: corfu.info, Node: Orderless completion, Next: TAB-and-Go completion, Prev: Completing with Corfu in the Eshell or Shell, Up: Installation and Configuration
-
-3.4 Orderless completion
-========================
-
-Orderless (https://github.com/oantolin/orderless) is an advanced
-completion style that supports multi-component search filters separated
-by a configurable character (space, by default). Normally, entering
-characters like space which lie outside the completion region boundaries
-(words, typically) causes Corfu to quit. This behavior is helpful with
-auto-completion, which may pop-up when not desired, e.g. on entering a
-new variable name. Just keep typing and Corfu will get out of the way.
-
- But orderless search terms can contain arbitrary characters; they are
-also interpreted as regular expressions. To use orderless, set
-‘corfu-separator’ (a space, by default) to the primary character of your
-orderless component separator.
-
- Then, when a new orderless component is desired, use ‘M-SPC’
-(‘corfu-insert-separator’) to enter the _first_ component separator in
-the input, and arbitrary orderless search terms and new separators can
-be entered thereafter.
-
- To treat the entire input as Orderless input, you can set the
-customization option ‘corfu-quit-at-boundary=t’. This disables the
-predicate which checks if the current completion boundary has been left.
-In contrast, if you _always_ want to quit at the boundary, simply set
-‘corfu-quit-at-boundary=nil’. By default ‘corfu-quit-at-boundary’ is
-set to ‘separator’ which quits at completion boundaries as long as no
-separator has been inserted with ‘corfu-insert-separator’.
-
- Finally, there exists the user option ‘corfu-quit-no-match’ which is
-set to ‘separator’ by default. With this setting Corfu stays alive as
-soon as you start advanced filtering with a ‘corfu-separator’ even if
-there are no matches, for example due to a typo. As long as no
-separator character has been inserted with ‘corfu-insert-separator’,
-Corfu will still quit if there are no matches. This ensures that the
-Corfu popup goes away quickly if completion is not possible.
-
- In the following we show two configurations, one which works best
-with auto completion and one which may work better with manual
-completion if you prefer to always use ‘SPC’ to separate the Orderless
-components.
-
- ;; Auto completion example
- (use-package corfu
- :custom
- (corfu-auto t) ;; Enable auto completion
- ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
- :bind
- ;; Another key binding can be used, such as S-SPC.
- ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
- :init
- (global-corfu-mode))
-
- ;; Manual completion example
- (use-package corfu
- :custom
- ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
- :bind
- ;; Configure SPC for separator insertion
- (:map corfu-map ("SPC" . corfu-insert-separator))
- :init
- (global-corfu-mode))
-
-
-File: corfu.info, Node: TAB-and-Go completion, Next: Transfer completion to the minibuffer, Prev: Orderless completion, Up: Installation and Configuration
-
-3.5 TAB-and-Go completion
-=========================
-
-You may be interested in configuring Corfu in TAB-and-Go style.
-Pressing TAB moves to the next candidate and further input will then
-commit the selection. Note that further input will not expand snippets
-or templates, which may not be desired but which leads overall to a more
-predictable behavior. In order to force snippet expansion, confirm a
-candidate explicitly with ‘RET’.
-
- (use-package corfu
- ;; TAB-and-Go customizations
- :custom
- (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- (corfu-preselect-first nil) ;; Disable candidate preselection
-
- ;; Use TAB for cycling, default is `corfu-complete'.
- :bind
- (:map corfu-map
- ("TAB" . corfu-next)
- ([tab] . corfu-next)
- ("S-TAB" . corfu-previous)
- ([backtab] . corfu-previous))
-
- :init
- (global-corfu-mode))
-
-
-File: corfu.info, Node: Transfer completion to the minibuffer, Prev: TAB-and-Go completion, Up: Installation and Configuration
-
-3.6 Transfer completion to the minibuffer
-=========================================
-
-Sometimes it is useful to transfer the Corfu completion session to the
-minibuffer, since the minibuffer offers richer interaction features. In
-particular, Embark (https://github.com/oantolin/embark) is available in
-the minibuffer, such that you can act on the candidates or
-export/collect the candidates to a separate buffer. Hopefully we can
-also add Corfu-support to Embark in the future, such that at least
-export/collect is possible directly from Corfu. But in my opinion
-having the ability to transfer the Corfu completion to the minibuffer is
-an even better feature, since further completion can be performed there.
-
- The command ‘corfu-move-to-minibuffer’ is defined here in terms of
-‘consult-completion-in-region’, which uses the minibuffer completion UI
-via ‘completing-read’.
-
- (defun corfu-move-to-minibuffer ()
- (interactive)
- (let ((completion-extra-properties corfu--extra)
- completion-cycle-threshold completion-cycling)
- (apply #'consult-completion-in-region completion-in-region--data)))
- (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
-
-
-File: corfu.info, Node: Key bindings, Next: Extensions, Prev: Installation and Configuration, Up: Top
-
-4 Key bindings
-**************
-
-Corfu uses a transient keymap ‘corfu-map’ which is active while the
-popup is shown. The keymap defines the following remappings and
-bindings:
-
- • ‘beginning-of-buffer’ -> ‘corfu-first’
- • ‘end-of-buffer’ -> ‘corfu-last’
- • ‘scroll-down-command’ -> ‘corfu-scroll-down’
- • ‘scroll-up-command’ -> ‘corfu-scroll-up’
- • ‘next-line’, ‘down’, ‘M-n’ -> ‘corfu-next’
- • ‘previous-line’, ‘up’, ‘M-p’ -> ‘corfu-previous’
- • ‘completion-at-point’, ‘TAB’ -> ‘corfu-complete’
- • ‘RET’ -> ‘corfu-insert’
- • ‘M-g’ -> ‘corfu-info-location’
- • ‘M-h’ -> ‘corfu-info-documentation’
- • ‘M-SPC’ -> ‘corfu-insert-separator’
- • ‘C-g’ -> ‘corfu-quit’
- • ‘keyboard-escape-quit’ -> ‘corfu-reset’
-
-
-File: corfu.info, Node: Extensions, Next: Complementary packages, Prev: Key bindings, Up: Top
-
-5 Extensions
-************
-
-We maintain small extension packages to Corfu in this repository in the
-subdirectory extensions/
-(https://github.com/minad/corfu/tree/main/extensions). The extensions
-are installed together with Corfu if you pull the package from ELPA.
-The extensions are inactive by default and can be enabled manually if
-desired. Furthermore it is possible to install all of the files
-separately, both ‘corfu.el’ and the ‘corfu-*.el’ extensions. Currently
-the following extensions come with the Corfu ELPA package:
-
- • corfu-history
- (https://github.com/minad/corfu/blob/main/extensions/corfu-history.el):
- ‘corfu-history-mode’ to remember selected candidates and to improve
- sorting.
- • corfu-indexed
- (https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el):
- ‘corfu-indexed-mode’ to select indexed candidates with prefix
- arguments.
- • corfu-info
- (https://github.com/minad/corfu/blob/main/extensions/corfu-info.el):
- Candidate actions to access the candidate location and
- documentation.
- • corfu-quick
- (https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el):
- Commands to select using Avy-style quick keys.
-
-
-File: corfu.info, Node: Complementary packages, Next: Alternatives, Prev: Extensions, Up: Top
-
-6 Complementary packages
-************************
-
-Corfu works well together with all packages providing code completion
-via the ‘completion-at-point-functions’. Many modes and packages
-already provide a Capf out of the box. Nevertheless you may want to
-look into complementary packages to enhance your setup.
-
- • Orderless (https://github.com/oantolin/orderless): Corfu supports
- completion styles, including the advanced Orderless
- (https://github.com/oantolin/orderless) completion style, where the
- filtering expressions are separated by spaces or another character
- (see ‘corfu-separator’).
-
- • Cape (https://github.com/minad/cape): Additional Capf backends and
- ‘completion-in-region’ commands are provided by the Cape
- (https://github.com/minad/cape) package. Among others, the package
- supplies a file path and a dabbrev completion backend. Cape
- provides the ‘cape-company-to-capf’ adapter to reuse Company
- backends in Corfu. Furthermore the function ‘cape-super-capf’ can
- merge multiple Capfs, such that the candidates of multiple Capfs
- are displayed together at the same time.
-
- • kind-icon (https://github.com/jdtsmith/kind-icon): Icons are
- supported by Corfu via an external package. For example the
- kind-icon (https://github.com/jdtsmith/kind-icon) package provides
- beautifully styled SVG icons based on monochromatic icon sets like
- material design.
-
- • corfu-doc (https://github.com/galeo/corfu-doc): The corfu-doc
- package displays the candidate documentation in a popup next to the
- Corfu popup, similar to ‘company-quickhelp’.
-
- • pcmpl-args (https://github.com/JonWaltman/pcmpl-args.el): Extend
- the Eshell/Shell Pcomplete mechanism with support for many more
- commands. Similar to the Fish shell, Pcomplete uses man page
- parsing to dynamically retrieve the completions and helpful
- annotations. This package brings Eshell completions to another
- level!
-
- • Tempel (https://github.com/minad/tempel): Tiny template/snippet
- package with templates in Lisp syntax, which can be used in
- conjunction with Corfu.
-
- • Vertico (https://github.com/minad/vertico): You may also want to
- look into my Vertico (https://github.com/minad/vertico) package.
- Vertico is the minibuffer completion counterpart of Corfu.
-
-
-File: corfu.info, Node: Alternatives, Next: Contributions, Prev: Complementary packages, Up: Top
-
-7 Alternatives
-**************
-
- • Company (https://github.com/company-mode/company-mode): Company is
- a widely used and mature completion package, which implements a
- similar interaction model and popup UI as Corfu. While Corfu
- relies exclusively on the standard Emacs completion API (Capfs),
- Company defines its own API for the backends. Company includes its
- completion backends, which are incompatible with the Emacs
- completion infrastructure. As a result of this design, Company is
- a more complex package than Corfu. Company by default uses
- overlays for the popup in contrast to the child frames used by
- Corfu. Overall both packages work well, but Company integrates
- less tightly with Emacs. The ‘completion-styles’ support is more
- limited and the ‘completion-at-point’ command and the
- ‘completion-in-region’ function do not invoke Company.
-
- • Mct (https://git.sr.ht/~protesilaos/mct): Protesilaos’ Minibuffer
- Confines Transcended package supports both minibuffer completion
- and completion in region. It reuses the default completion UI for
- this purpose and installs a timer which live updates the completion
- buffer. The main advantage of Mct is that you work with a regular
- Emacs buffer instead of with a popup. You can take advantage of
- the usual Emacs commands to navigate in the completions buffer. On
- top, Mct enhances the movement such that you can quickly switch
- between the completions buffer and the minibuffer or the region
- which is being completed. Mct does not support timer-based auto
- completion, but the integration into Emacs is naturally tight.
-
- • consult-completion-in-region (https://github.com/minad/consult):
- The Consult package provides the function
- ‘consult-completion-in-region’ which can be set as
- ‘completion-in-region-function’ such that it handles
- ‘completion-at-point’. The function works by transferring the
- in-buffer completion to the minibuffer. In the minibuffer, the
- minibuffer completion UI, for example Vertico
- (https://github.com/minad/vertico) takes over. If you prefer to
- perform all your completions in the minibuffer
- ‘consult-completion-in-region’ is your best option.
-
-
-File: corfu.info, Node: Contributions, Prev: Alternatives, Up: Top
-
-8 Contributions
-***************
-
-Since this package is part of GNU ELPA
-(http://elpa.gnu.org/packages/corfu.html) contributions require a
-copyright assignment to the FSF.
-
-
-
-Tag Table:
-Node: Top209
-Node: Introduction811
-Node: Features2501
-Node: Installation and Configuration3917
-Node: Auto completion9646
-Node: Completing with Corfu in the minibuffer10495
-Node: Completing with Corfu in the Eshell or Shell12352
-Node: Orderless completion15257
-Node: TAB-and-Go completion18365
-Node: Transfer completion to the minibuffer19480
-Node: Key bindings20819
-Node: Extensions21810
-Node: Complementary packages23143
-Node: Alternatives25639
-Node: Contributions28067
-
-End Tag Table
-
-
-Local Variables:
-coding: utf-8
-End:
diff --git a/elpa/corfu-0.27.signed b/elpa/corfu-0.27.signed
@@ -0,0 +1 @@
+Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2022-08-29T23:05:02+0200 using RSA
+\ No newline at end of file
diff --git a/elpa/corfu-0.23/LICENSE b/elpa/corfu-0.27/LICENSE
diff --git a/elpa/corfu-0.27/README-elpa b/elpa/corfu-0.27/README-elpa
@@ -0,0 +1,710 @@
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ CORFU.EL - COMPLETION OVERLAY REGION FUNCTION
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+
+Table of Contents
+─────────────────
+
+1. Features
+2. Installation and Configuration
+.. 1. Auto completion
+.. 2. Completing in the minibuffer
+.. 3. Completing in the Eshell or Shell
+.. 4. Orderless completion
+.. 5. TAB-and-Go completion
+.. 6. Transfer completion to the minibuffer
+3. Key bindings
+4. Extensions
+5. Complementary packages
+6. Alternatives
+7. Contributions
+
+
+Corfu enhances completion at point with a small completion popup. The
+current candidates are shown in a popup below or above the point. Corfu
+is the minimalistic `completion-in-region' counterpart of the [Vertico]
+minibuffer UI.
+
+Corfu is a small package, which relies on the Emacs completion
+facilities and concentrates on providing a polished completion
+UI. Completions are either provided by commands like
+`dabbrev-completion' or by pluggable backends
+(`completion-at-point-functions', Capfs). Most programming language
+major modes implement a Capf. Furthermore the language server packages,
+[Eglot] and [Lsp-mode], use Capfs which talk to the LSP server to
+retrieve the completions. Corfu does not include its own completion
+backends. The Emacs built-in Capfs and the Capfs provided by other
+programming language packages are usually sufficient. A few additional
+Capfs and completion utilities are provided by the [Cape] package.
+
+*NOTE*: Corfu uses child frames to show the popup and falls back to the
+default setting of the `completion-in-region-function' on non-graphical
+displays. If you want to use Corfu in the terminal, install the package
+[corfu-terminal], which provides an alternative overlay-based display.
+
+Table of Contents
+─────────────────
+
+1. Features
+2. Installation and Configuration
+.. 1. Auto completion
+.. 2. Completing in the minibuffer
+.. 3. Completing in the Eshell or Shell
+.. 4. Orderless completion
+.. 5. TAB-and-Go completion
+.. 6. Transfer completion to the minibuffer
+3. Key bindings
+4. Extensions
+5. Complementary packages
+6. Alternatives
+7. Contributions
+
+
+[Vertico] <https://github.com/minad/vertico>
+
+[Eglot] <https://github.com/joaotavora/eglot>
+
+[Lsp-mode] <https://github.com/emacs-lsp/lsp-mode>
+
+[Cape] <https://github.com/minad/cape>
+
+[corfu-terminal] <https://codeberg.org/akib/emacs-corfu-terminal>
+
+
+1 Features
+══════════
+
+ • Timer-based auto-completions (/off/ by default, set `corfu-auto').
+ • Popup display with scrollbar indicator and arrow key navigation.
+ • The popup can be summoned explicitly by pressing `TAB' at any time.
+ • The current candidate is inserted with `TAB' and selected with
+ `RET'.
+ • Candidates sorting by prefix, string length and alphabetically.
+ • The selected candidate is previewed (configurable via
+ `corfu-preview-current').
+ • The selected candidate automatically committed on further input by
+ default. (configurable via `corfu-preview-current').
+ • The [Orderless] completion style is supported. The filter string can
+ contain arbitrary characters, after inserting a space via `M-SPC'
+ (configurable via `corfu-quit-at-boundary' and `corfu-separator').
+ • Deferred completion style highlighting for performance.
+ • Support for candidate annotations and documentation in the echo
+ area.
+ • Deprecated candidates are crossed out in the display.
+ • Icons can be provided by an external package via margin formatter
+ functions.
+ • Extensions: Quick keys, Index keys, Sorting by history, Candidate
+ documentation
+
+
+[Orderless] <https://github.com/oantolin/orderless>
+
+
+2 Installation and Configuration
+════════════════════════════════
+
+ Corfu is available from [GNU ELPA], such that it can be installed
+ directly via `package-install'. After installation, the global minor
+ mode can be enabled with `M-x global-corfu-mode'. In order to
+ configure Corfu and other packages in your init.el, you may want to
+ use `use-package'.
+
+ Corfu is highly flexible and customizable via `corfu-*' customization
+ variables, such that you can adapt it precisely to your
+ requirements. However in order to quickly try out the Corfu completion
+ package, it should be sufficient to activate `global-corfu-mode'. You
+ can experiment with manual completion for example in an Elisp buffer
+ or in an Eshell or Shell buffer. For auto completion, set
+ `corfu-auto=t' before turning on `global-corfu-mode'.
+
+ Here is an example configuration:
+
+ ┌────
+ │ (use-package corfu
+ │ ;; Optional customizations
+ │ ;; :custom
+ │ ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ │ ;; (corfu-auto t) ;; Enable auto completion
+ │ ;; (corfu-separator ?\s) ;; Orderless field separator
+ │ ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
+ │ ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
+ │ ;; (corfu-preview-current nil) ;; Disable current candidate preview
+ │ ;; (corfu-preselect-first nil) ;; Disable candidate preselection
+ │ ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
+ │ ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
+ │ ;; (corfu-scroll-margin 5) ;; Use scroll margin
+ │
+ │ ;; Enable Corfu only for certain modes.
+ │ ;; :hook ((prog-mode . corfu-mode)
+ │ ;; (shell-mode . corfu-mode)
+ │ ;; (eshell-mode . corfu-mode))
+ │
+ │ ;; Recommended: Enable Corfu globally.
+ │ ;; This is recommended since Dabbrev can be used globally (M-/).
+ │ ;; See also `corfu-excluded-modes'.
+ │ :init
+ │ (global-corfu-mode))
+ │
+ │ ;; A few more useful configurations...
+ │ (use-package emacs
+ │ :init
+ │ ;; TAB cycle if there are only few candidates
+ │ (setq completion-cycle-threshold 3)
+ │
+ │ ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
+ │ ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
+ │ ;; (setq read-extended-command-predicate
+ │ ;; #'command-completion-default-include-p)
+ │
+ │ ;; Enable indentation+completion using the TAB key.
+ │ ;; `completion-at-point' is often bound to M-TAB.
+ │ (setq tab-always-indent 'complete))
+ └────
+
+ Dabbrev completion is based on `completion-in-region' and can be used
+ with Corfu. You may want to swap the `dabbrev-completion' with the
+ `dabbrev-expand' key for easier access, if you prefer completion. Also
+ take a look at the `cape-dabbrev' completion at point function
+ provided by my [Cape] package.
+
+ ┌────
+ │ ;; Use Dabbrev with Corfu!
+ │ (use-package dabbrev
+ │ ;; Swap M-/ and C-M-/
+ │ :bind (("M-/" . dabbrev-completion)
+ │ ("C-M-/" . dabbrev-expand))
+ │ ;; Other useful Dabbrev configurations.
+ │ :custom
+ │ (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
+ └────
+
+ If you start to configure the package more deeply, I recommend to give
+ the Orderless completion style a try for filtering. Orderless
+ completion is different from the familiar prefix TAB completion. Corfu
+ can be used with the default completion styles. The use of Orderless
+ is not a necessity.
+
+ ┌────
+ │ ;; Optionally use the `orderless' completion style.
+ │ (use-package orderless
+ │ :init
+ │ ;; Configure a custom style dispatcher (see the Consult wiki)
+ │ ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
+ │ ;; orderless-component-separator #'orderless-escapable-split-on-space)
+ │ (setq completion-styles '(orderless basic)
+ │ completion-category-defaults nil
+ │ completion-category-overrides '((file (styles . (partial-completion))))))
+ └────
+
+ The `basic' completion style is specified as fallback in addition to
+ `orderless' in order to ensure that completion commands which rely on
+ dynamic completion tables, e.g., `completion-table-dynamic' or
+ `completion-table-in-turn', work correctly. See `+orderless-dispatch'
+ in the [Consult wiki] for an advanced Orderless style
+ dispatcher. Additionally enable `partial-completion' for file path
+ expansion. `partial-completion' is important for file wildcard
+ support. Multiple files can be opened at once with `find-file' if you
+ enter a wildcard. You may also give the `initials' completion style a
+ try.
+
+ See also the [Corfu Wiki] and the [Cape manual] for additional Capf
+ configuration tips. The Lsp-mode configuration is documented in the
+ wiki. For more general documentation read the chapter about completion
+ in the [Emacs manual]. If you want to create your own Capfs, you can
+ find documentation about completion in the [Elisp manual].
+
+
+[GNU ELPA] <http://elpa.gnu.org/packages/corfu.html>
+
+[Cape] <https://github.com/minad/cape>
+
+[Consult wiki] <https://github.com/minad/consult/wiki>
+
+[Corfu Wiki] <https://github.com/minad/corfu/wiki>
+
+[Cape manual] <https://github.com/minad/cape>
+
+[Emacs manual]
+<https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html>
+
+[Elisp manual]
+<https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html>
+
+2.1 Auto completion
+───────────────────
+
+ Auto completion is disabled by default, but can be enabled by setting
+ `corfu-auto=t'. Furthermore you may want to configure Corfu to quit
+ completion eagerly, such that the completion popup stays out of your
+ way when it appeared unexpectedly.
+
+ ┌────
+ │ ;; Enable auto completion and configure quitting
+ │ (setq corfu-auto t
+ │ corfu-quit-no-match 'separator) ;; or t
+ └────
+
+ I recommend to experiment a bit with the various settings and key
+ bindings to find a configuration which works for you. There is no one
+ size fits all solution. Some people like auto completion, some like
+ manual completion, some want to cycle with TAB and some with the arrow
+ keys.
+
+ In case you like aggressive auto completion settings, where the
+ completion popup appears immediately, I recommend to use a cheap
+ completion style like `basic', which performs prefix filtering. In
+ this case Corfu completion should still be very fast in buffers with
+ efficient completion backends. You can try the following settings in
+ an Elisp buffer or the Emacs scratch buffer.
+
+ ┌────
+ │ ;; Aggressive completion, cheap prefix filtering.
+ │ (setq-local corfu-auto t
+ │ corfu-auto-delay 0
+ │ corfu-auto-prefix 0
+ │ completion-styles '(basic))
+ └────
+
+ If you want to combine fast prefix filtering and Orderless filtering
+ you can still do that by defining a custom Orderless completion style
+ via `orderless-define-completion-style'. We use a custom style
+ dispatcher, which enables prefix filtering for input shorter than 4
+ characters. Note that such a setup is quite advanced. Please refer to
+ the Orderless documentation and source code for further details.
+
+ ┌────
+ │ (defun orderless-fast-dispatch (word index total)
+ │ (and (= index 0) (= total 1) (length< word 4)
+ │ `(orderless-regexp . ,(concat "^" (regexp-quote word)))))
+ │
+ │ (orderless-define-completion-style orderless-fast
+ │ (orderless-style-dispatchers '(orderless-fast-dispatch))
+ │ (orderless-matching-styles '(orderless-literal orderless-regexp)))
+ │
+ │ (setq-local corfu-auto t
+ │ corfu-auto-delay 0
+ │ corfu-auto-prefix 0
+ │ completion-styles '(orderless-fast))
+ └────
+
+
+2.2 Completing in the minibuffer
+────────────────────────────────
+
+ Corfu can be used for completion in the minibuffer, since it relies on
+ child frames to display the candidates. By default,
+ `global-corfu-mode' does not activate `corfu-mode' in the minibuffer,
+ to avoid interference with specialised minibuffer completion UIs like
+ Vertico or Mct. However you may still want to enable Corfu completion
+ for commands like `M-:' (`eval-expression') or `M-!'
+ (`shell-command'), which read from the minibuffer. Activate
+ `corfu-mode' only if `completion-at-point' is bound in the
+ minibuffer-local keymap to achieve this effect.
+
+ ┌────
+ │ (defun corfu-enable-in-minibuffer ()
+ │ "Enable Corfu in the minibuffer if `completion-at-point' is bound."
+ │ (when (where-is-internal #'completion-at-point (list (current-local-map)))
+ │ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ │ (corfu-mode 1)))
+ │ (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
+ └────
+
+ You can also enable Corfu more generally for every minibuffer, as long
+ as no other completion UI is active. If you use Mct or Vertico as your
+ main minibuffer completion UI, the following snippet should yield the
+ desired result.
+
+ ┌────
+ │ (defun corfu-enable-always-in-minibuffer ()
+ │ "Enable Corfu in the minibuffer if Vertico/Mct are not active."
+ │ (unless (or (bound-and-true-p mct--active)
+ │ (bound-and-true-p vertico--input))
+ │ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ │ (corfu-mode 1)))
+ │ (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
+ └────
+
+
+2.3 Completing in the Eshell or Shell
+─────────────────────────────────────
+
+ When completing in the Eshell I recommend conservative local settings
+ without auto completion, such that the completion behavior is similar
+ to widely used shells like Bash, Zsh or Fish.
+
+ ┌────
+ │ (add-hook 'eshell-mode-hook
+ │ (lambda ()
+ │ (setq-local corfu-auto nil)
+ │ (corfu-mode)))
+ └────
+
+ When pressing `RET' while the Corfu popup is visible, the
+ `corfu-insert' command will be invoked. This command does inserts the
+ currently selected candidate, but it does not send the prompt input to
+ Eshell or the comint process. Therefore you often have to press `RET'
+ twice which feels like an unnecessary double confirmation. Fortunately
+ it is easy to improve this! In my configuration I define the advice
+ `corfu-send-shell' which sends the candidate after insertion.
+
+ ┌────
+ │ (defun corfu-send-shell (&rest _)
+ │ "Send completion candidate when inside comint/eshell."
+ │ (cond
+ │ ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
+ │ (eshell-send-input))
+ │ ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
+ │ (comint-send-input))))
+ │
+ │ (advice-add #'corfu-insert :after #'corfu-send-shell)
+ └────
+
+ Shell completion uses the flexible `Pcomplete' mechanism internally,
+ which allows you to program the completions per shell command. If you
+ want to know more, look into this [blog post], which shows how to
+ configure Pcomplete for git commands. I recommend the [pcmpl-args]
+ package which extends Pcomplete with completion support and helpful
+ annotation support for more commands. Similar to the Fish shell,
+ pcmpl-args uses man page parsing and –help output parsing to
+ dynamically generate completions. This package brings Eshell
+ completion to another level!
+
+ Unfortunately Pcomplete has a few technical issues, which we can work
+ around with the [Cape] library (Completion at point extensions). Cape
+ provides wrappers, which sanitize the Pcomplete function. Ideally the
+ bugs in Pcomplete should be fixed upstream. *For now these two advices
+ are strongly recommended to achieve a sane Eshell experience.*
+
+ ┌────
+ │ ;; Silence the pcomplete capf, no errors or messages!
+ │ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
+ │
+ │ ;; Ensure that pcomplete does not write to the buffer
+ │ ;; and behaves as a pure `completion-at-point-function'.
+ │ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
+ └────
+
+
+[blog post]
+<https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs>
+
+[pcmpl-args] <https://github.com/JonWaltman/pcmpl-args.el>
+
+[Cape] <https://github.com/minad/cape>
+
+
+2.4 Orderless completion
+────────────────────────
+
+ [Orderless] is an advanced completion style that supports
+ multi-component search filters separated by a configurable character
+ (space, by default). Normally, entering characters like space which
+ lie outside the completion region boundaries (words, typically) causes
+ Corfu to quit. This behavior is helpful with auto-completion, which
+ may pop-up when not desired, e.g. on entering a new variable
+ name. Just keep typing and Corfu will get out of the way.
+
+ But orderless search terms can contain arbitrary characters; they are
+ also interpreted as regular expressions. To use orderless, set
+ `corfu-separator' (a space, by default) to the primary character of
+ your orderless component separator.
+
+ Then, when a new orderless component is desired, use `M-SPC'
+ (`corfu-insert-separator') to enter the /first/ component separator in
+ the input, and arbitrary orderless search terms and new separators can
+ be entered thereafter.
+
+ To treat the entire input as Orderless input, you can set the
+ customization option `corfu-quit-at-boundary=t'. This disables the
+ predicate which checks if the current completion boundary has been
+ left. In contrast, if you /always/ want to quit at the boundary,
+ simply set `corfu-quit-at-boundary=nil'. By default
+ `corfu-quit-at-boundary' is set to `separator' which quits at
+ completion boundaries as long as no separator has been inserted with
+ `corfu-insert-separator'.
+
+ Finally, there exists the user option `corfu-quit-no-match' which is
+ set to `separator' by default. With this setting Corfu stays alive as
+ soon as you start advanced filtering with a `corfu-separator' even if
+ there are no matches, for example due to a typo. As long as no
+ separator character has been inserted with `corfu-insert-separator',
+ Corfu will still quit if there are no matches. This ensures that the
+ Corfu popup goes away quickly if completion is not possible.
+
+ In the following we show two configurations, one which works best with
+ auto completion and one which may work better with manual completion
+ if you prefer to always use `SPC' to separate the Orderless
+ components.
+
+ ┌────
+ │ ;; Auto completion example
+ │ (use-package corfu
+ │ :custom
+ │ (corfu-auto t) ;; Enable auto completion
+ │ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ │ :bind
+ │ ;; Another key binding can be used, such as S-SPC.
+ │ ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
+ │ :init
+ │ (global-corfu-mode))
+ │
+ │ ;; Manual completion example
+ │ (use-package corfu
+ │ :custom
+ │ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ │ :bind
+ │ ;; Configure SPC for separator insertion
+ │ (:map corfu-map ("SPC" . corfu-insert-separator))
+ │ :init
+ │ (global-corfu-mode))
+ └────
+
+
+[Orderless] <https://github.com/oantolin/orderless>
+
+
+2.5 TAB-and-Go completion
+─────────────────────────
+
+ You may be interested in configuring Corfu in TAB-and-Go
+ style. Pressing TAB moves to the next candidate and further input will
+ then commit the selection. Note that further input will not expand
+ snippets or templates, which may not be desired but which leads
+ overall to a more predictable behavior. In order to force snippet
+ expansion, confirm a candidate explicitly with `RET'.
+
+ ┌────
+ │ (use-package corfu
+ │ ;; TAB-and-Go customizations
+ │ :custom
+ │ (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ │ (corfu-preselect-first nil) ;; Disable candidate preselection
+ │
+ │ ;; Use TAB for cycling, default is `corfu-complete'.
+ │ :bind
+ │ (:map corfu-map
+ │ ("TAB" . corfu-next)
+ │ ([tab] . corfu-next)
+ │ ("S-TAB" . corfu-previous)
+ │ ([backtab] . corfu-previous))
+ │
+ │ :init
+ │ (global-corfu-mode))
+ └────
+
+
+2.6 Transfer completion to the minibuffer
+─────────────────────────────────────────
+
+ Sometimes it is useful to transfer the Corfu completion session to the
+ minibuffer, since the minibuffer offers richer interaction
+ features. In particular, [Embark] is available in the minibuffer, such
+ that you can act on the candidates or export/collect the candidates to
+ a separate buffer. Hopefully we can also add Corfu-support to Embark
+ in the future, such that at least export/collect is possible directly
+ from Corfu. But in my opinion having the ability to transfer the Corfu
+ completion to the minibuffer is an even better feature, since further
+ completion can be performed there.
+
+ The command `corfu-move-to-minibuffer' is defined here in terms of
+ `consult-completion-in-region', which uses the minibuffer completion
+ UI via `completing-read'.
+
+ ┌────
+ │ (defun corfu-move-to-minibuffer ()
+ │ (interactive)
+ │ (let ((completion-extra-properties corfu--extra)
+ │ completion-cycle-threshold completion-cycling)
+ │ (apply #'consult-completion-in-region completion-in-region--data)))
+ │ (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
+ └────
+
+
+[Embark] <https://github.com/oantolin/embark>
+
+
+3 Key bindings
+══════════════
+
+ Corfu uses a transient keymap `corfu-map' which is active while the
+ popup is shown. The keymap defines the following remappings and
+ bindings:
+
+ • `beginning-of-buffer' -> `corfu-first'
+ • `end-of-buffer' -> `corfu-last'
+ • `scroll-down-command' -> `corfu-scroll-down'
+ • `scroll-up-command' -> `corfu-scroll-up'
+ • `next-line', `down', `M-n' -> `corfu-next'
+ • `previous-line', `up', `M-p' -> `corfu-previous'
+ • `completion-at-point', `TAB' -> `corfu-complete'
+ • `RET' -> `corfu-insert'
+ • `M-g' -> `corfu-info-location'
+ • `M-h' -> `corfu-info-documentation'
+ • `M-SPC' -> `corfu-insert-separator'
+ • `C-g' -> `corfu-quit'
+ • `keyboard-escape-quit' -> `corfu-reset'
+
+
+4 Extensions
+════════════
+
+ We maintain small extension packages to Corfu in this repository in
+ the subdirectory [extensions/]. The extensions are installed together
+ with Corfu if you pull the package from ELPA. The extensions are
+ inactive by default and can be enabled manually if
+ desired. Furthermore it is possible to install all of the files
+ separately, both `corfu.el' and the `corfu-*.el' extensions. Currently
+ the following extensions come with the Corfu ELPA package:
+
+ • [corfu-history]: `corfu-history-mode' to remember selected
+ candidates and to improve sorting.
+ • [corfu-indexed]: `corfu-indexed-mode' to select indexed candidates
+ with prefix arguments.
+ • [corfu-info]: Actions to access the candidate location and
+ documentation.
+ • [corfu-quick]: Commands to select using Avy-style quick keys.
+
+ See the Commentary of those files for configuration details.
+
+
+[extensions/] <https://github.com/minad/corfu/tree/main/extensions>
+
+[corfu-history]
+<https://github.com/minad/corfu/blob/main/extensions/corfu-history.el>
+
+[corfu-indexed]
+<https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el>
+
+[corfu-info]
+<https://github.com/minad/corfu/blob/main/extensions/corfu-info.el>
+
+[corfu-quick]
+<https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el>
+
+
+5 Complementary packages
+════════════════════════
+
+ Corfu works well together with all packages providing code completion
+ via the `completion-at-point-functions'. Many modes and packages
+ already provide a Capf out of the box. Nevertheless you may want to
+ look into complementary packages to enhance your setup.
+
+ • [corfu-terminal]: The corfu-terminal package provides an
+ overlay-based display for Corfu, such that you can use Corfu in
+ terminal Emacs.
+
+ • [corfu-doc]: The corfu-doc package displays the candidate
+ documentation in a popup next to the Corfu popup, similar to
+ `company-quickhelp'.
+
+ • [Orderless]: Corfu supports completion styles, including the
+ advanced [Orderless] completion style, where the filtering
+ expressions are separated by spaces or another character (see
+ `corfu-separator').
+
+ • [Cape]: Additional Capf backends and `completion-in-region' commands
+ are provided by the [Cape] package. Among others, the package
+ supplies a file path and a Dabbrev completion backend. Cape provides
+ the `cape-company-to-capf' adapter to reuse Company backends in
+ Corfu. Furthermore the function `cape-super-capf' can merge multiple
+ Capfs, such that the candidates of multiple Capfs are displayed
+ together at the same time.
+
+ • [kind-icon]: Icons are supported by Corfu via an external
+ package. For example the [kind-icon] package provides beautifully
+ styled SVG icons based on monochromatic icon sets like material
+ design.
+
+ • [pcmpl-args]: Extend the Eshell/Shell Pcomplete mechanism with
+ support for many more commands. Similar to the Fish shell, Pcomplete
+ uses man page parsing to dynamically retrieve the completions and
+ helpful annotations. This package brings Eshell completions to
+ another level!
+
+ • [Tempel]: Tiny template/snippet package with templates in Lisp
+ syntax, which can be used in conjunction with Corfu.
+
+ • [Vertico]: You may also want to look into my [Vertico]
+ package. Vertico is the minibuffer completion counterpart of Corfu.
+
+
+[corfu-terminal] <https://codeberg.org/akib/emacs-corfu-terminal>
+
+[corfu-doc] <https://github.com/galeo/corfu-doc>
+
+[Orderless] <https://github.com/oantolin/orderless>
+
+[Cape] <https://github.com/minad/cape>
+
+[kind-icon] <https://github.com/jdtsmith/kind-icon>
+
+[pcmpl-args] <https://github.com/JonWaltman/pcmpl-args.el>
+
+[Tempel] <https://github.com/minad/tempel>
+
+[Vertico] <https://github.com/minad/vertico>
+
+
+6 Alternatives
+══════════════
+
+ • [Company]: Company is a widely used and mature completion package,
+ which implements a similar interaction model and popup UI as
+ Corfu. While Corfu relies exclusively on the standard Emacs
+ completion API (Capfs), Company defines its own API for the
+ backends. Company includes its completion backends, which are
+ incompatible with the Emacs completion infrastructure. As a result
+ of this design, Company is a more complex package than
+ Corfu. Company by default uses overlays for the popup in contrast to
+ the child frames used by Corfu. Overall both packages work well, but
+ Company integrates less tightly with Emacs. The `completion-styles'
+ support is more limited and the `completion-at-point' command and
+ the `completion-in-region' function do not invoke Company.
+
+ • [Mct]: Protesilaos' Minibuffer Confines Transcended package supports
+ both minibuffer completion and completion in region. It reuses the
+ default completion UI for this purpose and installs a timer which
+ live updates the completion buffer. The main advantage of Mct is
+ that you work with a regular Emacs buffer instead of with a
+ popup. You can take advantage of the usual Emacs commands to
+ navigate in the completions buffer. On top, Mct enhances the
+ movement such that you can quickly switch between the completions
+ buffer and the minibuffer or the region which is being
+ completed. Mct does not support timer-based auto completion, but the
+ integration into Emacs is naturally tight. Note that Mct development
+ is currently [discontinued] due to recent changes of the default
+ completion UI on the Emacs master branch.
+
+ • [consult-completion-in-region]: The Consult package provides the
+ function `consult-completion-in-region' which can be set as
+ `completion-in-region-function' such that it handles
+ `completion-at-point'. The function works by transferring the
+ in-buffer completion to the minibuffer. In the minibuffer, the
+ minibuffer completion UI, for example [Vertico] takes over. If you
+ prefer to perform all your completions in the minibuffer
+ `consult-completion-in-region' is your best option.
+
+
+[Company] <https://github.com/company-mode/company-mode>
+
+[Mct] <https://git.sr.ht/~protesilaos/mct>
+
+[discontinued]
+<https://protesilaos.com/codelog/2022-04-14-emacs-discontinue-mct/>
+
+[consult-completion-in-region] <https://github.com/minad/consult>
+
+[Vertico] <https://github.com/minad/vertico>
+
+
+7 Contributions
+═══════════════
+
+ Since this package is part of [GNU ELPA] contributions require a
+ copyright assignment to the FSF.
+
+
+[GNU ELPA] <http://elpa.gnu.org/packages/corfu.html>
diff --git a/elpa/corfu-0.27/README.org b/elpa/corfu-0.27/README.org
@@ -0,0 +1,531 @@
+#+title: corfu.el - Completion Overlay Region FUnction
+#+author: Daniel Mendler
+#+language: en
+#+export_file_name: corfu.texi
+#+texinfo_dir_category: Emacs misc features
+#+texinfo_dir_title: Corfu: (corfu).
+#+texinfo_dir_desc: Completion Overlay Region FUnction
+
+#+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>
+#+html: <a href="http://elpa.gnu.org/packages/corfu.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/corfu.svg"/></a>
+#+html: <a href="http://elpa.gnu.org/devel/corfu.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/corfu.svg"/></a>
+
+Corfu enhances completion at point with a small completion popup. The current
+candidates are shown in a popup below or above the point. Corfu is the
+minimalistic ~completion-in-region~ counterpart of the [[https://github.com/minad/vertico][Vertico]] minibuffer UI.
+
+Corfu is a small package, which relies on the Emacs completion facilities and
+concentrates on providing a polished completion UI. Completions are either
+provided by commands like ~dabbrev-completion~ or by pluggable backends
+(~completion-at-point-functions~, Capfs). Most programming language major modes
+implement a Capf. Furthermore the language server packages, [[https://github.com/joaotavora/eglot][Eglot]] and [[https://github.com/emacs-lsp/lsp-mode][Lsp-mode]],
+use Capfs which talk to the LSP server to retrieve the completions. Corfu does
+not include its own completion backends. The Emacs built-in Capfs and the Capfs
+provided by other programming language packages are usually sufficient. A few
+additional Capfs and completion utilities are provided by the [[https://github.com/minad/cape][Cape]] package.
+
+*NOTE*: Corfu uses child frames to show the popup and falls back to the default
+setting of the ~completion-in-region-function~ on non-graphical displays. If you
+want to use Corfu in the terminal, install the package [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]], which
+provides an alternative overlay-based display.
+
+#+html: <img src="https://github.com/minad/corfu/blob/screenshots/light.png?raw=true">
+
+#+html: <img src="https://github.com/minad/corfu/blob/screenshots/dark.png?raw=true">
+
+#+toc: headlines 8
+
+* Features
+
+- Timer-based auto-completions (/off/ by default, set ~corfu-auto~).
+- Popup display with scrollbar indicator and arrow key navigation.
+- The popup can be summoned explicitly by pressing =TAB= at any time.
+- The current candidate is inserted with =TAB= and selected with =RET=.
+- Candidates sorting by prefix, string length and alphabetically.
+- The selected candidate is previewed (configurable via ~corfu-preview-current~).
+- The selected candidate automatically committed on further input by default.
+ (configurable via ~corfu-preview-current~).
+- The [[https://github.com/oantolin/orderless][Orderless]] completion style is supported. The filter string can contain
+ arbitrary characters, after inserting a space via =M-SPC= (configurable via
+ ~corfu-quit-at-boundary~ and ~corfu-separator~).
+- Deferred completion style highlighting for performance.
+- Support for candidate annotations and documentation in the echo area.
+- Deprecated candidates are crossed out in the display.
+- Icons can be provided by an external package via margin formatter functions.
+- Extensions: Quick keys, Index keys, Sorting by history, Candidate documentation
+
+* Installation and Configuration
+
+Corfu is available from [[http://elpa.gnu.org/packages/corfu.html][GNU ELPA]], such that it can be installed directly via
+~package-install~. After installation, the global minor mode can be enabled with
+=M-x global-corfu-mode=. In order to configure Corfu and other packages in your
+init.el, you may want to use ~use-package~.
+
+Corfu is highly flexible and customizable via ~corfu-*~ customization variables,
+such that you can adapt it precisely to your requirements. However in order to
+quickly try out the Corfu completion package, it should be sufficient to
+activate ~global-corfu-mode~. You can experiment with manual completion for
+example in an Elisp buffer or in an Eshell or Shell buffer. For auto completion,
+set ~corfu-auto=t~ before turning on ~global-corfu-mode~.
+
+Here is an example configuration:
+
+#+begin_src emacs-lisp
+ (use-package corfu
+ ;; Optional customizations
+ ;; :custom
+ ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ ;; (corfu-auto t) ;; Enable auto completion
+ ;; (corfu-separator ?\s) ;; Orderless field separator
+ ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
+ ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
+ ;; (corfu-preview-current nil) ;; Disable current candidate preview
+ ;; (corfu-preselect-first nil) ;; Disable candidate preselection
+ ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
+ ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
+ ;; (corfu-scroll-margin 5) ;; Use scroll margin
+
+ ;; Enable Corfu only for certain modes.
+ ;; :hook ((prog-mode . corfu-mode)
+ ;; (shell-mode . corfu-mode)
+ ;; (eshell-mode . corfu-mode))
+
+ ;; Recommended: Enable Corfu globally.
+ ;; This is recommended since Dabbrev can be used globally (M-/).
+ ;; See also `corfu-excluded-modes'.
+ :init
+ (global-corfu-mode))
+
+ ;; A few more useful configurations...
+ (use-package emacs
+ :init
+ ;; TAB cycle if there are only few candidates
+ (setq completion-cycle-threshold 3)
+
+ ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
+ ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
+ ;; (setq read-extended-command-predicate
+ ;; #'command-completion-default-include-p)
+
+ ;; Enable indentation+completion using the TAB key.
+ ;; `completion-at-point' is often bound to M-TAB.
+ (setq tab-always-indent 'complete))
+#+end_src
+
+Dabbrev completion is based on =completion-in-region= and can be used with Corfu.
+You may want to swap the =dabbrev-completion= with the =dabbrev-expand= key for
+easier access, if you prefer completion. Also take a look at the =cape-dabbrev=
+completion at point function provided by my [[https://github.com/minad/cape][Cape]] package.
+
+#+begin_src emacs-lisp
+ ;; Use Dabbrev with Corfu!
+ (use-package dabbrev
+ ;; Swap M-/ and C-M-/
+ :bind (("M-/" . dabbrev-completion)
+ ("C-M-/" . dabbrev-expand))
+ ;; Other useful Dabbrev configurations.
+ :custom
+ (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
+#+end_src
+
+If you start to configure the package more deeply, I recommend to give the
+Orderless completion style a try for filtering. Orderless completion is
+different from the familiar prefix TAB completion. Corfu can be used with the
+default completion styles. The use of Orderless is not a necessity.
+
+#+begin_src emacs-lisp
+ ;; Optionally use the `orderless' completion style.
+ (use-package orderless
+ :init
+ ;; Configure a custom style dispatcher (see the Consult wiki)
+ ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
+ ;; orderless-component-separator #'orderless-escapable-split-on-space)
+ (setq completion-styles '(orderless basic)
+ completion-category-defaults nil
+ completion-category-overrides '((file (styles . (partial-completion))))))
+#+end_src
+
+The =basic= completion style is specified as fallback in addition to =orderless= in
+order to ensure that completion commands which rely on dynamic completion
+tables, e.g., ~completion-table-dynamic~ or ~completion-table-in-turn~, work
+correctly. See =+orderless-dispatch= in the [[https://github.com/minad/consult/wiki][Consult wiki]] for an advanced Orderless
+style dispatcher. Additionally enable =partial-completion= for file path
+expansion. =partial-completion= is important for file wildcard support. Multiple
+files can be opened at once with =find-file= if you enter a wildcard. You may also
+give the =initials= completion style a try.
+
+See also the [[https://github.com/minad/corfu/wiki][Corfu Wiki]] and the [[https://github.com/minad/cape][Cape manual]] for additional Capf configuration
+tips. The Lsp-mode configuration is documented in the wiki. For more general
+documentation read the chapter about completion in the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html][Emacs manual]]. If you want
+to create your own Capfs, you can find documentation about completion in the
+[[https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html][Elisp manual]].
+
+** Auto completion
+
+Auto completion is disabled by default, but can be enabled by setting
+~corfu-auto=t~. Furthermore you may want to configure Corfu to quit completion
+eagerly, such that the completion popup stays out of your way when it appeared
+unexpectedly.
+
+#+begin_src emacs-lisp
+ ;; Enable auto completion and configure quitting
+ (setq corfu-auto t
+ corfu-quit-no-match 'separator) ;; or t
+#+end_src
+
+I recommend to experiment a bit with the various settings and key bindings to
+find a configuration which works for you. There is no one size fits all
+solution. Some people like auto completion, some like manual completion, some
+want to cycle with TAB and some with the arrow keys.
+
+In case you like aggressive auto completion settings, where the completion popup
+appears immediately, I recommend to use a cheap completion style like =basic=,
+which performs prefix filtering. In this case Corfu completion should still be
+very fast in buffers with efficient completion backends. You can try the
+following settings in an Elisp buffer or the Emacs scratch buffer.
+
+#+begin_src emacs-lisp
+ ;; Aggressive completion, cheap prefix filtering.
+ (setq-local corfu-auto t
+ corfu-auto-delay 0
+ corfu-auto-prefix 0
+ completion-styles '(basic))
+#+end_src
+
+If you want to combine fast prefix filtering and Orderless filtering you can
+still do that by defining a custom Orderless completion style via
+=orderless-define-completion-style=. We use a custom style dispatcher, which
+enables prefix filtering for input shorter than 4 characters. Note that such a
+setup is quite advanced. Please refer to the Orderless documentation and source
+code for further details.
+
+#+begin_src emacs-lisp
+ (defun orderless-fast-dispatch (word index total)
+ (and (= index 0) (= total 1) (length< word 4)
+ `(orderless-regexp . ,(concat "^" (regexp-quote word)))))
+
+ (orderless-define-completion-style orderless-fast
+ (orderless-style-dispatchers '(orderless-fast-dispatch))
+ (orderless-matching-styles '(orderless-literal orderless-regexp)))
+
+ (setq-local corfu-auto t
+ corfu-auto-delay 0
+ corfu-auto-prefix 0
+ completion-styles '(orderless-fast))
+#+end_src
+
+** Completing in the minibuffer
+
+Corfu can be used for completion in the minibuffer, since it relies on child
+frames to display the candidates. By default, ~global-corfu-mode~ does not
+activate ~corfu-mode~ in the minibuffer, to avoid interference with specialised
+minibuffer completion UIs like Vertico or Mct. However you may still want to
+enable Corfu completion for commands like ~M-:~ (~eval-expression~) or ~M-!~
+(~shell-command~), which read from the minibuffer. Activate ~corfu-mode~ only if
+~completion-at-point~ is bound in the minibuffer-local keymap to achieve this
+effect.
+
+#+begin_src emacs-lisp
+ (defun corfu-enable-in-minibuffer ()
+ "Enable Corfu in the minibuffer if `completion-at-point' is bound."
+ (when (where-is-internal #'completion-at-point (list (current-local-map)))
+ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ (corfu-mode 1)))
+ (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
+#+end_src
+
+You can also enable Corfu more generally for every minibuffer, as long as no
+other completion UI is active. If you use Mct or Vertico as your main minibuffer
+completion UI, the following snippet should yield the desired result.
+
+#+begin_src emacs-lisp
+ (defun corfu-enable-always-in-minibuffer ()
+ "Enable Corfu in the minibuffer if Vertico/Mct are not active."
+ (unless (or (bound-and-true-p mct--active)
+ (bound-and-true-p vertico--input))
+ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ (corfu-mode 1)))
+ (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
+#+end_src
+
+** Completing in the Eshell or Shell
+
+When completing in the Eshell I recommend conservative local settings without
+auto completion, such that the completion behavior is similar to widely used
+shells like Bash, Zsh or Fish.
+
+#+begin_src emacs-lisp
+ (add-hook 'eshell-mode-hook
+ (lambda ()
+ (setq-local corfu-auto nil)
+ (corfu-mode)))
+#+end_src
+
+When pressing =RET= while the Corfu popup is visible, the ~corfu-insert~ command
+will be invoked. This command does inserts the currently selected candidate, but
+it does not send the prompt input to Eshell or the comint process. Therefore you
+often have to press =RET= twice which feels like an unnecessary double
+confirmation. Fortunately it is easy to improve this! In my configuration I
+define the advice ~corfu-send-shell~ which sends the candidate after insertion.
+
+#+begin_src emacs-lisp
+ (defun corfu-send-shell (&rest _)
+ "Send completion candidate when inside comint/eshell."
+ (cond
+ ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
+ (eshell-send-input))
+ ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
+ (comint-send-input))))
+
+ (advice-add #'corfu-insert :after #'corfu-send-shell)
+#+end_src
+
+Shell completion uses the flexible ~Pcomplete~ mechanism internally, which allows
+you to program the completions per shell command. If you want to know more, look
+into this [[https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs][blog post]], which shows how to configure Pcomplete for git commands. I
+recommend the [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]] package which extends Pcomplete with completion support
+and helpful annotation support for more commands. Similar to the Fish shell,
+pcmpl-args uses man page parsing and --help output parsing to dynamically
+generate completions. This package brings Eshell completion to another level!
+
+Unfortunately Pcomplete has a few technical issues, which we can work around
+with the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions). Cape provides wrappers,
+which sanitize the Pcomplete function. Ideally the bugs in Pcomplete should be
+fixed upstream. *For now these two advices are strongly recommended to achieve a
+sane Eshell experience.*
+
+#+begin_src emacs-lisp
+ ;; Silence the pcomplete capf, no errors or messages!
+ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
+
+ ;; Ensure that pcomplete does not write to the buffer
+ ;; and behaves as a pure `completion-at-point-function'.
+ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
+#+end_src
+
+** Orderless completion
+
+[[https://github.com/oantolin/orderless][Orderless]] is an advanced completion style that supports multi-component search
+filters separated by a configurable character (space, by default). Normally,
+entering characters like space which lie outside the completion region
+boundaries (words, typically) causes Corfu to quit. This behavior is helpful
+with auto-completion, which may pop-up when not desired, e.g. on entering a new
+variable name. Just keep typing and Corfu will get out of the way.
+
+But orderless search terms can contain arbitrary characters; they are also
+interpreted as regular expressions. To use orderless, set ~corfu-separator~ (a
+space, by default) to the primary character of your orderless component
+separator.
+
+Then, when a new orderless component is desired, use =M-SPC=
+(~corfu-insert-separator~) to enter the /first/ component separator in the input,
+and arbitrary orderless search terms and new separators can be entered
+thereafter.
+
+To treat the entire input as Orderless input, you can set the customization
+option ~corfu-quit-at-boundary=t~. This disables the predicate which checks if the
+current completion boundary has been left. In contrast, if you /always/ want to
+quit at the boundary, simply set ~corfu-quit-at-boundary=nil~. By default
+~corfu-quit-at-boundary~ is set to ~separator~ which quits at completion boundaries
+as long as no separator has been inserted with ~corfu-insert-separator~.
+
+Finally, there exists the user option ~corfu-quit-no-match~ which is set to
+=separator= by default. With this setting Corfu stays alive as soon as you start
+advanced filtering with a ~corfu-separator~ even if there are no matches, for
+example due to a typo. As long as no separator character has been inserted with
+~corfu-insert-separator~, Corfu will still quit if there are no matches. This
+ensures that the Corfu popup goes away quickly if completion is not possible.
+
+In the following we show two configurations, one which works best with auto
+completion and one which may work better with manual completion if you prefer to
+always use =SPC= to separate the Orderless components.
+
+ #+begin_src emacs-lisp
+ ;; Auto completion example
+ (use-package corfu
+ :custom
+ (corfu-auto t) ;; Enable auto completion
+ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ :bind
+ ;; Another key binding can be used, such as S-SPC.
+ ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
+ :init
+ (global-corfu-mode))
+
+ ;; Manual completion example
+ (use-package corfu
+ :custom
+ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ :bind
+ ;; Configure SPC for separator insertion
+ (:map corfu-map ("SPC" . corfu-insert-separator))
+ :init
+ (global-corfu-mode))
+#+end_src
+
+** TAB-and-Go completion
+
+You may be interested in configuring Corfu in TAB-and-Go style. Pressing TAB
+moves to the next candidate and further input will then commit the selection.
+Note that further input will not expand snippets or templates, which may not be
+desired but which leads overall to a more predictable behavior. In order to
+force snippet expansion, confirm a candidate explicitly with ~RET~.
+
+#+begin_src emacs-lisp
+ (use-package corfu
+ ;; TAB-and-Go customizations
+ :custom
+ (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ (corfu-preselect-first nil) ;; Disable candidate preselection
+
+ ;; Use TAB for cycling, default is `corfu-complete'.
+ :bind
+ (:map corfu-map
+ ("TAB" . corfu-next)
+ ([tab] . corfu-next)
+ ("S-TAB" . corfu-previous)
+ ([backtab] . corfu-previous))
+
+ :init
+ (global-corfu-mode))
+#+end_src
+
+** Transfer completion to the minibuffer
+
+Sometimes it is useful to transfer the Corfu completion session to the
+minibuffer, since the minibuffer offers richer interaction features. In
+particular, [[https://github.com/oantolin/embark][Embark]] is available in the minibuffer, such that you can act on the
+candidates or export/collect the candidates to a separate buffer. Hopefully we
+can also add Corfu-support to Embark in the future, such that at least
+export/collect is possible directly from Corfu. But in my opinion having the
+ability to transfer the Corfu completion to the minibuffer is an even better
+feature, since further completion can be performed there.
+
+The command ~corfu-move-to-minibuffer~ is defined here in terms of
+~consult-completion-in-region~, which uses the minibuffer completion UI via
+~completing-read~.
+
+#+begin_src emacs-lisp
+ (defun corfu-move-to-minibuffer ()
+ (interactive)
+ (let ((completion-extra-properties corfu--extra)
+ completion-cycle-threshold completion-cycling)
+ (apply #'consult-completion-in-region completion-in-region--data)))
+ (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
+#+end_src
+
+* Key bindings
+
+Corfu uses a transient keymap ~corfu-map~ which is active while the popup is
+shown. The keymap defines the following remappings and bindings:
+
+- ~beginning-of-buffer~ -> ~corfu-first~
+- ~end-of-buffer~ -> ~corfu-last~
+- ~scroll-down-command~ -> ~corfu-scroll-down~
+- ~scroll-up-command~ -> ~corfu-scroll-up~
+- ~next-line~, =down=, =M-n= -> ~corfu-next~
+- ~previous-line~, =up=, =M-p= -> ~corfu-previous~
+- ~completion-at-point~, =TAB= -> ~corfu-complete~
+- =RET= -> ~corfu-insert~
+- =M-g= -> ~corfu-info-location~
+- =M-h= -> ~corfu-info-documentation~
+- =M-SPC= -> ~corfu-insert-separator~
+- =C-g= -> ~corfu-quit~
+- ~keyboard-escape-quit~ -> ~corfu-reset~
+
+* Extensions
+:properties:
+:custom_id: extensions
+:end:
+
+We maintain small extension packages to Corfu in this repository in the
+subdirectory [[https://github.com/minad/corfu/tree/main/extensions][extensions/]]. The extensions are installed together with Corfu if
+you pull the package from ELPA. The extensions are inactive by default and can
+be enabled manually if desired. Furthermore it is possible to install all of the
+files separately, both ~corfu.el~ and the ~corfu-*.el~ extensions. Currently the
+following extensions come with the Corfu ELPA package:
+
+- [[https://github.com/minad/corfu/blob/main/extensions/corfu-history.el][corfu-history]]: =corfu-history-mode= to remember selected candidates and to improve sorting.
+- [[https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el][corfu-indexed]]: =corfu-indexed-mode= to select indexed candidates with prefix arguments.
+- [[https://github.com/minad/corfu/blob/main/extensions/corfu-info.el][corfu-info]]: Actions to access the candidate location and documentation.
+- [[https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el][corfu-quick]]: Commands to select using Avy-style quick keys.
+
+See the Commentary of those files for configuration details.
+
+* Complementary packages
+
+Corfu works well together with all packages providing code completion via the
+~completion-at-point-functions~. Many modes and packages already provide a Capf
+out of the box. Nevertheless you may want to look into complementary packages to
+enhance your setup.
+
+- [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]]: The corfu-terminal package provides an overlay-based display
+ for Corfu, such that you can use Corfu in terminal Emacs.
+
+- [[https://github.com/galeo/corfu-doc][corfu-doc]]: The corfu-doc package displays the candidate documentation in a
+ popup next to the Corfu popup, similar to =company-quickhelp=.
+
+- [[https://github.com/oantolin/orderless][Orderless]]: Corfu supports completion styles, including the advanced
+ [[https://github.com/oantolin/orderless][Orderless]] completion style, where the filtering expressions are separated by
+ spaces or another character (see ~corfu-separator~).
+
+- [[https://github.com/minad/cape][Cape]]: Additional Capf backends and =completion-in-region= commands
+ are provided by the [[https://github.com/minad/cape][Cape]] package. Among others, the package supplies a file
+ path and a Dabbrev completion backend. Cape provides the ~cape-company-to-capf~
+ adapter to reuse Company backends in Corfu. Furthermore the function
+ ~cape-super-capf~ can merge multiple Capfs, such that the candidates of multiple
+ Capfs are displayed together at the same time.
+
+- [[https://github.com/jdtsmith/kind-icon][kind-icon]]: Icons are supported by Corfu via an external package. For example
+ the [[https://github.com/jdtsmith/kind-icon][kind-icon]] package provides beautifully styled SVG icons based on
+ monochromatic icon sets like material design.
+
+- [[https://github.com/JonWaltman/pcmpl-args.el][pcmpl-args]]: Extend the Eshell/Shell Pcomplete mechanism with support for many
+ more commands. Similar to the Fish shell, Pcomplete uses man page parsing to
+ dynamically retrieve the completions and helpful annotations. This package
+ brings Eshell completions to another level!
+
+- [[https://github.com/minad/tempel][Tempel]]: Tiny template/snippet package with templates in Lisp syntax, which
+ can be used in conjunction with Corfu.
+
+- [[https://github.com/minad/vertico][Vertico]]: You may also want to look into my [[https://github.com/minad/vertico][Vertico]] package. Vertico is the
+ minibuffer completion counterpart of Corfu.
+
+* Alternatives
+
+- [[https://github.com/company-mode/company-mode][Company]]: Company is a widely used and mature completion package, which
+ implements a similar interaction model and popup UI as Corfu. While Corfu
+ relies exclusively on the standard Emacs completion API (Capfs), Company
+ defines its own API for the backends. Company includes its completion
+ backends, which are incompatible with the Emacs completion infrastructure. As
+ a result of this design, Company is a more complex package than Corfu. Company
+ by default uses overlays for the popup in contrast to the child frames used by
+ Corfu. Overall both packages work well, but Company integrates less tightly
+ with Emacs. The ~completion-styles~ support is more limited and the
+ ~completion-at-point~ command and the ~completion-in-region~ function do not
+ invoke Company.
+
+- [[https://git.sr.ht/~protesilaos/mct][Mct]]: Protesilaos' Minibuffer Confines Transcended package supports both
+ minibuffer completion and completion in region. It reuses the default
+ completion UI for this purpose and installs a timer which live updates the
+ completion buffer. The main advantage of Mct is that you work with a regular
+ Emacs buffer instead of with a popup. You can take advantage of the usual
+ Emacs commands to navigate in the completions buffer. On top, Mct enhances the
+ movement such that you can quickly switch between the completions buffer and
+ the minibuffer or the region which is being completed. Mct does not support
+ timer-based auto completion, but the integration into Emacs is naturally
+ tight. Note that Mct development is currently [[https://protesilaos.com/codelog/2022-04-14-emacs-discontinue-mct/][discontinued]] due to recent
+ changes of the default completion UI on the Emacs master branch.
+
+- [[https://github.com/minad/consult][consult-completion-in-region]]: The Consult package provides the function
+ ~consult-completion-in-region~ which can be set as ~completion-in-region-function~
+ such that it handles ~completion-at-point~. The function works by transferring
+ the in-buffer completion to the minibuffer. In the minibuffer, the minibuffer
+ completion UI, for example [[https://github.com/minad/vertico][Vertico]] takes over. If you prefer to perform all
+ your completions in the minibuffer ~consult-completion-in-region~ is your best
+ option.
+
+* Contributions
+
+Since this package is part of [[http://elpa.gnu.org/packages/corfu.html][GNU ELPA]] contributions require a copyright
+assignment to the FSF.
diff --git a/elpa/corfu-0.27/corfu-autoloads.el b/elpa/corfu-0.27/corfu-autoloads.el
@@ -0,0 +1,151 @@
+;;; corfu-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*-
+;; Generated by the `loaddefs-generate' function.
+
+;; This file is part of GNU Emacs.
+
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+ (or (file-name-directory #$) (car load-path))))
+
+
+
+;;; Generated autoloads from corfu.el
+
+(autoload 'corfu-mode "corfu" "\
+Completion Overlay Region FUnction.
+
+This is a minor mode. If called interactively, toggle the `Corfu
+mode' mode. If the prefix argument is positive, enable the mode,
+and if it is zero or negative, disable the mode.
+
+If called from Lisp, toggle the mode if ARG is `toggle'. Enable
+the mode if ARG is nil, omitted, or is a positive number.
+Disable the mode if ARG is a negative number.
+
+To check whether the minor mode is enabled in the current buffer,
+evaluate `corfu-mode'.
+
+The mode's hook is called both when the mode is enabled and when
+it is disabled.
+
+(fn &optional ARG)" t nil)
+(put 'global-corfu-mode 'globalized-minor-mode t)
+(defvar global-corfu-mode nil "\
+Non-nil if Global Corfu mode is enabled.
+See the `global-corfu-mode' command
+for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `global-corfu-mode'.")
+(custom-autoload 'global-corfu-mode "corfu" nil)
+(autoload 'global-corfu-mode "corfu" "\
+Toggle Corfu mode in all buffers.
+With prefix ARG, enable Global Corfu mode if ARG is positive;
+otherwise, disable it.
+
+If called from Lisp, toggle the mode if ARG is `toggle'.
+Enable the mode if ARG is nil, omitted, or is a positive number.
+Disable the mode if ARG is a negative number.
+
+Corfu mode is enabled in all buffers where `corfu--on' would do it.
+
+See `corfu-mode' for more information on Corfu mode.
+
+(fn &optional ARG)" t nil)
+(register-definition-prefixes "corfu" '("corfu-"))
+
+
+;;; Generated autoloads from corfu-history.el
+
+(defvar corfu-history-mode nil "\
+Non-nil if Corfu-History mode is enabled.
+See the `corfu-history-mode' command
+for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `corfu-history-mode'.")
+(custom-autoload 'corfu-history-mode "corfu-history" nil)
+(autoload 'corfu-history-mode "corfu-history" "\
+Update Corfu history and sort completions by history.
+
+This is a global minor mode. If called interactively, toggle the
+`Corfu-History mode' mode. If the prefix argument is positive,
+enable the mode, and if it is zero or negative, disable the mode.
+
+If called from Lisp, toggle the mode if ARG is `toggle'. Enable
+the mode if ARG is nil, omitted, or is a positive number.
+Disable the mode if ARG is a negative number.
+
+To check whether the minor mode is enabled in the current buffer,
+evaluate `(default-value \\='corfu-history-mode)'.
+
+The mode's hook is called both when the mode is enabled and when
+it is disabled.
+
+(fn &optional ARG)" t nil)
+(register-definition-prefixes "corfu-history" '("corfu-history"))
+
+
+;;; Generated autoloads from corfu-indexed.el
+
+(defvar corfu-indexed-mode nil "\
+Non-nil if Corfu-Indexed mode is enabled.
+See the `corfu-indexed-mode' command
+for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `corfu-indexed-mode'.")
+(custom-autoload 'corfu-indexed-mode "corfu-indexed" nil)
+(autoload 'corfu-indexed-mode "corfu-indexed" "\
+Prefix candidates with indices.
+
+This is a global minor mode. If called interactively, toggle the
+`Corfu-Indexed mode' mode. If the prefix argument is positive,
+enable the mode, and if it is zero or negative, disable the mode.
+
+If called from Lisp, toggle the mode if ARG is `toggle'. Enable
+the mode if ARG is nil, omitted, or is a positive number.
+Disable the mode if ARG is a negative number.
+
+To check whether the minor mode is enabled in the current buffer,
+evaluate `(default-value \\='corfu-indexed-mode)'.
+
+The mode's hook is called both when the mode is enabled and when
+it is disabled.
+
+(fn &optional ARG)" t nil)
+(register-definition-prefixes "corfu-indexed" '("corfu-indexed-"))
+
+
+;;; Generated autoloads from corfu-info.el
+
+(autoload 'corfu-info-documentation "corfu-info" "\
+Show documentation of current candidate." t nil)
+(autoload 'corfu-info-location "corfu-info" "\
+Show location of current candidate." t nil)
+(register-definition-prefixes "corfu-info" '("corfu-info--restore-on-next-command"))
+
+
+;;; Generated autoloads from corfu-quick.el
+
+(autoload 'corfu-quick-jump "corfu-quick" "\
+Jump to candidate using quick keys." t nil)
+(autoload 'corfu-quick-insert "corfu-quick" "\
+Insert candidate using quick keys." t nil)
+(autoload 'corfu-quick-complete "corfu-quick" "\
+Complete candidate using quick keys." t nil)
+(register-definition-prefixes "corfu-quick" '("corfu-quick"))
+
+;;; End of scraped data
+
+(provide 'corfu-autoloads)
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8-emacs-unix
+;; End:
+
+;;; corfu-autoloads.el ends here
diff --git a/elpa/corfu-0.27/corfu-history.el b/elpa/corfu-0.27/corfu-history.el
@@ -0,0 +1,106 @@
+;;; corfu-history.el --- Sorting by history for Corfu -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2022
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1") (corfu "0.27"))
+;; Homepage: https://github.com/minad/corfu
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Enable `corfu-history-mode' to sort candidates by their history
+;; position. Maintain a list of recently selected candidates. In order
+;; to save the history across Emacs sessions, enable `savehist-mode' and
+;; add `corfu-history' to `savehist-additional-variables'.
+;;
+;; (corfu-history-mode 1)
+;; (savehist-mode 1)
+;; (add-to-list 'savehist-additional-variables 'corfu-history)
+
+;;; Code:
+
+(require 'corfu)
+(eval-when-compile
+ (require 'cl-lib))
+
+(defcustom corfu-history-length nil
+ "Corfu history length."
+ :type '(choice (const nil) integer)
+ :group 'corfu)
+
+(defvar corfu-history--hash nil
+ "Hash table of Corfu candidates.")
+
+(defvar corfu-history nil
+ "History of Corfu candidates.")
+
+(defun corfu-history--sort-predicate (x y)
+ "Sorting predicate which compares X and Y."
+ (pcase-let ((`(,sx . ,hx) x)
+ (`(,sy . ,hy) y))
+ (or (< hx hy)
+ (and (= hx hy)
+ (or (< (length sx) (length sy))
+ (and (= (length sx) (length sy))
+ (string< sx sy)))))))
+
+(defun corfu-history--sort (candidates)
+ "Sort CANDIDATES by history."
+ (unless corfu-history--hash
+ (setq corfu-history--hash (make-hash-table :test #'equal :size (length corfu-history)))
+ (cl-loop for elem in corfu-history for index from 0 do
+ (unless (gethash elem corfu-history--hash)
+ (puthash elem index corfu-history--hash))))
+ ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by
+ ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is
+ ;; shorter than 2**16 entries.
+ (cl-loop for cand on candidates do
+ (setcar cand (cons (car cand)
+ (+ (ash (gethash (car cand) corfu-history--hash #xFFFF) 13)
+ (length (car cand))))))
+ (setq candidates (sort candidates #'corfu-history--sort-predicate))
+ (cl-loop for cand on candidates do (setcar cand (caar cand)))
+ candidates)
+
+(defun corfu-history--insert (&rest _)
+ "Advice for `corfu--insert'."
+ (when (>= corfu--index 0)
+ (add-to-history 'corfu-history
+ (substring-no-properties
+ (nth corfu--index corfu--candidates))
+ corfu-history-length)
+ (setq corfu-history--hash nil)))
+
+;;;###autoload
+(define-minor-mode corfu-history-mode
+ "Update Corfu history and sort completions by history."
+ :global t
+ :group 'corfu
+ (cond
+ (corfu-history-mode
+ (setq corfu-sort-function #'corfu-history--sort)
+ (advice-add #'corfu--insert :before #'corfu-history--insert))
+ (t
+ (setq corfu-sort-function #'corfu-sort-length-alpha)
+ (advice-remove #'corfu--insert #'corfu-history--insert))))
+
+(provide 'corfu-history)
+;;; corfu-history.el ends here
diff --git a/elpa/corfu-0.27/corfu-indexed.el b/elpa/corfu-0.27/corfu-indexed.el
@@ -0,0 +1,108 @@
+;;; corfu-indexed.el --- Select indexed candidates -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2022
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1") (corfu "0.27"))
+;; Homepage: https://github.com/minad/corfu
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package is a Corfu extension, which prefixes candidates with indices if
+;; enabled via `corfu-indexed-mode'. It allows you to select candidates with
+;; prefix arguments. This is designed to be a faster alternative to selecting a
+;; candidate with `corfu-next' and `corfu-previous'.
+
+;;; Code:
+
+(require 'corfu)
+(eval-when-compile
+ (require 'cl-lib))
+
+(defface corfu-indexed
+ '((default :height 0.75)
+ (((class color) (min-colors 88) (background dark))
+ :foreground "#f4f4f4" :background "#323232")
+ (((class color) (min-colors 88) (background light))
+ :foreground "#404148" :background "#d7d7d7")
+ (t :background "black"))
+ "Face used for the candidate index prefix."
+ :group 'corfu-faces)
+
+(defcustom corfu-indexed-start 0
+ "Start of the indexing."
+ :group 'corfu
+ :type 'integer)
+
+(defvar corfu-indexed--commands
+ '(corfu-insert corfu-complete)
+ "Commands that should be indexed.")
+
+(defun corfu-indexed--affixate (cands)
+ "Advice for `corfu--affixate' which prefixes the CANDS with an index."
+ (setq cands (cdr cands))
+ (let* ((space #(" " 0 1 (face (:height 0.5 :inherit corfu-indexed))))
+ (width (if (> (+ corfu-indexed-start (length cands)) 10) 2 1))
+ (fmt (concat space
+ (propertize (format "%%%ds" width)
+ 'face 'corfu-indexed)
+ space))
+ (align
+ (propertize (make-string width ?\s)
+ 'display
+ `(space :align-to (+ left ,(1+ width))))))
+ (cl-loop for cand in cands for index from corfu-indexed-start do
+ (setf (cadr cand)
+ (concat
+ (propertize " " 'display (format fmt index))
+ align
+ (cadr cand))))
+ (cons t cands)))
+
+(defun corfu-indexed--handle-prefix (orig &rest args)
+ "Handle prefix argument before calling ORIG function with ARGS."
+ (if (and current-prefix-arg (called-interactively-p t))
+ (let ((corfu--index (+ corfu--scroll
+ (- (prefix-numeric-value current-prefix-arg)
+ corfu-indexed-start))))
+ (if (or (< corfu--index 0)
+ (>= corfu--index corfu--total)
+ (>= corfu--index (+ corfu--scroll corfu-count)))
+ (message "Out of range")
+ (funcall orig)))
+ (apply orig args)))
+
+;;;###autoload
+(define-minor-mode corfu-indexed-mode
+ "Prefix candidates with indices."
+ :global t :group 'corfu
+ (cond
+ (corfu-indexed-mode
+ (advice-add #'corfu--affixate :filter-return #'corfu-indexed--affixate)
+ (dolist (cmd corfu-indexed--commands)
+ (advice-add cmd :around #'corfu-indexed--handle-prefix)))
+ (t
+ (advice-remove #'corfu--affixate #'corfu-indexed--affixate)
+ (dolist (cmd corfu-indexed--commands)
+ (advice-remove cmd #'corfu-indexed--handle-prefix)))))
+
+(provide 'corfu-indexed)
+;;; corfu-indexed.el ends here
diff --git a/elpa/corfu-0.27/corfu-info.el b/elpa/corfu-0.27/corfu-info.el
@@ -0,0 +1,97 @@
+;;; corfu-info.el --- Show candidate information in separate buffer -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2022
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1") (corfu "0.27"))
+;; Homepage: https://github.com/minad/corfu
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This Corfu extension provides commands to show additional information to the
+;; candidates in a separate buffer. The commands `corfu-info-location' and
+;; `corfu-info-documentation' are bound by default in the `corfu-map' to M-g and
+;; M-h respectively.
+
+;;; Code:
+
+(require 'corfu)
+(eval-when-compile
+ (require 'subr-x))
+
+(defun corfu-info--restore-on-next-command ()
+ "Restore window configuration before next command."
+ (let ((config (current-window-configuration))
+ (other other-window-scroll-buffer)
+ (restore (make-symbol "corfu--restore")))
+ (fset restore
+ (lambda ()
+ (setq other-window-scroll-buffer other)
+ (unless (memq this-command '(scroll-other-window scroll-other-window-down))
+ (when (memq this-command '(corfu-quit corfu-reset))
+ (setq this-command #'ignore))
+ (remove-hook 'pre-command-hook restore)
+ (set-window-configuration config))))
+ (add-hook 'pre-command-hook restore)))
+
+;;;###autoload
+(defun corfu-info-documentation ()
+ "Show documentation of current candidate."
+ (interactive)
+ ;; Company support, taken from `company.el', see `company-show-doc-buffer'.
+ (when (< corfu--index 0)
+ (user-error "No candidate selected"))
+ (if-let* ((fun (plist-get corfu--extra :company-doc-buffer))
+ (res (funcall fun (nth corfu--index corfu--candidates))))
+ (let ((buf (or (car-safe res) res)))
+ (corfu-info--restore-on-next-command)
+ (setq other-window-scroll-buffer (get-buffer buf))
+ (set-window-start (display-buffer buf t) (or (cdr-safe res) (point-min))))
+ (user-error "No documentation available")))
+
+;;;###autoload
+(defun corfu-info-location ()
+ "Show location of current candidate."
+ (interactive)
+ ;; Company support, taken from `company.el', see `company-show-location'.
+ (when (< corfu--index 0)
+ (user-error "No candidate selected"))
+ (if-let* ((fun (plist-get corfu--extra :company-location))
+ (loc (funcall fun (nth corfu--index corfu--candidates))))
+ (let ((buf (or (and (bufferp (car loc)) (car loc)) (find-file-noselect (car loc) t))))
+ (corfu-info--restore-on-next-command)
+ (setq other-window-scroll-buffer buf)
+ (with-selected-window (display-buffer buf t)
+ (save-restriction
+ (widen)
+ (if (bufferp (car loc))
+ (goto-char (cdr loc))
+ (goto-char (point-min))
+ (forward-line (1- (cdr loc))))
+ (set-window-start nil (point)))))
+ (user-error "No candidate location available")))
+
+;; Emacs 28: Do not show Corfu commands with M-X
+(put #'corfu-info-location 'completion-predicate #'ignore)
+(put #'corfu-info-documentation 'completion-predicate #'ignore)
+
+(provide 'corfu-info)
+;;; corfu-info.el ends here
diff --git a/elpa/corfu-0.27/corfu-pkg.el b/elpa/corfu-0.27/corfu-pkg.el
@@ -0,0 +1,2 @@
+;; Generated package description from corfu.el -*- no-byte-compile: t -*-
+(define-package "corfu" "0.27" "Completion Overlay Region FUnction" '((emacs "27.1")) :commit "42f777680ee50fa1328326c7be0c045e9c3ccb69" :authors '(("Daniel Mendler" . "mail@daniel-mendler.de")) :maintainer '("Daniel Mendler" . "mail@daniel-mendler.de") :url "https://github.com/minad/corfu")
diff --git a/elpa/corfu-0.27/corfu-quick.el b/elpa/corfu-0.27/corfu-quick.el
@@ -0,0 +1,153 @@
+;;; corfu-quick.el --- Quick keys for Corfu -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Luis Henriquez-Perez <luis@luishp.xyz>, Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2022
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1") (corfu "0.27"))
+;; Homepage: https://github.com/minad/corfu
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package is a Corfu extension, which prefixes candidates with
+;; quick keys. Typing these quick keys allows you to select the
+;; candidate in front of them. This is designed to be a faster
+;; alternative to selecting a candidate with `corfu-next' and
+;; `corfu-previous'.
+;; (define-key corfu-map "\M-q" #'corfu-quick-complete)
+;; (define-key corfu-map "\C-q" #'corfu-quick-insert)
+
+;;; Code:
+
+(require 'corfu)
+(eval-when-compile
+ (require 'cl-lib))
+
+(defcustom corfu-quick1 "asdfgh"
+ "First level quick keys."
+ :type 'string
+ :group 'corfu)
+
+(defcustom corfu-quick2 "jkl"
+ "Second level quick keys."
+ :type 'string
+ :group 'corfu)
+
+(defface corfu-quick1
+ '((((class color) (min-colors 88) (background dark))
+ :background "#0050af" :foreground "white" :inherit bold)
+ (((class color) (min-colors 88) (background light))
+ :background "#7feaff" :foreground "black" :inherit bold)
+ (t :background "blue" :foreground "white" :inherit bold))
+ "Face used for the first quick key."
+ :group 'corfu-faces)
+
+(defface corfu-quick2
+ '((((class color) (min-colors 88) (background dark))
+ :background "#7f1f7f" :foreground "white" :inherit bold)
+ (((class color) (min-colors 88) (background light))
+ :background "#ffaaff" :foreground "black" :inherit bold)
+ (t :background "magenta" :foreground "white" :inherit bold))
+ "Face used for the second quick key."
+ :group 'corfu-faces)
+
+(defun corfu-quick--keys (two idx) ;; See vertico-quick--keys
+ "Format quick keys prefix.
+IDX is the current candidate index.
+TWO is non-nil if two keys should be displayed."
+ (let* ((fst (length corfu-quick1))
+ (snd (length corfu-quick2))
+ (len (+ fst snd)))
+ (if (>= idx fst)
+ (let ((first (elt corfu-quick2 (mod (/ (- idx fst) len) snd)))
+ (second (elt (concat corfu-quick1 corfu-quick2) (mod (- idx fst) len))))
+ (cond
+ ((eq first two)
+ (list
+ (concat " " (propertize (char-to-string second) 'face 'corfu-quick1))
+ (cons second (+ corfu--scroll idx))))
+ (two
+ (list " "))
+ (t
+ (list
+ (concat (propertize (char-to-string first) 'face 'corfu-quick1)
+ (propertize (char-to-string second) 'face 'corfu-quick2))
+ (cons first (list first))))))
+ (let ((first (elt corfu-quick1 (mod idx fst))))
+ (if two
+ (list " ")
+ (list
+ (concat (propertize (char-to-string first) 'face 'corfu-quick1) " ")
+ (cons first (+ corfu--scroll idx))))))))
+
+(defun corfu-quick--read (&optional first)
+ "Read quick key given FIRST pressed key."
+ (cl-letf* ((list nil)
+ (space1 (propertize " " 'display
+ `(space :width
+ (+ 0.5 (,(alist-get
+ 'child-frame-border-width
+ corfu--frame-parameters))))))
+ (space2 #(" " 0 1 (display (space :width 0.5))))
+ (orig (symbol-function #'corfu--affixate))
+ ((symbol-function #'corfu--affixate)
+ (lambda (cands)
+ (setq cands (cdr (funcall orig cands)))
+ (cl-loop for cand in cands for index from 0 do
+ (pcase-let ((`(,keys . ,events) (corfu-quick--keys first index)))
+ (setq list (nconc events list))
+ (setf (cadr cand) (concat space1 (propertize " " 'display keys) space2))))
+ (cons t cands)))
+ ;; Increase minimum width to avoid odd jumping
+ (corfu-min-width (+ 3 corfu-min-width)))
+ (corfu--candidates-popup (car completion-in-region--data))
+ (alist-get (read-key) list)))
+
+;;;###autoload
+(defun corfu-quick-jump ()
+ "Jump to candidate using quick keys."
+ (interactive)
+ (corfu--echo-cancel)
+ (if (= corfu--total 0)
+ (and (message "No match") nil)
+ (let ((idx (corfu-quick--read)))
+ (when (consp idx) (setq idx (corfu-quick--read (car idx))))
+ (when idx (setq corfu--index idx)))))
+
+;;;###autoload
+(defun corfu-quick-insert ()
+ "Insert candidate using quick keys."
+ (interactive)
+ (when (corfu-quick-jump)
+ (corfu-insert)))
+
+;;;###autoload
+(defun corfu-quick-complete ()
+ "Complete candidate using quick keys."
+ (interactive)
+ (when (corfu-quick-jump)
+ (corfu-complete)))
+
+;; Emacs 28: Do not show Corfu commands in M-X
+(dolist (sym '(corfu-quick-jump corfu-quick-insert corfu-quick-complete))
+ (put sym 'completion-predicate #'ignore))
+
+(provide 'corfu-quick)
+;;; corfu-quick.el ends here
diff --git a/elpa/corfu-0.27/corfu.el b/elpa/corfu-0.27/corfu.el
@@ -0,0 +1,1292 @@
+;;; corfu.el --- Completion Overlay Region FUnction -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021, 2022 Free Software Foundation, Inc.
+
+;; Author: Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2021
+;; Version: 0.27
+;; Package-Requires: ((emacs "27.1"))
+;; Homepage: https://github.com/minad/corfu
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Corfu enhances the default completion in region function with a
+;; completion overlay. The current candidates are shown in a popup
+;; below or above the point. Corfu can be considered the minimalistic
+;; completion-in-region counterpart of Vertico.
+
+;;; Code:
+
+(require 'seq)
+(eval-when-compile
+ (require 'cl-lib)
+ (require 'subr-x))
+
+(defgroup corfu nil
+ "Completion Overlay Region FUnction."
+ :group 'convenience
+ :prefix "corfu-")
+
+(defcustom corfu-count 10
+ "Maximal number of candidates to show."
+ :type 'integer)
+
+(defcustom corfu-scroll-margin 2
+ "Number of lines at the top and bottom when scrolling.
+The value should lie between 0 and corfu-count/2."
+ :type 'integer)
+
+(defcustom corfu-min-width 15
+ "Popup minimum width in characters."
+ :type 'integer)
+
+(defcustom corfu-max-width 100
+ "Popup maximum width in characters."
+ :type 'integer)
+
+(defcustom corfu-cycle nil
+ "Enable cycling for `corfu-next' and `corfu-previous'."
+ :type 'boolean)
+
+(defcustom corfu-on-exact-match 'insert
+ "Configure how a single exact match should be handled."
+ :type '(choice (const insert) (const quit) (const nil)))
+
+(defcustom corfu-continue-commands
+ ;; nil is undefined command
+ '(nil ignore universal-argument universal-argument-more digit-argument
+ "\\`corfu-" "\\`scroll-other-window")
+ "Continue Corfu completion after executing these commands."
+ :type '(repeat (choice regexp symbol)))
+
+(defcustom corfu-preview-current 'insert
+ "Preview currently selected candidate.
+If the variable has the value `insert', the candidate is automatically
+inserted on further input."
+ :type '(choice boolean (const insert)))
+
+(defcustom corfu-preselect-first t
+ "Preselect first candidate."
+ :type 'boolean)
+
+(defcustom corfu-separator ?\s
+ "Component separator character.
+The character used for separating components in the input. The presence
+of this separator character will inhibit quitting at completion
+boundaries, so that any further characters can be entered. To enter the
+first separator character, call `corfu-insert-separator' (bound to M-SPC
+by default). Useful for multi-component completion styles such as
+Orderless."
+ :type 'character)
+
+(defcustom corfu-quit-at-boundary 'separator
+ "Automatically quit at completion boundary.
+nil: Never quit at completion boundary.
+t: Always quit at completion boundary.
+separator: Quit at boundary if no `corfu-separator' has been inserted."
+ :type '(choice boolean (const separator)))
+
+(defcustom corfu-quit-no-match 'separator
+ "Automatically quit if no matching candidate is found.
+nil: Stay alive even if there is no match.
+t: Quit if there is no match.
+separator: Only stay alive if there is no match and
+`corfu-separator' has been inserted."
+ :type '(choice boolean (const separator)))
+
+(defcustom corfu-excluded-modes nil
+ "List of modes excluded by `global-corfu-mode'."
+ :type '(repeat symbol))
+
+(defcustom corfu-left-margin-width 0.5
+ "Width of the left margin in units of the character width."
+ :type 'float)
+
+(defcustom corfu-right-margin-width 0.5
+ "Width of the right margin in units of the character width."
+ :type 'float)
+
+(defcustom corfu-bar-width 0.2
+ "Width of the bar in units of the character width."
+ :type 'float)
+
+(defcustom corfu-echo-documentation '(1.0 . 0.2)
+ "Show documentation string in the echo area after that number of seconds.
+Set to nil to disable the echo message or to t for an instant message.
+The value can be a pair of two floats to specify initial and subsequent
+delay."
+ :type '(choice (const :tag "Never" nil)
+ (const :tag "Instant" t)
+ (number :tag "Delay in seconds")
+ (cons :tag "Two Delays"
+ (choice :tag "Initial " number)
+ (choice :tag "Subsequent" number))))
+
+(defcustom corfu-margin-formatters nil
+ "Registry for margin formatter functions.
+Each function of the list is called with the completion metadata as
+argument until an appropriate formatter is found. The function should
+return a formatter function, which takes the candidate string and must
+return a string, possibly an icon."
+ :type 'hook)
+
+(defcustom corfu-sort-function #'corfu-sort-length-alpha
+ "Default sorting function, used if no `display-sort-function' is specified."
+ :type `(choice
+ (const :tag "No sorting" nil)
+ (const :tag "By length and alpha" ,#'corfu-sort-length-alpha)
+ (function :tag "Custom function")))
+
+(defcustom corfu-sort-override-function nil
+ "Override sort function which overrides the `display-sort-function'."
+ :type '(choice (const nil) function))
+
+(defcustom corfu-auto-prefix 3
+ "Minimum length of prefix for auto completion.
+The completion backend can override this with
+:company-prefix-length."
+ :type 'integer)
+
+(defcustom corfu-auto-delay 0.2
+ "Delay for auto completion."
+ :type 'float)
+
+(defcustom corfu-auto-commands
+ '("self-insert-command\\'"
+ c-electric-colon c-electric-lt-gt c-electric-slash c-scope-operator)
+ "Commands which initiate auto completion."
+ :type '(repeat (choice regexp symbol)))
+
+(defcustom corfu-auto nil
+ "Enable auto completion."
+ :type 'boolean)
+
+(defgroup corfu-faces nil
+ "Faces used by Corfu."
+ :group 'corfu
+ :group 'faces)
+
+(defface corfu-default
+ '((((class color) (min-colors 88) (background dark)) :background "#191a1b")
+ (((class color) (min-colors 88) (background light)) :background "#f0f0f0")
+ (t :background "gray"))
+ "Default face, foreground and background colors used for the popup.")
+
+(defface corfu-current
+ '((((class color) (min-colors 88) (background dark))
+ :background "#00415e" :foreground "white")
+ (((class color) (min-colors 88) (background light))
+ :background "#c0efff" :foreground "black")
+ (t :background "blue" :foreground "white"))
+ "Face used to highlight the currently selected candidate.")
+
+(defface corfu-bar
+ '((((class color) (min-colors 88) (background dark)) :background "#a8a8a8")
+ (((class color) (min-colors 88) (background light)) :background "#505050")
+ (t :background "gray"))
+ "The background color is used for the scrollbar indicator.")
+
+(defface corfu-border
+ '((((class color) (min-colors 88) (background dark)) :background "#323232")
+ (((class color) (min-colors 88) (background light)) :background "#d7d7d7")
+ (t :background "gray"))
+ "The background color used for the thin border.")
+
+(defface corfu-echo
+ '((t :inherit completions-annotations))
+ "Face used for echo area messages.")
+
+(defface corfu-annotations
+ '((t :inherit completions-annotations))
+ "Face used for annotations.")
+
+(defface corfu-deprecated
+ '((t :inherit shadow :strike-through t))
+ "Face used for deprecated candidates.")
+
+(defvar corfu-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [remap beginning-of-buffer] #'corfu-first)
+ (define-key map [remap end-of-buffer] #'corfu-last)
+ (define-key map [remap scroll-down-command] #'corfu-scroll-down)
+ (define-key map [remap scroll-up-command] #'corfu-scroll-up)
+ (define-key map [remap next-line] #'corfu-next)
+ (define-key map [remap previous-line] #'corfu-previous)
+ (define-key map [remap completion-at-point] #'corfu-complete)
+ (define-key map [down] #'corfu-next)
+ (define-key map [up] #'corfu-previous)
+ (define-key map [remap keyboard-escape-quit] #'corfu-reset)
+ ;; XXX [tab] is bound because of org-mode
+ ;; The binding should be removed from org-mode-map.
+ (define-key map [tab] #'corfu-complete)
+ (define-key map "\M-n" #'corfu-next)
+ (define-key map "\M-p" #'corfu-previous)
+ (define-key map "\C-g" #'corfu-quit)
+ (define-key map "\r" #'corfu-insert)
+ (define-key map "\t" #'corfu-complete)
+ (define-key map "\M-g" 'corfu-info-location)
+ (define-key map "\M-h" 'corfu-info-documentation)
+ (define-key map "\M- " #'corfu-insert-separator)
+ map)
+ "Corfu keymap used when popup is shown.")
+
+(defvar corfu--auto-timer nil
+ "Auto completion timer.")
+
+(defvar-local corfu--candidates nil
+ "List of candidates.")
+
+(defvar-local corfu--metadata nil
+ "Completion metadata.")
+
+(defvar-local corfu--base ""
+ "Base string, which is concatenated with the candidate.")
+
+(defvar-local corfu--total 0
+ "Length of the candidate list `corfu--candidates'.")
+
+(defvar-local corfu--highlight #'identity
+ "Deferred candidate highlighting function.")
+
+(defvar-local corfu--index -1
+ "Index of current candidate or negative for prompt selection.")
+
+(defvar-local corfu--preselect -1
+ "Index of preselected candidate, negative for prompt selection.")
+
+(defvar-local corfu--scroll 0
+ "Scroll position.")
+
+(defvar-local corfu--input nil
+ "Cons of last prompt contents and point.")
+
+(defvar-local corfu--preview-ov nil
+ "Current candidate overlay.")
+
+(defvar-local corfu--extra nil
+ "Extra completion properties.")
+
+(defvar-local corfu--change-group nil
+ "Undo change group.")
+
+(defvar-local corfu--echo-timer nil
+ "Echo area message timer.")
+
+(defvar-local corfu--echo-message nil
+ "Last echo message.")
+
+(defvar corfu--frame nil
+ "Popup frame.")
+
+(defvar corfu--frame-timer nil
+ "Frame hide timer.")
+
+(defconst corfu--state-vars
+ '(corfu--base
+ corfu--candidates
+ corfu--highlight
+ corfu--index
+ corfu--preselect
+ corfu--scroll
+ corfu--input
+ corfu--total
+ corfu--preview-ov
+ corfu--extra
+ corfu--echo-timer
+ corfu--echo-message
+ corfu--change-group
+ corfu--metadata)
+ "Buffer-local state variables used by Corfu.")
+
+(defvar corfu--frame-parameters
+ '((no-accept-focus . t)
+ (no-focus-on-map . t)
+ (min-width . t)
+ (min-height . t)
+ (width . 0)
+ (height . 0)
+ (border-width . 0)
+ (child-frame-border-width . 1)
+ (left-fringe . 0)
+ (right-fringe . 0)
+ (vertical-scroll-bars . nil)
+ (horizontal-scroll-bars . nil)
+ (menu-bar-lines . 0)
+ (tool-bar-lines . 0)
+ (tab-bar-lines . 0)
+ (no-other-frame . t)
+ (unsplittable . t)
+ (undecorated . t)
+ (cursor-type . nil)
+ (visibility . nil)
+ (no-special-glyphs . t)
+ (desktop-dont-save . t))
+ "Default child frame parameters.")
+
+(defvar corfu--buffer-parameters
+ '((mode-line-format . nil)
+ (header-line-format . nil)
+ (tab-line-format . nil)
+ (tab-bar-format . nil) ;; Emacs 28 tab-bar-format
+ (frame-title-format . "")
+ (truncate-lines . t)
+ (cursor-in-non-selected-windows . nil)
+ (cursor-type . nil)
+ (show-trailing-whitespace . nil)
+ (display-line-numbers . nil)
+ (left-fringe-width . nil)
+ (right-fringe-width . nil)
+ (left-margin-width . 0)
+ (right-margin-width . 0)
+ (fringes-outside-margins . 0)
+ (fringe-indicator-alist . nil)
+ (indicate-empty-lines . nil)
+ (indicate-buffer-boundaries . nil)
+ (buffer-read-only . t))
+ "Default child frame buffer parameters.")
+
+(defvar corfu--mouse-ignore-map
+ (let ((map (make-sparse-keymap)))
+ (dotimes (i 7)
+ (dolist (k '(mouse down-mouse drag-mouse double-mouse triple-mouse))
+ (define-key map (vector (intern (format "%s-%s" k (1+ i)))) #'ignore)))
+ map)
+ "Ignore all mouse clicks.")
+
+(defun corfu--make-buffer (content)
+ "Create corfu buffer with CONTENT."
+ (let ((fr face-remapping-alist)
+ (ls line-spacing)
+ (buffer (get-buffer-create " *corfu*")))
+ (with-current-buffer buffer
+ ;;; XXX HACK install mouse ignore map
+ (use-local-map corfu--mouse-ignore-map)
+ (dolist (var corfu--buffer-parameters)
+ (set (make-local-variable (car var)) (cdr var)))
+ (setq-local face-remapping-alist (copy-tree fr)
+ line-spacing ls)
+ (cl-pushnew 'corfu-default (alist-get 'default face-remapping-alist))
+ (let ((inhibit-modification-hooks t)
+ (inhibit-read-only t))
+ (erase-buffer)
+ (insert content)
+ (goto-char (point-min))))
+ buffer))
+
+;; Function adapted from posframe.el by tumashu
+(defvar x-gtk-resize-child-frames) ;; Not present on non-gtk builds
+(defun corfu--make-frame (x y width height content)
+ "Show child frame at X/Y with WIDTH/HEIGHT and CONTENT."
+ (let* ((window-min-height 1)
+ (window-min-width 1)
+ (x-gtk-resize-child-frames
+ (let ((case-fold-search t))
+ (and
+ ;; XXX HACK to fix resizing on gtk3/gnome taken from posframe.el
+ ;; More information:
+ ;; * https://github.com/minad/corfu/issues/17
+ ;; * https://gitlab.gnome.org/GNOME/mutter/-/issues/840
+ ;; * https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00001.html
+ (string-match-p "gtk3" system-configuration-features)
+ (string-match-p "gnome\\|cinnamon"
+ (or (getenv "XDG_CURRENT_DESKTOP")
+ (getenv "DESKTOP_SESSION") ""))
+ 'resize-mode)))
+ (after-make-frame-functions)
+ (edge (window-inside-pixel-edges))
+ (ch (default-line-height))
+ (border (alist-get 'child-frame-border-width corfu--frame-parameters))
+ (x (max border (min (+ (car edge) x (- border))
+ (- (frame-pixel-width) width))))
+ (yb (+ (cadr edge) (window-tab-line-height) y ch))
+ (y (if (> (+ yb (* corfu-count ch) ch ch) (frame-pixel-height))
+ (- yb height ch 1)
+ yb))
+ (buffer (corfu--make-buffer content))
+ (parent (window-frame)))
+ (unless (and (frame-live-p corfu--frame)
+ (eq (frame-parent corfu--frame) parent))
+ (when corfu--frame (delete-frame corfu--frame))
+ (setq corfu--frame (make-frame
+ `((parent-frame . ,parent)
+ (minibuffer . ,(minibuffer-window parent))
+ ;; Set `internal-border-width' for Emacs 27
+ (internal-border-width . ,border)
+ ,@corfu--frame-parameters))))
+ ;; XXX HACK Setting the same frame-parameter/face-background is not a nop.
+ ;; Check explicitly before applying the setting. Without the check, the
+ ;; frame flickers on Mac.
+ ;; XXX HACK We have to apply the face background before adjusting the frame
+ ;; parameter, otherwise the border is not updated (BUG!).
+ (let* ((face (if (facep 'child-frame-border) 'child-frame-border 'internal-border))
+ (new (face-attribute 'corfu-border :background nil 'default)))
+ (unless (equal (face-attribute face :background corfu--frame 'default) new)
+ (set-face-background face new corfu--frame)))
+ (let ((new (face-attribute 'corfu-default :background nil 'default)))
+ (unless (equal (frame-parameter corfu--frame 'background-color) new)
+ (set-frame-parameter corfu--frame 'background-color new)))
+ (let ((win (frame-root-window corfu--frame)))
+ (set-window-buffer win buffer)
+ ;; Disallow selection of root window (#63)
+ (set-window-parameter win 'no-delete-other-windows t)
+ (set-window-parameter win 'no-other-window t)
+ ;; Mark window as dedicated to prevent frame reuse (#60)
+ (set-window-dedicated-p win t))
+ (set-frame-size corfu--frame width height t)
+ (if (frame-visible-p corfu--frame)
+ ;; XXX HACK Avoid flicker when frame is already visible.
+ ;; Redisplay, wait for resize and then move the frame.
+ (unless (equal (frame-position corfu--frame) (cons x y))
+ (redisplay 'force)
+ (sleep-for 0.01)
+ (set-frame-position corfu--frame x y))
+ ;; XXX HACK: Force redisplay, otherwise the popup sometimes does not
+ ;; display content.
+ (set-frame-position corfu--frame x y)
+ (redisplay 'force)
+ (make-frame-visible corfu--frame))
+ (redirect-frame-focus corfu--frame parent)))
+
+(defun corfu--popup-show (pos off width lines &optional curr lo bar)
+ "Show LINES as popup at POS - OFF.
+WIDTH is the width of the popup.
+The current candidate CURR is highlighted.
+A scroll bar is displayed from LO to LO+BAR."
+ (let* ((ch (default-line-height))
+ (cw (default-font-width))
+ (ml (ceiling (* cw corfu-left-margin-width)))
+ (mr (ceiling (* cw corfu-right-margin-width)))
+ (bw (ceiling (min mr (* cw corfu-bar-width))))
+ (marginl (and (> ml 0) (propertize " " 'display `(space :width (,ml)))))
+ (marginr (and (> mr 0) (propertize " " 'display `(space :align-to right))))
+ (sbar (when (> bw 0)
+ (concat (propertize " " 'display `(space :align-to (- right (,mr))))
+ (propertize " " 'display `(space :width (,(- mr bw))))
+ (propertize " " 'face 'corfu-bar 'display `(space :width (,bw))))))
+ (row 0)
+ (pos (posn-x-y (posn-at-point pos)))
+ (x (or (car pos) 0))
+ (y (or (cdr pos) 0)))
+ (corfu--make-frame
+ (- x ml (* cw off)) y
+ (+ (* width cw) ml mr) (* (length lines) ch)
+ (mapconcat (lambda (line)
+ (let ((str (concat marginl line
+ (if (and lo (<= lo row (+ lo bar))) sbar marginr))))
+ (when (eq row curr)
+ (add-face-text-property
+ 0 (length str) 'corfu-current 'append str))
+ (setq row (1+ row))
+ str))
+ lines "\n"))))
+
+(defun corfu--hide-frame-deferred ()
+ "Deferred frame hiding."
+ (setq corfu--frame-timer nil)
+ (when (frame-live-p corfu--frame)
+ (make-frame-invisible corfu--frame)
+ (with-current-buffer (window-buffer (frame-root-window corfu--frame))
+ (let ((inhibit-modification-hooks t)
+ (inhibit-read-only t))
+ (erase-buffer)))))
+
+(defun corfu--popup-hide ()
+ "Hide Corfu popup."
+ (when (and (frame-live-p corfu--frame) (not corfu--frame-timer))
+ (setq corfu--frame-timer (run-at-time 0 nil #'corfu--hide-frame-deferred))))
+
+(defun corfu--popup-support-p ()
+ "Return non-nil if child frames are supported."
+ (display-graphic-p))
+
+(defun corfu--move-to-front (elem list)
+ "Move ELEM to front of LIST."
+ (if-let (found (member elem list))
+ (let ((head (list (car found))))
+ (nconc head (delq (setcar found nil) list)))
+ list))
+
+;; bug#47711: Deferred highlighting for `completion-all-completions'
+;; XXX There is one complication: `completion--twq-all' already adds
+;; `completions-common-part'.
+(defun corfu--all-completions (&rest args)
+ "Compute all completions for ARGS with deferred highlighting."
+ (cl-letf* ((orig-pcm (symbol-function #'completion-pcm--hilit-commonality))
+ (orig-flex (symbol-function #'completion-flex-all-completions))
+ ((symbol-function #'completion-flex-all-completions)
+ (lambda (&rest args)
+ ;; Unfortunately for flex we have to undo the deferred
+ ;; highlighting, since flex uses the completion-score for
+ ;; sorting, which is applied during highlighting.
+ (cl-letf (((symbol-function #'completion-pcm--hilit-commonality) orig-pcm))
+ (apply orig-flex args))))
+ ;; Defer the following highlighting functions
+ (hl #'identity)
+ ((symbol-function #'completion-hilit-commonality)
+ (lambda (cands prefix &optional base)
+ (setq hl (lambda (x) (nconc (completion-hilit-commonality x prefix base) nil)))
+ (and cands (nconc cands base))))
+ ((symbol-function #'completion-pcm--hilit-commonality)
+ (lambda (pattern cands)
+ (setq hl (lambda (x)
+ ;; `completion-pcm--hilit-commonality' sometimes
+ ;; throws an internal error for example when entering
+ ;; "/sudo:://u".
+ (condition-case nil
+ (completion-pcm--hilit-commonality pattern x)
+ (t x))))
+ cands)))
+ ;; Only advise orderless after it has been loaded to avoid load order issues
+ (if (and (fboundp 'orderless-highlight-matches)
+ (fboundp 'orderless-pattern-compiler))
+ (cl-letf (((symbol-function 'orderless-highlight-matches)
+ (lambda (pattern cands)
+ (let ((regexps (orderless-pattern-compiler pattern)))
+ (setq hl (lambda (x) (orderless-highlight-matches regexps x))))
+ cands)))
+ (cons (apply #'completion-all-completions args) hl))
+ (cons (apply #'completion-all-completions args) hl))))
+
+(defun corfu--sort-predicate (x y)
+ "Sorting predicate which compares X and Y."
+ (or (< (length x) (length y)) (and (= (length x) (length y)) (string< x y))))
+
+(defun corfu-sort-length-alpha (list)
+ "Sort LIST by length and alphabetically."
+ (sort list #'corfu--sort-predicate))
+
+(defmacro corfu--partition! (list form)
+ "Evaluate FORM for every element and partition LIST."
+ (let ((head1 (make-symbol "head1"))
+ (head2 (make-symbol "head2"))
+ (tail1 (make-symbol "tail1"))
+ (tail2 (make-symbol "tail2")))
+ `(let* ((,head1 (cons nil nil))
+ (,head2 (cons nil nil))
+ (,tail1 ,head1)
+ (,tail2 ,head2))
+ (while ,list
+ (if (let ((it (car ,list))) ,form)
+ (progn
+ (setcdr ,tail1 ,list)
+ (pop ,tail1))
+ (setcdr ,tail2 ,list)
+ (pop ,tail2))
+ (pop ,list))
+ (setcdr ,tail1 (cdr ,head2))
+ (setcdr ,tail2 nil)
+ (setq ,list (cdr ,head1)))))
+
+(defun corfu--move-prefix-candidates-to-front (field candidates)
+ "Move CANDIDATES which match prefix of FIELD to the beginning."
+ (let* ((word (substring field 0
+ (seq-position field corfu-separator)))
+ (len (length word)))
+ (corfu--partition!
+ candidates
+ (and (>= (length it) len)
+ (eq t (compare-strings word 0 len it 0 len
+ completion-ignore-case))))))
+
+(defun corfu--filter-files (files)
+ "Filter FILES by `completion-ignored-extensions'."
+ (let ((re (concat "\\(?:\\(?:\\`\\|/\\)\\.\\.?/\\|"
+ (regexp-opt completion-ignored-extensions)
+ "\\)\\'")))
+ (or (seq-remove (lambda (x) (string-match-p re x)) files) files)))
+
+(defun corfu--sort-function ()
+ "Return the sorting function."
+ (or corfu-sort-override-function
+ (corfu--metadata-get 'display-sort-function)
+ corfu-sort-function))
+
+(defun corfu--recompute-candidates (str pt table pred)
+ "Recompute candidates from STR, PT, TABLE and PRED."
+ (pcase-let* ((before (substring str 0 pt))
+ (after (substring str pt))
+ (corfu--metadata (completion-metadata before table pred))
+ ;; bug#47678: `completion-boundaries` fails for `partial-completion`
+ ;; if the cursor is moved between the slashes of "~//".
+ ;; See also vertico.el which has the same issue.
+ (bounds (or (condition-case nil
+ (completion-boundaries before table pred after)
+ (t (cons 0 (length after))))))
+ (field (substring str (car bounds) (+ pt (cdr bounds))))
+ (completing-file (eq (corfu--metadata-get 'category) 'file))
+ (`(,all . ,hl) (corfu--all-completions str table pred pt corfu--metadata))
+ (base (or (when-let (z (last all)) (prog1 (cdr z) (setcdr z nil))) 0))
+ (corfu--base (substring str 0 base)))
+ ;; Filter the ignored file extensions. We cannot use modified predicate for
+ ;; this filtering, since this breaks the special casing in the
+ ;; `completion-file-name-table' for `file-exists-p' and `file-directory-p'.
+ (when completing-file (setq all (corfu--filter-files all)))
+ (setq all (delete-consecutive-dups (funcall (or (corfu--sort-function) #'identity) all)))
+ (setq all (corfu--move-prefix-candidates-to-front field all))
+ (when (and completing-file (not (string-suffix-p "/" field)))
+ (setq all (corfu--move-to-front (concat field "/") all)))
+ (setq all (corfu--move-to-front field all))
+ (list corfu--base all (length all) hl corfu--metadata
+ ;; Select the prompt when the input is a valid completion
+ ;; and if it is not equal to the first candidate.
+ (if (or (not corfu-preselect-first) (not all)
+ (and (not (equal field (car all)))
+ (not (and completing-file (equal (concat field "/") (car all))))
+ (test-completion str table pred)))
+ -1 0))))
+
+(defun corfu--update-candidates (str pt table pred)
+ "Update candidates from STR, PT, TABLE and PRED."
+ ;; Redisplay such that the input becomes immediately visible before the
+ ;; expensive candidate recomputation is performed (Issue #48). See also
+ ;; corresponding vertico#89.
+ (redisplay)
+ (pcase
+ ;; Bind non-essential=t to prevent Tramp from opening new connections,
+ ;; without the user explicitly requesting it via M-TAB.
+ (let ((non-essential t))
+ (while-no-input (corfu--recompute-candidates str pt table pred)))
+ ('nil (keyboard-quit))
+ (`(,base ,candidates ,total ,hl ,metadata ,preselect)
+ (setq corfu--input (cons str pt)
+ corfu--candidates candidates
+ corfu--base base
+ corfu--total total
+ corfu--preselect preselect
+ corfu--index preselect
+ corfu--highlight hl
+ corfu--metadata metadata))))
+
+(defun corfu--match-symbol-p (pattern sym)
+ "Return non-nil if SYM is matching an element of the PATTERN list."
+ (and (symbolp sym)
+ (cl-loop for x in pattern
+ thereis (if (symbolp x)
+ (eq sym x)
+ (string-match-p x (symbol-name sym))))))
+
+(defun corfu-quit ()
+ "Quit Corfu completion."
+ (interactive)
+ (completion-in-region-mode -1))
+
+(defun corfu-reset ()
+ "Reset Corfu completion.
+This command can be executed multiple times by hammering the ESC key. If a
+candidate is selected, unselect the candidate. Otherwise reset the input. If
+there hasn't been any input, then quit."
+ (interactive)
+ (if (/= corfu--index corfu--preselect)
+ (progn
+ (corfu--goto -1)
+ (setq this-command #'corfu-first))
+ ;; Cancel all changes and start new change group.
+ (cancel-change-group corfu--change-group)
+ (activate-change-group (setq corfu--change-group (prepare-change-group)))
+ (when (eq last-command #'corfu-reset) (corfu-quit))))
+
+(defun corfu--affixate (cands)
+ "Annotate CANDS with annotation function."
+ (setq cands
+ (if-let (aff (or (corfu--metadata-get 'affixation-function)
+ (plist-get corfu--extra :affixation-function)))
+ (funcall aff cands)
+ (if-let (ann (or (corfu--metadata-get 'annotation-function)
+ (plist-get corfu--extra :annotation-function)))
+ (cl-loop for cand in cands collect
+ (let ((suffix (or (funcall ann cand) "")))
+ ;; The default completion UI adds the
+ ;; `completions-annotations' face if no other faces are
+ ;; present. We use a custom `corfu-annotations' face to
+ ;; allow further styling which fits better for popups.
+ (unless (text-property-not-all 0 (length suffix) 'face nil suffix)
+ (setq suffix (propertize suffix 'face 'corfu-annotations)))
+ (list cand "" suffix)))
+ (cl-loop for cand in cands collect (list cand "" "")))))
+ (let* ((dep (plist-get corfu--extra :company-deprecated))
+ (completion-extra-properties corfu--extra)
+ (mf (run-hook-with-args-until-success 'corfu-margin-formatters corfu--metadata)))
+ (cl-loop for x in cands for (c . _) = x do
+ (when mf
+ (setf (cadr x) (funcall mf c)))
+ (when (and dep (funcall dep c))
+ (setcar x (setq c (substring c)))
+ (add-face-text-property 0 (length c) 'corfu-deprecated 'append c)))
+ (cons mf cands)))
+
+(defun corfu--metadata-get (prop)
+ "Return PROP from completion metadata."
+ ;; Note: Do not use `completion-metadata-get' in order to avoid Marginalia.
+ ;; The Marginalia annotators are too heavy for the Corfu popup!
+ (cdr (assq prop corfu--metadata)))
+
+(defun corfu--format-candidates (cands)
+ "Format annotated CANDS."
+ (setq cands
+ (cl-loop for c in cands collect
+ (cl-loop for s in c collect
+ (replace-regexp-in-string "[ \t]*\n[ \t]*" " " s))))
+ (let* ((cw (cl-loop for x in cands maximize (string-width (car x))))
+ (pw (cl-loop for x in cands maximize (string-width (cadr x))))
+ (sw (cl-loop for x in cands maximize (string-width (caddr x))))
+ (width (+ pw cw sw))
+ ;; -4 because of margins and some additional safety
+ (max-width (min corfu-max-width (- (frame-width) 4))))
+ (when (> width max-width)
+ (setq sw (max 0 (- max-width pw cw))
+ width (+ pw cw sw)))
+ (when (< width corfu-min-width)
+ (setq cw (+ cw (- corfu-min-width width))
+ width corfu-min-width))
+ (setq width (min width max-width))
+ (list pw width
+ (cl-loop for (cand prefix suffix) in cands collect
+ (truncate-string-to-width
+ (concat prefix
+ (make-string (max 0 (- pw (string-width prefix))) ?\s)
+ cand
+ (when (/= sw 0)
+ (make-string
+ (+ (max 0 (- cw (string-width cand)))
+ (max 0 (- sw (string-width suffix))))
+ ?\s))
+ suffix)
+ width)))))
+
+(defun corfu--update-scroll ()
+ "Update scroll position."
+ (let ((off (max (min corfu-scroll-margin (/ corfu-count 2)) 0))
+ (corr (if (= corfu-scroll-margin (/ corfu-count 2)) (1- (mod corfu-count 2)) 0)))
+ (setq corfu--scroll (min (max 0 (- corfu--total corfu-count))
+ (max 0 (+ corfu--index off 1 (- corfu-count))
+ (min (- corfu--index off corr) corfu--scroll))))))
+
+(defun corfu--candidates-popup (pos)
+ "Show candidates popup at POS."
+ (corfu--update-scroll)
+ (pcase-let* ((last (min (+ corfu--scroll corfu-count) corfu--total))
+ (bar (ceiling (* corfu-count corfu-count) corfu--total))
+ (lo (min (- corfu-count bar 1) (floor (* corfu-count corfu--scroll) corfu--total)))
+ (`(,mf . ,acands) (corfu--affixate (funcall corfu--highlight
+ (seq-subseq corfu--candidates corfu--scroll last))))
+ (`(,pw ,width ,fcands) (corfu--format-candidates acands))
+ ;; Disable the left margin if a margin formatter is active.
+ (corfu-left-margin-width (if mf 0 corfu-left-margin-width)))
+ ;; Nonlinearity at the end and the beginning
+ (when (/= corfu--scroll 0)
+ (setq lo (max 1 lo)))
+ (when (/= last corfu--total)
+ (setq lo (min (- corfu-count bar 2) lo)))
+ (corfu--popup-show (+ pos (length corfu--base)) pw width fcands (- corfu--index corfu--scroll)
+ (and (> corfu--total corfu-count) lo) bar)))
+
+(defun corfu--preview-current (beg end)
+ "Show current candidate as overlay given BEG and END."
+ (when-let (cand (and corfu-preview-current (>= corfu--index 0)
+ (/= corfu--index corfu--preselect)
+ (nth corfu--index corfu--candidates)))
+ (setq corfu--preview-ov (make-overlay beg end nil t t))
+ (overlay-put corfu--preview-ov 'priority 1000)
+ (overlay-put corfu--preview-ov 'window (selected-window))
+ (overlay-put corfu--preview-ov
+ (if (= beg end) 'after-string 'display)
+ (concat corfu--base cand))))
+
+(defun corfu--echo-cancel (&optional msg)
+ "Cancel echo timer and refresh MSG to prevent flicker during redisplay."
+ (when corfu--echo-timer
+ (cancel-timer corfu--echo-timer)
+ (setq corfu--echo-timer nil))
+ (corfu--echo-show msg))
+
+(defun corfu--echo-show (msg)
+ "Show MSG in echo area."
+ (when (or msg corfu--echo-message)
+ (setq msg (or msg "")
+ corfu--echo-message msg)
+ (corfu--message "%s" (if (text-property-not-all 0 (length msg) 'face nil msg)
+ msg
+ (propertize msg 'face 'corfu-echo)))))
+
+(defun corfu--echo-documentation ()
+ "Show documentation string of current candidate in echo area."
+ (if-let* ((delay (if (consp corfu-echo-documentation)
+ (funcall (if corfu--echo-message #'cdr #'car)
+ corfu-echo-documentation)
+ corfu-echo-documentation))
+ (fun (plist-get corfu--extra :company-docsig))
+ (cand (and (>= corfu--index 0)
+ (nth corfu--index corfu--candidates))))
+ (if (or (eq delay t) (<= delay 0))
+ (corfu--echo-show (funcall fun cand))
+ (corfu--echo-cancel)
+ (setq corfu--echo-timer
+ (run-at-time delay nil
+ (lambda ()
+ (corfu--echo-show (funcall fun cand))))))
+ (corfu--echo-cancel)))
+
+(defun corfu--update ()
+ "Refresh Corfu UI."
+ (pcase-let* ((`(,beg ,end ,table ,pred) completion-in-region--data)
+ (pt (- (point) beg))
+ (str (buffer-substring-no-properties beg end))
+ (initializing (not corfu--input)))
+ (when corfu--frame-timer
+ (cancel-timer corfu--frame-timer)
+ (setq corfu--frame-timer nil))
+ (corfu--echo-cancel corfu--echo-message)
+ (cond
+ ;; XXX Guard against errors during candidate generation.
+ ;; Turn off completion immediately if there are errors
+ ;; For example dabbrev throws error "No dynamic expansion ... found".
+ ;; TODO Report this as a bug? Are completion tables supposed to throw errors?
+ ((condition-case err
+ ;; Only recompute when input changed
+ (unless (equal corfu--input (cons str pt))
+ (corfu--update-candidates str pt table pred)
+ nil)
+ (error (corfu-quit)
+ (message "Corfu completion error: %s" (error-message-string err)))))
+ ;; 1) Initializing, no candidates => Quit. Happens during auto completion.
+ ((and initializing (not corfu--candidates))
+ (corfu-quit))
+ ;; 2) Single exactly matching candidate and no further completion is possible.
+ ((and (not (equal str ""))
+ (equal (car corfu--candidates) str) (not (cdr corfu--candidates))
+ (not (consp (completion-try-completion str table pred pt corfu--metadata)))
+ (or initializing corfu-on-exact-match))
+ ;; Quit directly when initializing. This happens during auto completion.
+ (if (or initializing (eq corfu-on-exact-match 'quit))
+ (corfu-quit)
+ (corfu--done str 'finished)))
+ ;; 3) There exist candidates => Show candidates popup.
+ (corfu--candidates
+ (corfu--candidates-popup beg)
+ (corfu--preview-current beg end)
+ (corfu--echo-documentation)
+ (redisplay 'force)) ;; XXX HACK Ensure that popup is redisplayed
+ ;; 4) There are no candidates & corfu-quit-no-match => Confirmation popup.
+ ((and (not corfu--candidates)
+ (pcase-exhaustive corfu-quit-no-match
+ ('t nil)
+ ('nil t)
+ ('separator (seq-contains-p (car corfu--input) corfu-separator))))
+ (corfu--popup-show beg 0 8 '(#("No match" 0 8 (face italic))))
+ (redisplay 'force)) ;; XXX HACK Ensure that popup is redisplayed
+ (t (corfu-quit)))))
+
+(defun corfu--pre-command ()
+ "Insert selected candidate unless command is marked to continue completion."
+ (when corfu--preview-ov
+ (delete-overlay corfu--preview-ov)
+ (setq corfu--preview-ov nil))
+ (when (and (eq corfu-preview-current 'insert)
+ (/= corfu--index corfu--preselect)
+ ;; See the comment about `overriding-local-map' in `corfu--post-command'.
+ (not (or overriding-terminal-local-map
+ (corfu--match-symbol-p corfu-continue-commands this-command))))
+ (corfu--insert 'exact)))
+
+(defun corfu-insert-separator ()
+ "Insert a separator character, inhibiting quit on completion boundary.
+See `corfu-separator' for more details."
+ (interactive)
+ (insert corfu-separator))
+
+(defun corfu--post-command ()
+ "Refresh Corfu after last command."
+ (or (pcase completion-in-region--data
+ (`(,beg ,end . ,_)
+ (when (let ((pt (point)))
+ (and (eq (marker-buffer beg) (current-buffer))
+ ;; Check ranges
+ (<= beg pt end)
+ (save-excursion
+ (goto-char beg)
+ (let ((inhibit-field-text-motion t))
+ (<= (line-beginning-position) pt (line-end-position))))
+ (or
+ ;; TODO We keep alive Corfu if a `overriding-terminal-local-map' is
+ ;; installed, for example the `universal-argument-map'. It would be good to
+ ;; think about a better criterion instead. Unfortunately relying on
+ ;; `this-command' alone is not sufficient, since the value of `this-command'
+ ;; gets clobbered in the case of transient keymaps.
+ overriding-terminal-local-map
+ ;; Check if it is an explicitly listed continue command
+ (corfu--match-symbol-p corfu-continue-commands this-command)
+ (and
+ ;; Check for empty input
+ (or (not corfu--input) (< beg end))
+ ;; Check separator or predicate
+ (or (not corfu-quit-at-boundary)
+ (and (eq corfu-quit-at-boundary 'separator)
+ (or (eq this-command #'corfu-insert-separator)
+ ;; with separator, any further chars allowed
+ (seq-contains-p (car corfu--input) corfu-separator)))
+ (funcall completion-in-region-mode--predicate))))))
+ (corfu--update)
+ t)))
+ (corfu-quit))
+ (when corfu-auto (corfu--auto-post-command)))
+
+(defun corfu--goto (index)
+ "Go to candidate with INDEX."
+ (setq corfu--index (max corfu--preselect (min index (1- corfu--total)))))
+
+(defun corfu-next (&optional n)
+ "Go forward N candidates."
+ (interactive "p")
+ (let ((index (+ corfu--index (or n 1))))
+ (corfu--goto
+ (cond
+ ((not corfu-cycle) index)
+ ((= corfu--total 0) -1)
+ ((< corfu--preselect 0) (1- (mod (1+ index) (1+ corfu--total))))
+ (t (mod index corfu--total))))))
+
+(defun corfu-previous (&optional n)
+ "Go backward N candidates."
+ (interactive "p")
+ (corfu-next (- (or n 1))))
+
+(defun corfu-scroll-down (&optional n)
+ "Go back by N pages."
+ (interactive "p")
+ (corfu--goto (max 0 (- corfu--index (* (or n 1) corfu-count)))))
+
+(defun corfu-scroll-up (&optional n)
+ "Go forward by N pages."
+ (interactive "p")
+ (corfu-scroll-down (- (or n 1))))
+
+(defun corfu-first ()
+ "Go to first candidate, or to the prompt when the first candidate is selected."
+ (interactive)
+ (corfu--goto (if (> corfu--index 0) 0 -1)))
+
+(defun corfu-last ()
+ "Go to last candidate."
+ (interactive)
+ (corfu--goto (1- corfu--total)))
+
+(defun corfu-complete ()
+ "Try to complete current input.
+If a candidate is selected, insert it."
+ (interactive)
+ (pcase-let ((`(,beg ,end ,table ,pred) completion-in-region--data))
+ (if (>= corfu--index 0)
+ ;; Continue completion with selected candidate
+ (progn
+ (corfu--insert nil)
+ ;; Exit with status 'finished if input is a valid match and no further
+ ;; completion is possible. Furthermore treat the completion as
+ ;; finished if we are at the end of a boundary, even if other longer
+ ;; candidates would still match, since the user invoked `corfu-complete'
+ ;; with an explicitly selected candidate!
+ (let ((newstr (buffer-substring-no-properties beg end)))
+ (when (and (test-completion newstr table pred)
+ (or
+ (not (consp (completion-try-completion
+ newstr table pred (length newstr)
+ (completion-metadata newstr table pred))))
+ (equal (completion-boundaries newstr table pred "") '(0 . 0))))
+ (corfu--done newstr 'finished))))
+ ;; Try to complete the current input string
+ (let* ((pt (max 0 (- (point) beg)))
+ (str (buffer-substring-no-properties beg end))
+ (metadata (completion-metadata (substring str 0 pt) table pred)))
+ (pcase (completion-try-completion str table pred pt metadata)
+ ('t
+ (goto-char end)
+ (corfu--done str 'finished))
+ (`(,newstr . ,newpt)
+ (unless (equal str newstr)
+ ;; bug#55205: completion--replace removes properties!
+ (completion--replace beg end (concat newstr)))
+ (goto-char (+ beg newpt))
+ ;; Exit with status 'finished if input is a valid match
+ ;; and no further completion is possible.
+ (when (and (test-completion newstr table pred)
+ (not (consp (completion-try-completion
+ newstr table pred newpt
+ (completion-metadata newstr table pred)))))
+ (corfu--done newstr 'finished))))))))
+
+(defun corfu--insert (status)
+ "Insert current candidate, exit with STATUS if non-nil."
+ (pcase-let* ((`(,beg ,end . ,_) completion-in-region--data)
+ (str (buffer-substring-no-properties beg end)))
+ ;; XXX There is a small bug here, depending on interpretation.
+ ;; When completing "~/emacs/master/li|/calc" where "|" is the
+ ;; cursor, then the candidate only includes the prefix
+ ;; "~/emacs/master/lisp/", but not the suffix "/calc". Default
+ ;; completion has the same problem when selecting in the
+ ;; *Completions* buffer. See bug#48356.
+ (setq str (concat corfu--base (substring-no-properties
+ (nth corfu--index corfu--candidates))))
+ ;; bug#55205: completion--replace removes properties!
+ (completion--replace beg end (concat str))
+ (corfu--goto -1) ;; Reset selection, but continue completion.
+ (when status (corfu--done str status)))) ;; Exit with status
+
+(defun corfu--done (str status)
+ "Call the `:exit-function' with STR and STATUS and exit completion."
+ (let ((exit (plist-get corfu--extra :exit-function)))
+ ;; For successfull completions, amalgamate undo operations,
+ ;; such that completion can be undone in a single step.
+ (undo-amalgamate-change-group corfu--change-group)
+ (corfu-quit)
+ ;; XXX Is the :exit-function handling sufficient?
+ (when exit (funcall exit str status))))
+
+(defun corfu-insert ()
+ "Insert current candidate.
+Quit if no candidate is selected."
+ (interactive)
+ (if (>= corfu--index 0)
+ (corfu--insert 'finished)
+ (corfu-quit)))
+
+(defun corfu--setup ()
+ "Setup Corfu completion state."
+ (setq corfu--extra completion-extra-properties)
+ (completion-in-region-mode 1)
+ (undo-boundary) ;; Necessary to support `corfu-reset'
+ (activate-change-group (setq corfu--change-group (prepare-change-group)))
+ (setcdr (assq #'completion-in-region-mode minor-mode-overriding-map-alist) corfu-map)
+ (add-hook 'pre-command-hook #'corfu--pre-command nil 'local)
+ (add-hook 'post-command-hook #'corfu--post-command)
+ ;; Disable default post-command handling, since we have our own
+ ;; checks in `corfu--post-command'.
+ (remove-hook 'post-command-hook #'completion-in-region--postch)
+ (let ((sym (make-symbol "corfu--teardown"))
+ (buf (current-buffer)))
+ (fset sym (lambda ()
+ ;; Ensure that the teardown runs in the correct buffer, if still alive.
+ (unless completion-in-region-mode
+ (remove-hook 'completion-in-region-mode-hook sym)
+ (with-current-buffer (if (buffer-live-p buf) buf (current-buffer))
+ (corfu--teardown)))))
+ (add-hook 'completion-in-region-mode-hook sym)))
+
+(defun corfu--teardown ()
+ "Teardown Corfu."
+ (corfu--popup-hide)
+ (remove-hook 'pre-command-hook #'corfu--pre-command 'local)
+ (remove-hook 'post-command-hook #'corfu--post-command)
+ (when corfu--preview-ov (delete-overlay corfu--preview-ov))
+ (corfu--echo-cancel)
+ (accept-change-group corfu--change-group)
+ (mapc #'kill-local-variable corfu--state-vars))
+
+(defun corfu--in-region (&rest args)
+ "Corfu completion in region function called with ARGS."
+ ;; XXX We can get an endless loop when `completion-in-region-function' is set
+ ;; globally to `corfu--in-region'. This should never happen.
+ (apply (if (corfu--popup-support-p) #'corfu--in-region-1
+ (default-value 'completion-in-region-function))
+ args))
+
+(defun corfu--in-region-1 (beg end table &optional pred)
+ "Complete in region, see `completion-in-region' for BEG, END, TABLE, PRED."
+ (barf-if-buffer-read-only)
+ ;; Restart the completion. This can happen for example if C-M-/
+ ;; (`dabbrev-completion') is pressed while the Corfu popup is already open.
+ (when completion-in-region-mode (corfu-quit))
+ (let* ((pt (max 0 (- (point) beg)))
+ (str (buffer-substring-no-properties beg end))
+ (before (substring str 0 pt))
+ (metadata (completion-metadata before table pred))
+ (exit (plist-get completion-extra-properties :exit-function))
+ (threshold (completion--cycle-threshold metadata))
+ (completion-in-region-mode-predicate
+ (or completion-in-region-mode-predicate (lambda () t))))
+ (pcase (completion-try-completion str table pred pt metadata)
+ ('nil (corfu--message "No match") nil)
+ ('t (goto-char end)
+ (corfu--message "Sole match")
+ (when exit (funcall exit str 'finished))
+ t)
+ (`(,newstr . ,newpt)
+ (pcase-let ((`(,base ,candidates ,total . ,_)
+ (corfu--recompute-candidates str pt table pred)))
+ (unless (markerp beg) (setq beg (copy-marker beg)))
+ (setq end (copy-marker end t)
+ completion-in-region--data (list beg end table pred))
+ (unless (equal str newstr)
+ ;; bug#55205: completion--replace removes properties!
+ (completion--replace beg end (concat newstr)))
+ (goto-char (+ beg newpt))
+ (if (= total 1)
+ ;; If completion is finished and cannot be further completed,
+ ;; return 'finished. Otherwise setup the Corfu popup.
+ (cond
+ ((consp (completion-try-completion
+ newstr table pred newpt
+ (completion-metadata newstr table pred)))
+ (corfu--setup))
+ (exit (funcall exit newstr 'finished)))
+ (if (or (= total 0) (not threshold)
+ (and (not (eq threshold t)) (< threshold total)))
+ (corfu--setup)
+ (corfu--cycle-candidates total candidates (+ (length base) beg) end)
+ ;; Do not show Corfu when "trivially" cycling, i.e.,
+ ;; when the completion is finished after the candidate.
+ (unless (equal (completion-boundaries (car candidates) table pred "")
+ '(0 . 0))
+ (corfu--setup)))))
+ t))))
+
+(defun corfu--message (&rest msg)
+ "Show completion MSG."
+ (let (message-log-max) (apply #'message msg)))
+
+(defun corfu--cycle-candidates (total cands beg end)
+ "Cycle between TOTAL number of CANDS.
+See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
+ (let* ((idx 0)
+ (map (make-sparse-keymap))
+ (replace (lambda ()
+ (interactive)
+ ;; bug#55205: completion--replace removes properties!
+ (completion--replace beg end (concat (nth idx cands)))
+ (corfu--message "Cycling %d/%d..." (1+ idx) total)
+ (setq idx (mod (1+ idx) total))
+ (set-transient-map map))))
+ (define-key map [remap completion-at-point] replace)
+ (define-key map [remap corfu-complete] replace)
+ (define-key map (vector last-command-event) replace)
+ (funcall replace)))
+
+(defun corfu--auto-complete-deferred (&optional tick)
+ "Initiate auto completion if TICK did not change."
+ (setq corfu--auto-timer nil)
+ (when (and (not completion-in-region-mode)
+ (or (not tick) (equal tick (corfu--auto-tick))))
+ (pcase (while-no-input ;; Interruptible capf query
+ (run-hook-wrapped 'completion-at-point-functions #'corfu--capf-wrapper))
+ (`(,fun ,beg ,end ,table . ,plist)
+ (let ((completion-in-region-mode-predicate
+ (lambda () (eq beg (car-safe (funcall fun)))))
+ (completion-extra-properties plist))
+ (setq completion-in-region--data
+ (list (if (markerp beg) beg (copy-marker beg))
+ (copy-marker end t)
+ table
+ (plist-get plist :predicate)))
+ (corfu--setup)
+ (corfu--update))))))
+
+(defun corfu--auto-post-command ()
+ "Post command hook which initiates auto completion."
+ (when corfu--auto-timer
+ (cancel-timer corfu--auto-timer)
+ (setq corfu--auto-timer nil))
+ (when (and (not completion-in-region-mode)
+ (not defining-kbd-macro)
+ (not buffer-read-only)
+ (corfu--match-symbol-p corfu-auto-commands this-command)
+ (corfu--popup-support-p))
+ (if (<= corfu-auto-delay 0)
+ (corfu--auto-complete-deferred)
+ ;; NOTE: Do not use idle timer since this leads to unacceptable slowdowns,
+ ;; in particular if flyspell-mode is enabled.
+ (setq corfu--auto-timer
+ (run-at-time corfu-auto-delay nil
+ #'corfu--auto-complete-deferred (corfu--auto-tick))))))
+
+(defun corfu--auto-tick ()
+ "Return the current tick/status of the buffer.
+Auto completion is only performed if the tick did not change."
+ (list (current-buffer) (buffer-chars-modified-tick) (point)))
+
+;;;###autoload
+(define-minor-mode corfu-mode
+ "Completion Overlay Region FUnction."
+ :global nil :group 'corfu
+ (cond
+ (corfu-mode
+ ;; FIXME: Install advice which fixes `completion--capf-wrapper', such that
+ ;; it respects the completion styles for non-exclusive capfs. See FIXME in
+ ;; the `completion--capf-wrapper' function in minibuffer.el, where the
+ ;; issue has been mentioned. We never uninstall this advice since the
+ ;; advice is active *globally*.
+ (advice-add #'completion--capf-wrapper :around #'corfu--capf-wrapper-advice)
+ (advice-add #'eldoc-display-message-no-interference-p :before-while #'corfu--allow-eldoc)
+ (and corfu-auto (add-hook 'post-command-hook #'corfu--auto-post-command nil 'local))
+ (setq-local completion-in-region-function #'corfu--in-region))
+ (t
+ (remove-hook 'post-command-hook #'corfu--auto-post-command 'local)
+ (kill-local-variable 'completion-in-region-function))))
+
+(defun corfu--capf-wrapper (fun &optional prefix)
+ "Wrapper for `completion-at-point' FUN.
+The wrapper determines if the capf is applicable at the current position
+and performs sanity checking on the returned result. PREFIX is a prefix
+length override, set to t for manual completion."
+ (pcase (funcall fun)
+ ((and res `(,beg ,end ,table . ,plist))
+ (and (integer-or-marker-p beg) ;; Valid capf result
+ (<= beg (point) end) ;; Sanity checking
+ ;; When auto completing, check the prefix length!
+ (let ((len (or prefix
+ (plist-get plist :company-prefix-length)
+ (- (point) beg))))
+ (or (eq len t) (>= len corfu-auto-prefix)))
+ ;; For non-exclusive capfs, check for valid completion.
+ (or (not (eq 'no (plist-get plist :exclusive)))
+ (let* ((str (buffer-substring-no-properties beg end))
+ (pt (- (point) beg))
+ (pred (plist-get plist :predicate))
+ (md (completion-metadata (substring str 0 pt) table pred)))
+ ;; We use `completion-try-completion' to check if there are
+ ;; completions. The upstream `completion--capf-wrapper' uses
+ ;; `try-completion' which is incorrect since it only checks for
+ ;; prefix completions.
+ (completion-try-completion str table pred pt md)))
+ (cons fun res)))))
+
+(defun corfu--capf-wrapper-advice (orig fun which)
+ "Around advice for `completion--capf-wrapper'.
+The ORIG function takes the FUN and WHICH arguments."
+ (if corfu-mode (corfu--capf-wrapper fun t) (funcall orig fun which)))
+
+;;;###autoload
+(define-globalized-minor-mode global-corfu-mode corfu-mode corfu--on :group 'corfu)
+
+(defun corfu--on ()
+ "Turn `corfu-mode' on."
+ (unless (or noninteractive
+ (eq (aref (buffer-name) 0) ?\s)
+ (memq major-mode corfu-excluded-modes))
+ (corfu-mode 1)))
+
+(defun corfu--allow-eldoc ()
+ "Return non-nil if Corfu is currently not active."
+ (not (and corfu-mode completion-in-region-mode)))
+
+;; Emacs 28: Do not show Corfu commands with M-X
+(dolist (sym '(corfu-next corfu-previous corfu-first corfu-last corfu-quit corfu-reset
+ corfu-complete corfu-insert corfu-scroll-up corfu-scroll-down
+ corfu-insert-separator))
+ (put sym 'completion-predicate #'ignore))
+
+(provide 'corfu)
+;;; corfu.el ends here
diff --git a/elpa/corfu-0.27/corfu.info b/elpa/corfu-0.27/corfu.info
@@ -0,0 +1,675 @@
+This is corfu.info, produced by makeinfo version 6.7 from corfu.texi.
+
+INFO-DIR-SECTION Emacs misc features
+START-INFO-DIR-ENTRY
+* Corfu: (corfu). Completion Overlay Region FUnction.
+END-INFO-DIR-ENTRY
+
+
+File: corfu.info, Node: Top, Next: Features, Up: (dir)
+
+corfu.el - Completion Overlay Region FUnction
+*********************************************
+
+Corfu enhances completion at point with a small completion popup. The
+current candidates are shown in a popup below or above the point. Corfu
+is the minimalistic ‘completion-in-region’ counterpart of the Vertico
+(https://github.com/minad/vertico) minibuffer UI.
+
+ Corfu is a small package, which relies on the Emacs completion
+facilities and concentrates on providing a polished completion UI.
+Completions are either provided by commands like ‘dabbrev-completion’ or
+by pluggable backends (‘completion-at-point-functions’, Capfs). Most
+programming language major modes implement a Capf. Furthermore the
+language server packages, Eglot (https://github.com/joaotavora/eglot)
+and Lsp-mode (https://github.com/emacs-lsp/lsp-mode), use Capfs which
+talk to the LSP server to retrieve the completions. Corfu does not
+include its own completion backends. The Emacs built-in Capfs and the
+Capfs provided by other programming language packages are usually
+sufficient. A few additional Capfs and completion utilities are
+provided by the Cape (https://github.com/minad/cape) package.
+
+ *NOTE*: Corfu uses child frames to show the popup and falls back to
+the default setting of the ‘completion-in-region-function’ on
+non-graphical displays. If you want to use Corfu in the terminal,
+install the package corfu-terminal
+(https://codeberg.org/akib/emacs-corfu-terminal), which provides an
+alternative overlay-based display.
+
+* Menu:
+
+* Features::
+* Installation and Configuration::
+* Key bindings::
+* Extensions::
+* Complementary packages::
+* Alternatives::
+* Contributions::
+
+— The Detailed Node Listing —
+
+Installation and Configuration
+
+* Auto completion::
+* Completing in the minibuffer::
+* Completing in the Eshell or Shell::
+* Orderless completion::
+* TAB-and-Go completion::
+* Transfer completion to the minibuffer::
+
+
+
+File: corfu.info, Node: Features, Next: Installation and Configuration, Prev: Top, Up: Top
+
+1 Features
+**********
+
+ • Timer-based auto-completions (_off_ by default, set ‘corfu-auto’).
+ • Popup display with scrollbar indicator and arrow key navigation.
+ • The popup can be summoned explicitly by pressing ‘TAB’ at any time.
+ • The current candidate is inserted with ‘TAB’ and selected with
+ ‘RET’.
+ • Candidates sorting by prefix, string length and alphabetically.
+ • The selected candidate is previewed (configurable via
+ ‘corfu-preview-current’).
+ • The selected candidate automatically committed on further input by
+ default. (configurable via ‘corfu-preview-current’).
+ • The Orderless (https://github.com/oantolin/orderless) completion
+ style is supported. The filter string can contain arbitrary
+ characters, after inserting a space via ‘M-SPC’ (configurable via
+ ‘corfu-quit-at-boundary’ and ‘corfu-separator’).
+ • Deferred completion style highlighting for performance.
+ • Support for candidate annotations and documentation in the echo
+ area.
+ • Deprecated candidates are crossed out in the display.
+ • Icons can be provided by an external package via margin formatter
+ functions.
+ • Extensions: Quick keys, Index keys, Sorting by history, Candidate
+ documentation
+
+
+File: corfu.info, Node: Installation and Configuration, Next: Key bindings, Prev: Features, Up: Top
+
+2 Installation and Configuration
+********************************
+
+Corfu is available from GNU ELPA
+(http://elpa.gnu.org/packages/corfu.html), such that it can be installed
+directly via ‘package-install’. After installation, the global minor
+mode can be enabled with ‘M-x global-corfu-mode’. In order to configure
+Corfu and other packages in your init.el, you may want to use
+‘use-package’.
+
+ Corfu is highly flexible and customizable via ‘corfu-*’ customization
+variables, such that you can adapt it precisely to your requirements.
+However in order to quickly try out the Corfu completion package, it
+should be sufficient to activate ‘global-corfu-mode’. You can
+experiment with manual completion for example in an Elisp buffer or in
+an Eshell or Shell buffer. For auto completion, set ‘corfu-auto=t’
+before turning on ‘global-corfu-mode’.
+
+ Here is an example configuration:
+
+ (use-package corfu
+ ;; Optional customizations
+ ;; :custom
+ ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ ;; (corfu-auto t) ;; Enable auto completion
+ ;; (corfu-separator ?\s) ;; Orderless field separator
+ ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
+ ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
+ ;; (corfu-preview-current nil) ;; Disable current candidate preview
+ ;; (corfu-preselect-first nil) ;; Disable candidate preselection
+ ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
+ ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
+ ;; (corfu-scroll-margin 5) ;; Use scroll margin
+
+ ;; Enable Corfu only for certain modes.
+ ;; :hook ((prog-mode . corfu-mode)
+ ;; (shell-mode . corfu-mode)
+ ;; (eshell-mode . corfu-mode))
+
+ ;; Recommended: Enable Corfu globally.
+ ;; This is recommended since Dabbrev can be used globally (M-/).
+ ;; See also `corfu-excluded-modes'.
+ :init
+ (global-corfu-mode))
+
+ ;; A few more useful configurations...
+ (use-package emacs
+ :init
+ ;; TAB cycle if there are only few candidates
+ (setq completion-cycle-threshold 3)
+
+ ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
+ ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
+ ;; (setq read-extended-command-predicate
+ ;; #'command-completion-default-include-p)
+
+ ;; Enable indentation+completion using the TAB key.
+ ;; `completion-at-point' is often bound to M-TAB.
+ (setq tab-always-indent 'complete))
+
+ Dabbrev completion is based on ‘completion-in-region’ and can be used
+with Corfu. You may want to swap the ‘dabbrev-completion’ with the
+‘dabbrev-expand’ key for easier access, if you prefer completion. Also
+take a look at the ‘cape-dabbrev’ completion at point function provided
+by my Cape (https://github.com/minad/cape) package.
+
+ ;; Use Dabbrev with Corfu!
+ (use-package dabbrev
+ ;; Swap M-/ and C-M-/
+ :bind (("M-/" . dabbrev-completion)
+ ("C-M-/" . dabbrev-expand))
+ ;; Other useful Dabbrev configurations.
+ :custom
+ (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
+
+ If you start to configure the package more deeply, I recommend to
+give the Orderless completion style a try for filtering. Orderless
+completion is different from the familiar prefix TAB completion. Corfu
+can be used with the default completion styles. The use of Orderless is
+not a necessity.
+
+ ;; Optionally use the `orderless' completion style.
+ (use-package orderless
+ :init
+ ;; Configure a custom style dispatcher (see the Consult wiki)
+ ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
+ ;; orderless-component-separator #'orderless-escapable-split-on-space)
+ (setq completion-styles '(orderless basic)
+ completion-category-defaults nil
+ completion-category-overrides '((file (styles . (partial-completion))))))
+
+ The ‘basic’ completion style is specified as fallback in addition to
+‘orderless’ in order to ensure that completion commands which rely on
+dynamic completion tables, e.g., ‘completion-table-dynamic’ or
+‘completion-table-in-turn’, work correctly. See ‘+orderless-dispatch’
+in the Consult wiki (https://github.com/minad/consult/wiki) for an
+advanced Orderless style dispatcher. Additionally enable
+‘partial-completion’ for file path expansion. ‘partial-completion’ is
+important for file wildcard support. Multiple files can be opened at
+once with ‘find-file’ if you enter a wildcard. You may also give the
+‘initials’ completion style a try.
+
+ See also the Corfu Wiki (https://github.com/minad/corfu/wiki) and the
+Cape manual (https://github.com/minad/cape) for additional Capf
+configuration tips. The Lsp-mode configuration is documented in the
+wiki. For more general documentation read the chapter about completion
+in the Emacs manual
+(https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html).
+If you want to create your own Capfs, you can find documentation about
+completion in the Elisp manual
+(https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html).
+
+* Menu:
+
+* Auto completion::
+* Completing in the minibuffer::
+* Completing in the Eshell or Shell::
+* Orderless completion::
+* TAB-and-Go completion::
+* Transfer completion to the minibuffer::
+
+
+File: corfu.info, Node: Auto completion, Next: Completing in the minibuffer, Up: Installation and Configuration
+
+2.1 Auto completion
+===================
+
+Auto completion is disabled by default, but can be enabled by setting
+‘corfu-auto=t’. Furthermore you may want to configure Corfu to quit
+completion eagerly, such that the completion popup stays out of your way
+when it appeared unexpectedly.
+
+ ;; Enable auto completion and configure quitting
+ (setq corfu-auto t
+ corfu-quit-no-match 'separator) ;; or t
+
+ I recommend to experiment a bit with the various settings and key
+bindings to find a configuration which works for you. There is no one
+size fits all solution. Some people like auto completion, some like
+manual completion, some want to cycle with TAB and some with the arrow
+keys.
+
+ In case you like aggressive auto completion settings, where the
+completion popup appears immediately, I recommend to use a cheap
+completion style like ‘basic’, which performs prefix filtering. In this
+case Corfu completion should still be very fast in buffers with
+efficient completion backends. You can try the following settings in an
+Elisp buffer or the Emacs scratch buffer.
+
+ ;; Aggressive completion, cheap prefix filtering.
+ (setq-local corfu-auto t
+ corfu-auto-delay 0
+ corfu-auto-prefix 0
+ completion-styles '(basic))
+
+ If you want to combine fast prefix filtering and Orderless filtering
+you can still do that by defining a custom Orderless completion style
+via ‘orderless-define-completion-style’. We use a custom style
+dispatcher, which enables prefix filtering for input shorter than 4
+characters. Note that such a setup is quite advanced. Please refer to
+the Orderless documentation and source code for further details.
+
+ (defun orderless-fast-dispatch (word index total)
+ (and (= index 0) (= total 1) (length< word 4)
+ `(orderless-regexp . ,(concat "^" (regexp-quote word)))))
+
+ (orderless-define-completion-style orderless-fast
+ (orderless-style-dispatchers '(orderless-fast-dispatch))
+ (orderless-matching-styles '(orderless-literal orderless-regexp)))
+
+ (setq-local corfu-auto t
+ corfu-auto-delay 0
+ corfu-auto-prefix 0
+ completion-styles '(orderless-fast))
+
+
+File: corfu.info, Node: Completing in the minibuffer, Next: Completing in the Eshell or Shell, Prev: Auto completion, Up: Installation and Configuration
+
+2.2 Completing in the minibuffer
+================================
+
+Corfu can be used for completion in the minibuffer, since it relies on
+child frames to display the candidates. By default, ‘global-corfu-mode’
+does not activate ‘corfu-mode’ in the minibuffer, to avoid interference
+with specialised minibuffer completion UIs like Vertico or Mct. However
+you may still want to enable Corfu completion for commands like ‘M-:’
+(‘eval-expression’) or ‘M-!’ (‘shell-command’), which read from the
+minibuffer. Activate ‘corfu-mode’ only if ‘completion-at-point’ is
+bound in the minibuffer-local keymap to achieve this effect.
+
+ (defun corfu-enable-in-minibuffer ()
+ "Enable Corfu in the minibuffer if `completion-at-point' is bound."
+ (when (where-is-internal #'completion-at-point (list (current-local-map)))
+ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ (corfu-mode 1)))
+ (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
+
+ You can also enable Corfu more generally for every minibuffer, as
+long as no other completion UI is active. If you use Mct or Vertico as
+your main minibuffer completion UI, the following snippet should yield
+the desired result.
+
+ (defun corfu-enable-always-in-minibuffer ()
+ "Enable Corfu in the minibuffer if Vertico/Mct are not active."
+ (unless (or (bound-and-true-p mct--active)
+ (bound-and-true-p vertico--input))
+ ;; (setq-local corfu-auto nil) Enable/disable auto completion
+ (corfu-mode 1)))
+ (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
+
+
+File: corfu.info, Node: Completing in the Eshell or Shell, Next: Orderless completion, Prev: Completing in the minibuffer, Up: Installation and Configuration
+
+2.3 Completing in the Eshell or Shell
+=====================================
+
+When completing in the Eshell I recommend conservative local settings
+without auto completion, such that the completion behavior is similar to
+widely used shells like Bash, Zsh or Fish.
+
+ (add-hook 'eshell-mode-hook
+ (lambda ()
+ (setq-local corfu-auto nil)
+ (corfu-mode)))
+
+ When pressing ‘RET’ while the Corfu popup is visible, the
+‘corfu-insert’ command will be invoked. This command does inserts the
+currently selected candidate, but it does not send the prompt input to
+Eshell or the comint process. Therefore you often have to press ‘RET’
+twice which feels like an unnecessary double confirmation. Fortunately
+it is easy to improve this! In my configuration I define the advice
+‘corfu-send-shell’ which sends the candidate after insertion.
+
+ (defun corfu-send-shell (&rest _)
+ "Send completion candidate when inside comint/eshell."
+ (cond
+ ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
+ (eshell-send-input))
+ ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
+ (comint-send-input))))
+
+ (advice-add #'corfu-insert :after #'corfu-send-shell)
+
+ Shell completion uses the flexible ‘Pcomplete’ mechanism internally,
+which allows you to program the completions per shell command. If you
+want to know more, look into this blog post
+(https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs),
+which shows how to configure Pcomplete for git commands. I recommend
+the pcmpl-args (https://github.com/JonWaltman/pcmpl-args.el) package
+which extends Pcomplete with completion support and helpful annotation
+support for more commands. Similar to the Fish shell, pcmpl-args uses
+man page parsing and –help output parsing to dynamically generate
+completions. This package brings Eshell completion to another level!
+
+ Unfortunately Pcomplete has a few technical issues, which we can work
+around with the Cape (https://github.com/minad/cape) library (Completion
+at point extensions). Cape provides wrappers, which sanitize the
+Pcomplete function. Ideally the bugs in Pcomplete should be fixed
+upstream. *For now these two advices are strongly recommended to
+achieve a sane Eshell experience.*
+
+ ;; Silence the pcomplete capf, no errors or messages!
+ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
+
+ ;; Ensure that pcomplete does not write to the buffer
+ ;; and behaves as a pure `completion-at-point-function'.
+ (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
+
+
+File: corfu.info, Node: Orderless completion, Next: TAB-and-Go completion, Prev: Completing in the Eshell or Shell, Up: Installation and Configuration
+
+2.4 Orderless completion
+========================
+
+Orderless (https://github.com/oantolin/orderless) is an advanced
+completion style that supports multi-component search filters separated
+by a configurable character (space, by default). Normally, entering
+characters like space which lie outside the completion region boundaries
+(words, typically) causes Corfu to quit. This behavior is helpful with
+auto-completion, which may pop-up when not desired, e.g. on entering a
+new variable name. Just keep typing and Corfu will get out of the way.
+
+ But orderless search terms can contain arbitrary characters; they are
+also interpreted as regular expressions. To use orderless, set
+‘corfu-separator’ (a space, by default) to the primary character of your
+orderless component separator.
+
+ Then, when a new orderless component is desired, use ‘M-SPC’
+(‘corfu-insert-separator’) to enter the _first_ component separator in
+the input, and arbitrary orderless search terms and new separators can
+be entered thereafter.
+
+ To treat the entire input as Orderless input, you can set the
+customization option ‘corfu-quit-at-boundary=t’. This disables the
+predicate which checks if the current completion boundary has been left.
+In contrast, if you _always_ want to quit at the boundary, simply set
+‘corfu-quit-at-boundary=nil’. By default ‘corfu-quit-at-boundary’ is
+set to ‘separator’ which quits at completion boundaries as long as no
+separator has been inserted with ‘corfu-insert-separator’.
+
+ Finally, there exists the user option ‘corfu-quit-no-match’ which is
+set to ‘separator’ by default. With this setting Corfu stays alive as
+soon as you start advanced filtering with a ‘corfu-separator’ even if
+there are no matches, for example due to a typo. As long as no
+separator character has been inserted with ‘corfu-insert-separator’,
+Corfu will still quit if there are no matches. This ensures that the
+Corfu popup goes away quickly if completion is not possible.
+
+ In the following we show two configurations, one which works best
+with auto completion and one which may work better with manual
+completion if you prefer to always use ‘SPC’ to separate the Orderless
+components.
+
+ ;; Auto completion example
+ (use-package corfu
+ :custom
+ (corfu-auto t) ;; Enable auto completion
+ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ :bind
+ ;; Another key binding can be used, such as S-SPC.
+ ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
+ :init
+ (global-corfu-mode))
+
+ ;; Manual completion example
+ (use-package corfu
+ :custom
+ ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
+ :bind
+ ;; Configure SPC for separator insertion
+ (:map corfu-map ("SPC" . corfu-insert-separator))
+ :init
+ (global-corfu-mode))
+
+
+File: corfu.info, Node: TAB-and-Go completion, Next: Transfer completion to the minibuffer, Prev: Orderless completion, Up: Installation and Configuration
+
+2.5 TAB-and-Go completion
+=========================
+
+You may be interested in configuring Corfu in TAB-and-Go style.
+Pressing TAB moves to the next candidate and further input will then
+commit the selection. Note that further input will not expand snippets
+or templates, which may not be desired but which leads overall to a more
+predictable behavior. In order to force snippet expansion, confirm a
+candidate explicitly with ‘RET’.
+
+ (use-package corfu
+ ;; TAB-and-Go customizations
+ :custom
+ (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
+ (corfu-preselect-first nil) ;; Disable candidate preselection
+
+ ;; Use TAB for cycling, default is `corfu-complete'.
+ :bind
+ (:map corfu-map
+ ("TAB" . corfu-next)
+ ([tab] . corfu-next)
+ ("S-TAB" . corfu-previous)
+ ([backtab] . corfu-previous))
+
+ :init
+ (global-corfu-mode))
+
+
+File: corfu.info, Node: Transfer completion to the minibuffer, Prev: TAB-and-Go completion, Up: Installation and Configuration
+
+2.6 Transfer completion to the minibuffer
+=========================================
+
+Sometimes it is useful to transfer the Corfu completion session to the
+minibuffer, since the minibuffer offers richer interaction features. In
+particular, Embark (https://github.com/oantolin/embark) is available in
+the minibuffer, such that you can act on the candidates or
+export/collect the candidates to a separate buffer. Hopefully we can
+also add Corfu-support to Embark in the future, such that at least
+export/collect is possible directly from Corfu. But in my opinion
+having the ability to transfer the Corfu completion to the minibuffer is
+an even better feature, since further completion can be performed there.
+
+ The command ‘corfu-move-to-minibuffer’ is defined here in terms of
+‘consult-completion-in-region’, which uses the minibuffer completion UI
+via ‘completing-read’.
+
+ (defun corfu-move-to-minibuffer ()
+ (interactive)
+ (let ((completion-extra-properties corfu--extra)
+ completion-cycle-threshold completion-cycling)
+ (apply #'consult-completion-in-region completion-in-region--data)))
+ (define-key corfu-map "\M-m" #'corfu-move-to-minibuffer)
+
+
+File: corfu.info, Node: Key bindings, Next: Extensions, Prev: Installation and Configuration, Up: Top
+
+3 Key bindings
+**************
+
+Corfu uses a transient keymap ‘corfu-map’ which is active while the
+popup is shown. The keymap defines the following remappings and
+bindings:
+
+ • ‘beginning-of-buffer’ -> ‘corfu-first’
+ • ‘end-of-buffer’ -> ‘corfu-last’
+ • ‘scroll-down-command’ -> ‘corfu-scroll-down’
+ • ‘scroll-up-command’ -> ‘corfu-scroll-up’
+ • ‘next-line’, ‘down’, ‘M-n’ -> ‘corfu-next’
+ • ‘previous-line’, ‘up’, ‘M-p’ -> ‘corfu-previous’
+ • ‘completion-at-point’, ‘TAB’ -> ‘corfu-complete’
+ • ‘RET’ -> ‘corfu-insert’
+ • ‘M-g’ -> ‘corfu-info-location’
+ • ‘M-h’ -> ‘corfu-info-documentation’
+ • ‘M-SPC’ -> ‘corfu-insert-separator’
+ • ‘C-g’ -> ‘corfu-quit’
+ • ‘keyboard-escape-quit’ -> ‘corfu-reset’
+
+
+File: corfu.info, Node: Extensions, Next: Complementary packages, Prev: Key bindings, Up: Top
+
+4 Extensions
+************
+
+We maintain small extension packages to Corfu in this repository in the
+subdirectory extensions/
+(https://github.com/minad/corfu/tree/main/extensions). The extensions
+are installed together with Corfu if you pull the package from ELPA.
+The extensions are inactive by default and can be enabled manually if
+desired. Furthermore it is possible to install all of the files
+separately, both ‘corfu.el’ and the ‘corfu-*.el’ extensions. Currently
+the following extensions come with the Corfu ELPA package:
+
+ • corfu-history
+ (https://github.com/minad/corfu/blob/main/extensions/corfu-history.el):
+ ‘corfu-history-mode’ to remember selected candidates and to improve
+ sorting.
+ • corfu-indexed
+ (https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el):
+ ‘corfu-indexed-mode’ to select indexed candidates with prefix
+ arguments.
+ • corfu-info
+ (https://github.com/minad/corfu/blob/main/extensions/corfu-info.el):
+ Actions to access the candidate location and documentation.
+ • corfu-quick
+ (https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el):
+ Commands to select using Avy-style quick keys.
+
+ See the Commentary of those files for configuration details.
+
+
+File: corfu.info, Node: Complementary packages, Next: Alternatives, Prev: Extensions, Up: Top
+
+5 Complementary packages
+************************
+
+Corfu works well together with all packages providing code completion
+via the ‘completion-at-point-functions’. Many modes and packages
+already provide a Capf out of the box. Nevertheless you may want to
+look into complementary packages to enhance your setup.
+
+ • corfu-terminal (https://codeberg.org/akib/emacs-corfu-terminal):
+ The corfu-terminal package provides an overlay-based display for
+ Corfu, such that you can use Corfu in terminal Emacs.
+
+ • corfu-doc (https://github.com/galeo/corfu-doc): The corfu-doc
+ package displays the candidate documentation in a popup next to the
+ Corfu popup, similar to ‘company-quickhelp’.
+
+ • Orderless (https://github.com/oantolin/orderless): Corfu supports
+ completion styles, including the advanced Orderless
+ (https://github.com/oantolin/orderless) completion style, where the
+ filtering expressions are separated by spaces or another character
+ (see ‘corfu-separator’).
+
+ • Cape (https://github.com/minad/cape): Additional Capf backends and
+ ‘completion-in-region’ commands are provided by the Cape
+ (https://github.com/minad/cape) package. Among others, the package
+ supplies a file path and a Dabbrev completion backend. Cape
+ provides the ‘cape-company-to-capf’ adapter to reuse Company
+ backends in Corfu. Furthermore the function ‘cape-super-capf’ can
+ merge multiple Capfs, such that the candidates of multiple Capfs
+ are displayed together at the same time.
+
+ • kind-icon (https://github.com/jdtsmith/kind-icon): Icons are
+ supported by Corfu via an external package. For example the
+ kind-icon (https://github.com/jdtsmith/kind-icon) package provides
+ beautifully styled SVG icons based on monochromatic icon sets like
+ material design.
+
+ • pcmpl-args (https://github.com/JonWaltman/pcmpl-args.el): Extend
+ the Eshell/Shell Pcomplete mechanism with support for many more
+ commands. Similar to the Fish shell, Pcomplete uses man page
+ parsing to dynamically retrieve the completions and helpful
+ annotations. This package brings Eshell completions to another
+ level!
+
+ • Tempel (https://github.com/minad/tempel): Tiny template/snippet
+ package with templates in Lisp syntax, which can be used in
+ conjunction with Corfu.
+
+ • Vertico (https://github.com/minad/vertico): You may also want to
+ look into my Vertico (https://github.com/minad/vertico) package.
+ Vertico is the minibuffer completion counterpart of Corfu.
+
+
+File: corfu.info, Node: Alternatives, Next: Contributions, Prev: Complementary packages, Up: Top
+
+6 Alternatives
+**************
+
+ • Company (https://github.com/company-mode/company-mode): Company is
+ a widely used and mature completion package, which implements a
+ similar interaction model and popup UI as Corfu. While Corfu
+ relies exclusively on the standard Emacs completion API (Capfs),
+ Company defines its own API for the backends. Company includes its
+ completion backends, which are incompatible with the Emacs
+ completion infrastructure. As a result of this design, Company is
+ a more complex package than Corfu. Company by default uses
+ overlays for the popup in contrast to the child frames used by
+ Corfu. Overall both packages work well, but Company integrates
+ less tightly with Emacs. The ‘completion-styles’ support is more
+ limited and the ‘completion-at-point’ command and the
+ ‘completion-in-region’ function do not invoke Company.
+
+ • Mct (https://git.sr.ht/~protesilaos/mct): Protesilaos’ Minibuffer
+ Confines Transcended package supports both minibuffer completion
+ and completion in region. It reuses the default completion UI for
+ this purpose and installs a timer which live updates the completion
+ buffer. The main advantage of Mct is that you work with a regular
+ Emacs buffer instead of with a popup. You can take advantage of
+ the usual Emacs commands to navigate in the completions buffer. On
+ top, Mct enhances the movement such that you can quickly switch
+ between the completions buffer and the minibuffer or the region
+ which is being completed. Mct does not support timer-based auto
+ completion, but the integration into Emacs is naturally tight.
+ Note that Mct development is currently discontinued
+ (https://protesilaos.com/codelog/2022-04-14-emacs-discontinue-mct/)
+ due to recent changes of the default completion UI on the Emacs
+ master branch.
+
+ • consult-completion-in-region (https://github.com/minad/consult):
+ The Consult package provides the function
+ ‘consult-completion-in-region’ which can be set as
+ ‘completion-in-region-function’ such that it handles
+ ‘completion-at-point’. The function works by transferring the
+ in-buffer completion to the minibuffer. In the minibuffer, the
+ minibuffer completion UI, for example Vertico
+ (https://github.com/minad/vertico) takes over. If you prefer to
+ perform all your completions in the minibuffer
+ ‘consult-completion-in-region’ is your best option.
+
+
+File: corfu.info, Node: Contributions, Prev: Alternatives, Up: Top
+
+7 Contributions
+***************
+
+Since this package is part of GNU ELPA
+(http://elpa.gnu.org/packages/corfu.html) contributions require a
+copyright assignment to the FSF.
+
+
+
+Tag Table:
+Node: Top209
+Node: Features2205
+Node: Installation and Configuration3612
+Node: Auto completion9362
+Node: Completing in the minibuffer11726
+Node: Completing in the Eshell or Shell13539
+Node: Orderless completion16400
+Node: TAB-and-Go completion19497
+Node: Transfer completion to the minibuffer20612
+Node: Key bindings21951
+Node: Extensions22942
+Node: Complementary packages24325
+Node: Alternatives27023
+Node: Contributions29670
+
+End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/elpa/corfu-0.23/dir b/elpa/corfu-0.27/dir