dotemacs

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

README.org (63571B)


      1 #+title: consult.el - Consulting completing-read
      2 #+author: Daniel Mendler
      3 #+language: en
      4 #+export_file_name: consult.texi
      5 #+texinfo_dir_category: Emacs misc features
      6 #+texinfo_dir_title: Consult: (consult).
      7 #+texinfo_dir_desc: Useful commands built on completing-read.
      8 
      9 #+html: <a href="https://www.gnu.org/software/emacs/"><img alt="GNU Emacs" src="https://github.com/minad/corfu/blob/screenshots/emacs.svg?raw=true"/></a>
     10 #+html: <a href="https://elpa.gnu.org/packages/consult.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/consult.svg"/></a>
     11 #+html: <a href="https://elpa.gnu.org/devel/consult.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/consult.svg"/></a>
     12 #+html: <a href="https://melpa.org/#/consult"><img alt="MELPA" src="https://melpa.org/packages/consult-badge.svg"/></a>
     13 #+html: <a href="https://stable.melpa.org/#/consult"><img alt="MELPA Stable" src="https://stable.melpa.org/packages/consult-badge.svg"/></a>
     14 
     15 Consult provides search and navigation commands based on the Emacs completion
     16 function [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Completion.html][completing-read]]. Completion allows you to quickly select an item from a
     17 list of candidates. Consult offers asynchronous and interactive =consult-grep= and
     18 =consult-ripgrep= commands, and the line-based search command =consult-line=.
     19 Furthermore Consult provides an advanced buffer switching command =consult-buffer=
     20 to switch between buffers, recently opened files, bookmarks and buffer-like
     21 candidates from other sources. Some of the Consult commands are enhanced
     22 versions of built-in Emacs commands. For example the command =consult-imenu=
     23 presents a flat list of the Imenu with [[#live-previews][live preview]], [[#narrowing-and-grouping][grouping and narrowing]].
     24 Please take a look at the [[#available-commands][full list of commands]].
     25 
     26 Consult is fully compatible with completion systems centered around the standard
     27 Emacs =completing-read= API, notably the default completion system, [[https://github.com/minad/vertico][Vertico]], [[https://github.com/protesilaos/mct][Mct]],
     28 and [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Icomplete.html][Icomplete]].
     29 
     30 This package keeps the completion system specifics to a minimum. The ability of
     31 the Consult commands to work well with arbitrary completion systems is one of
     32 the main advantages of the package. Consult fits well into existing setups and
     33 it helps you to create a full completion environment out of small and
     34 independent components.
     35 
     36 You can combine the complementary packages [[https://github.com/minad/marginalia/][Marginalia]], [[https://github.com/oantolin/embark/][Embark]] and [[https://github.com/oantolin/orderless][Orderless]] with
     37 Consult. Marginalia enriches the completion display with annotations, e.g.,
     38 documentation strings or file information. The versatile Embark package provides
     39 local actions, comparable to a context menu. These actions operate on the
     40 selected candidate in the minibuffer or at point in normal buffers. For example,
     41 when selecting from a list of files, Embark offers an action to delete the file.
     42 Additionally Embark offers a facility to collect completion candidates in a
     43 collect buffer. The section [[#embark-integration][Embark integration]] documents in greater detail how
     44 Consult and Embark work together.
     45 
     46 #+toc: headlines 8
     47 
     48 * Screenshots :noexport:
     49 
     50 #+caption: consult-grep
     51 [[https://github.com/minad/consult/blob/screenshots/consult-grep.gif?raw=true]]
     52 Fig. 1: Command =consult-git-grep=
     53 
     54 #+caption: consult-imenu
     55 [[https://github.com/minad/consult/blob/screenshots/consult-imenu.png?raw=true]]
     56 Fig. 2: Command =consult-imenu=
     57 
     58 #+caption: consult-line
     59 [[https://github.com/minad/consult/blob/screenshots/consult-line.png?raw=true]]
     60 Fig. 3: Command =consult-line=
     61 
     62 * Available commands
     63 :properties:
     64 :custom_id: available-commands
     65 :description: Navigation, search, editing commands and more
     66 :end:
     67 #+cindex: commands
     68 
     69 Most Consult commands follow the meaningful naming scheme =consult-<thing>=.
     70 Many commands implement a little known but convenient Emacs feature called
     71 "future history", which guesses what input the user wants. At a command prompt
     72 type =M-n= and typically Consult will insert the symbol or thing at point into
     73 the input.
     74 
     75 *TIP:* If you have [[https://github.com/minad/marginalia][Marginalia]] annotators activated, type =M-x ^consult= to see
     76 all Consult commands with their abbreviated description. Alternatively, type
     77 =C-h a ^consult= to get an overview of all Consult variables and functions with
     78 their descriptions.
     79 
     80 ** Virtual Buffers
     81 :properties:
     82 :description: Buffers, bookmarks and recent files
     83 :end:
     84 #+cindex: virtual buffers
     85 
     86 #+findex: consult-buffer
     87 #+findex: consult-buffer-other-window
     88 #+findex: consult-buffer-other-frame
     89 #+findex: consult-project-buffer
     90 #+findex: consult-recent-file
     91 #+findex: consult-bookmark
     92 - =consult-buffer= (=-other-window=, =-other-frame=): Enhanced version
     93   of =switch-to-buffer= with support for virtual buffers. Supports live preview
     94   of buffers and narrowing to the virtual buffer types. You can type =f SPC= in
     95   order to narrow to recent files. Press =SPC= to show ephemeral buffers.
     96   Supported narrowing keys:
     97   - b Buffers
     98   - SPC Hidden buffers
     99   - * Modified buffers
    100   - f Files (Requires =recentf-mode=)
    101   - r File registers
    102   - m Bookmarks
    103   - p Project
    104   - Custom [[#multiple-sources][other sources]] configured in =consult-buffer-sources=.
    105 - =consult-project-buffer=: Variant of =consult-buffer= restricted to buffers and
    106   recent files of the current project. You can add custom sources to
    107   =consult-project-buffer-sources=. The command may prompt you for a project if
    108   you invoke it from outside a project.
    109 - =consult-bookmark=: Select or create bookmark. To select bookmarks you might use the
    110   =consult-buffer= as an alternative, which can include a bookmark virtual buffer
    111   source. Note that =consult-bookmark= supports preview of bookmarks and
    112   narrowing.
    113 - =consult-recent-file=: Select from recent files with preview.
    114   You might prefer the powerful =consult-buffer= instead, which can include
    115   recent files as a virtual buffer source. The =recentf-mode= enables tracking of
    116   recent files.
    117 
    118 ** Editing
    119 :properties:
    120 :description: Commands useful for editing
    121 :end:
    122 #+cindex: editing
    123 
    124 #+findex: consult-yank-pop
    125 #+findex: consult-yank-from-kill-ring
    126 #+findex: consult-yank-replace
    127 #+findex: consult-kmacro
    128 - =consult-yank-from-kill-ring=: Enhanced version of =yank= to select an item
    129   from the =kill-ring=. The selected text previewed as overlay in the buffer.
    130 - =consult-yank-pop=: Enhanced version of =yank-pop= with DWIM-behavior, which
    131   either replaces the last =yank= by cycling through the =kill-ring=, or if there
    132   has not been a last =yank= consults the =kill-ring=. The selected text previewed
    133   as overlay in the buffer.
    134 - =consult-yank-replace=: Like =consult-yank-pop=, but always replaces the last
    135   =yank= with an item from the =kill-ring=.
    136 - =consult-kmacro=: Select macro from the macro ring and execute it.
    137 
    138 ** Register
    139 :properties:
    140 :description: Searching through registers and fast access
    141 :end:
    142 #+cindex: register
    143 
    144 #+findex: consult-register
    145 #+findex: consult-register-load
    146 #+findex: consult-register-store
    147 #+findex: consult-register-format
    148 #+findex: consult-register-window
    149 - =consult-register=: Select from list of registers. The command
    150   supports narrowing to register types and preview of marker positions. This
    151   command is useful to search the register contents. For quick access use the
    152   commands =consult-register-load=, =consult-register-store= or the built-in Emacs
    153   register commands.
    154 - =consult-register-format=: Set =register-preview-function= to this function for
    155   an enhanced register formatting. See the [[#use-package-example][example configuration]].
    156 - =consult-register-window=: Replace =register-preview= with this function for a
    157   better register window. See the [[#use-package-example][example configuration]].
    158 - =consult-register-load=: Utility command to quickly load a register.
    159   The command either jumps to the register value or inserts it.
    160 - =consult-register-store=: Improved UI to store registers depending on the current
    161   context with an action menu. With an active region, store/append/prepend the
    162   contents, optionally deleting the region when a prefix argument is given.
    163   With a numeric prefix argument, store/add the number. Otherwise store point,
    164   frameset, window or kmacro. Usage examples:
    165   * =M-' x=: If no region is active, store point in register =x=.
    166     If a region is active, store the region in register =x=.
    167   * =M-' M-w x=: Store window configuration in register =x=.
    168   * =C-u 100 M-' x=: Store number in register =x=.
    169 
    170 ** Navigation
    171 :properties:
    172 :description: Mark rings, outlines and imenu
    173 :end:
    174 #+cindex: navigation
    175 
    176 #+findex: consult-goto-line
    177 #+findex: consult-mark
    178 #+findex: consult-global-mark
    179 #+findex: consult-outline
    180 #+findex: consult-imenu
    181 #+findex: consult-imenu-multi
    182 - =consult-goto-line=: Jump to line number enhanced with live preview.
    183   This is a drop-in replacement for =goto-line=.
    184 - =consult-mark=: Jump to a marker in the =mark-ring=. Supports live
    185   preview and recursive editing.
    186 - =consult-global-mark=: Jump to a marker in the =global-mark-ring=.
    187   Supports live preview and recursive editing.
    188 - =consult-outline=: Jump to a heading of the outline. Supports narrowing
    189   to a heading level, live preview and recursive editing.
    190 - =consult-imenu=: Jump to imenu item in the current buffer. Supports
    191   live preview, recursive editing and narrowing.
    192 - =consult-imenu-multi=: Jump to imenu item in project buffers, with
    193   the same major mode as the current buffer. Supports live preview,
    194   recursive editing and narrowing. This feature has been inspired by
    195   [[https://github.com/vspinu/imenu-anywhere][imenu-anywhere]].
    196 
    197 ** Search
    198 :properties:
    199 :description: Line search, grep and file search
    200 :end:
    201 #+cindex: search
    202 
    203 #+findex: consult-line
    204 #+findex: consult-line-multi
    205 #+findex: consult-keep-lines
    206 #+findex: consult-focus-lines
    207 - =consult-line=: Enter search string and select from matching lines.
    208   Supports live preview and recursive editing. The symbol at point and the
    209   recent Isearch string are added to the "future history" and can be accessed
    210   by pressing =M-n=. When =consult-line= is bound to the =isearch-mode-map= and
    211   is invoked during a running Isearch, it will use the current Isearch string.
    212 - =consult-line-multi=: Search dynamically across multiple buffers. By default
    213   search across project buffers. If invoked with a prefix argument search across
    214   all buffers. The candidates are computed on demand based on the input. The
    215   command behaves like =consult-grep=, but operates on buffers instead of files.
    216 - =consult-keep-lines=: Replacement for =keep/flush-lines= which uses the current
    217   completion style for filtering the buffer. The function updates the buffer
    218   while typing. In particular =consult-keep-lines= can narrow down an exported
    219   Embark collect buffer further, relying on the same completion filtering as
    220   ~completing-read~. If the input begins with the negation operator, i.e., ~! SPC~,
    221   the filter matches the complement. If a region is active, the region restricts
    222   the filtering.
    223 - =consult-focus-lines=: Temporarily hide lines by filtering them using the
    224   current completion style. Call with =C-u= prefix argument in order to show the
    225   hidden lines again. If the input begins with the negation operator, i.e., ~!
    226   SPC~, the filter matches the complement. In contrast to =consult-keep-lines= this
    227   function does not edit the buffer. If a region is active, the region restricts
    228   the filtering.
    229 
    230 ** Grep and Find
    231 :properties:
    232 :description: Searching through the filesystem
    233 :end:
    234 #+cindex: grep
    235 #+cindex: find
    236 #+cindex: locate
    237 
    238 #+findex: consult-grep
    239 #+findex: consult-ripgrep
    240 #+findex: consult-git-grep
    241 #+findex: consult-find
    242 #+findex: consult-locate
    243 - =consult-grep=, =consult-ripgrep=, =consult-git-grep=: Search for regular expression
    244   in files. Consult invokes Grep asynchronously, while you enter the search
    245   term. After at least =consult-async-min-input= characters, the search gets
    246   started. Consult splits the input string into two parts, if the first
    247   character is a punctuation character, like =#=. For example
    248   =#regexps#filter-string=, is split at the second =#=. The string =regexps= is
    249   passed to Grep. Note that Consult transforms Emacs regular expressions to
    250   expressions understand by the search program. Always use Emacs regular
    251   expressions at the prompt. If you enter multiple regular expressions
    252   separated by space only lines matching all regular expressions are shown. In
    253   order to match space literally, escape the space with a backslash. The
    254   =filter-string= is passed to the /fast/ Emacs filtering to further narrow down
    255   the list of matches. This is particularly useful if you are using an advanced
    256   completion style like orderless. =consult-grep= supports preview. If the
    257   =consult-project-function= returns non-nil, =consult-grep= searches the
    258   current project directory. Otherwise the =default-directory= is searched. If
    259   =consult-grep= is invoked with prefix argument =C-u M-s g=, you can specify the
    260   directory manually.
    261 - =consult-find=, =consult-locate=: Find file by matching the path against a regexp.
    262   Like for =consult-grep=, either the project root or the current directory is the
    263   root directory for the search. The input string is treated similarly to
    264   =consult-grep=, where the first part is passed to find, and the second part is
    265   used for Emacs filtering.
    266 
    267 ** Compilation
    268 :properties:
    269 :description: Jumping to references and compilation errors
    270 :end:
    271 #+cindex: compilation errors
    272 
    273 #+findex: consult-compile-error
    274 #+findex: consult-flymake
    275 #+findex: consult-xref
    276 - =consult-compile-error=: Jump to a compilation error. Supports live preview
    277   narrowing and recursive editing.
    278 - =consult-flymake=: Jump to flymake diagnostic. Supports live preview and
    279   recursive editing. The command supports narrowing. Press =e SPC=, =w SPC=, =n SPC=
    280   to only show errors, warnings and notes respectively.
    281 - =consult-xref=: Integration with xref. This function can be set as
    282   =xref-show-xrefs-function= and =xref-show-definitions-function=.
    283 
    284 ** Histories
    285 :properties:
    286 :description: Navigating histories
    287 :end:
    288 #+cindex: history
    289 
    290 #+findex: consult-complex-command
    291 #+findex: consult-history
    292 #+findex: consult-isearch-history
    293 - =consult-complex-command=: Select a command from the
    294   =command-history=. This command is a =completing-read= version of
    295   =repeat-complex-command= and is also a replacement for the =command-history=
    296   command from chistory.el.
    297 - =consult-history=: Insert a string from the current buffer history, for example
    298   the Eshell or Comint history. You can also invoke this command from the
    299   minibuffer. In that case =consult-history= uses the history stored in the
    300   =minibuffer-history-variable=. If you prefer =completion-at-point=, take a look at
    301   =cape-history= from the [[https://github.com/minad/cape][Cape]] package.
    302 - =consult-isearch-history=: During an Isearch session, this command picks a
    303   search string from history and continues the search with the newly selected
    304   string. Outside of Isearch, the command allows you to pick a string from the
    305   history and starts a new Isearch. =consult-isearch-history= acts as a drop-in
    306   replacement for =isearch-edit-string=.
    307 
    308 ** Modes
    309 :properties:
    310 :description: Toggling minor modes and executing commands
    311 :end:
    312 #+cindex: minor mode
    313 #+cindex: major mode
    314 
    315 #+findex: consult-minor-mode-menu
    316 #+findex: consult-mode-command
    317 - =consult-minor-mode-menu=: Enable/disable minor mode. Supports
    318   narrowing to on/off/local/global modes by pressing =i/o/l/g SPC=
    319   respectively.
    320 - =consult-mode-command=: Run a command from the currently active minor or major
    321   modes. Supports narrowing to local-minor/global-minor/major mode via the keys
    322   =l/g/m=.
    323 
    324 ** Org Mode
    325 :properties:
    326 :description: Org-specific commands
    327 :end:
    328 
    329 #+findex: consult-org-heading
    330 #+findex: consult-org-agenda
    331 - =consult-org-heading=: Similar to =consult-outline=, for Org
    332   buffers. Supports narrowing by heading level, priority and TODO
    333   state, as well as live preview and recursive editing.
    334 - =consult-org-agenda=: Jump to an agenda heading. Supports
    335   narrowing by heading level, priority and TODO state, as well as
    336   live preview and recursive editing.
    337 
    338 ** Miscellaneous
    339 :properties:
    340 :description: Various other useful commands
    341 :end:
    342 
    343 #+findex: consult-completion-in-region
    344 #+findex: consult-theme
    345 #+findex: consult-man
    346 #+findex: consult-preview-at-point
    347 #+findex: consult-preview-at-point-mode
    348 - =consult-man=: Find Unix man page, via Unix =apropos= or =man -k=. =consult-man= opens
    349   the selected man page using the Emacs =man= command.
    350 - =consult-theme=: Select a theme and disable all currently enabled themes.
    351   Supports live preview of the theme while scrolling through the candidates.
    352 - =consult-preview-at-point= and =consult-preview-at-point-mode=: Command and minor
    353   mode which previews the candidate at point in the =*Completions*= buffer. This
    354   mode is relevant if you use [[https://git.sr.ht/~protesilaos/mct][Mct]] or the default =*Completions*= UI.
    355 - =consult-completion-in-region=: In case you don't use [[https://github.com/minad/corfu][Corfu]] as your in-buffer
    356   completion UI, this function can be set as =completion-in-region-function=. Then
    357   your minibuffer completion UI (e.g., Vertico or Icomplete) will be used for
    358   =completion-at-point=. If you use Mct, you can give =mct-region-mode= a try.
    359   #+begin_src emacs-lisp
    360     ;; Use `consult-completion-in-region' if Vertico is enabled.
    361     ;; Otherwise use the default `completion--in-region' function.
    362     (setq completion-in-region-function
    363           (lambda (&rest args)
    364             (apply (if vertico-mode
    365                        #'consult-completion-in-region
    366                      #'completion--in-region)
    367                    args)))
    368   #+end_src
    369   Instead of =consult-completion-in-region=, you may prefer to see the
    370   completions directly in the buffer as a small popup. In that case, I recommend
    371   either the [[https://github.com/minad/corfu][Corfu]] or the [[https://github.com/company-mode/company-mode][Company]] package. There is a technical limitation of
    372   =consult-completion-in-region= in combination with Lsp-mode or Eglot. The Lsp
    373   server relies on the input at point, in order to generate refined candidate
    374   strings. Since the completion is transferred from the original buffer to the
    375   minibuffer, the server does not receive the updated input. LSP completion
    376   works with Corfu or Company though, which perform the completion directly in
    377   the original buffer.
    378 
    379 * Special features
    380 :properties:
    381 :description: Enhancements over built-in `completing-read'
    382 :end:
    383 
    384 Consult enhances =completing-read= with live previews of candidates, additional
    385 narrowing capabilities to candidate groups and asynchronously generated
    386 candidate lists. The internal =consult--read= function, which is used by most
    387 Consult commands, is a thin wrapper around =completing-read= and provides the
    388 special functionality. In order to support multiple candidate sources there
    389 exists the high-level function =consult--multi=. The architecture of Consult
    390 allows it to work with different completion systems in the backend, while still
    391 offering advanced features.
    392 
    393 ** Live previews
    394 :properties:
    395 :description: Preview the currently selected candidate
    396 :custom_id: live-previews
    397 :end:
    398 #+cindex: preview
    399 
    400 Some Consult commands support live previews. For example when you scroll through
    401 the items of =consult-line=, the buffer will scroll to the corresponding position.
    402 It is possible to jump back and forth between the minibuffer and the buffer to
    403 perform recursive editing while the search is ongoing.
    404 
    405 Consult enables previews by default. You can disable them by adjusting the
    406 =consult-preview-key= variable. Furthermore it is possible to specify keybindings
    407 which trigger the preview manually as shown in the [[#use-package-example][example configuration]]. The
    408 default setting of =consult-preview-key= is =any= which means that Consult triggers
    409 the preview /immediately/ on any key press when the selected candidate changes.
    410 You can configure each command individually with its own =:preview-key=. The
    411 following settings are possible:
    412 
    413 - Automatic and immediate ='any=
    414 - Automatic and delayed =(list :debounce 0.5 'any)=
    415 - Manual and immediate =(kbd "M-.")=
    416 - Manual and delayed =(list :debounce 0.5 (kbd "M-."))=
    417 - Disabled =nil=
    418 
    419 A safe recommendation is to leave automatic immediate previews enabled in
    420 general and disable the automatic preview only for commands where the preview
    421 may be expensive due to file loading. Internally, Consult uses the
    422 value of =this-command= to determine the =:preview-key=
    423 customized. This means that if you wrap a =consult-*= command within
    424 your own function or command, you will also need to add the name of
    425 /your custom command/ to the =consult-customize= call in order for it
    426 to be considered.
    427 
    428 #+begin_src emacs-lisp
    429   (consult-customize
    430    consult-ripgrep consult-git-grep consult-grep
    431    consult-bookmark consult-recent-file consult-xref
    432    consult--source-bookmark consult--source-file-register
    433    consult--source-recent-file consult--source-project-recent-file
    434    ;; my/command-wrapping-consult    ;; disable auto previews inside my command
    435    :preview-key '(:debounce 0.4 any) ;; Option 1: Delay preview
    436    ;; :preview-key (kbd "M-."))      ;; Option 2: Manual preview
    437 #+end_src
    438 
    439 In this case one may wonder what the difference is between using an Embark
    440 action on the current candidate in comparison to a manually triggered preview.
    441 The main difference is that the files opened by manual preview are closed again
    442 after the completion session. Furthermore during preview some functionality is
    443 disabled to improve the performance, see for example the customization variables
    444 =consult-preview-allowed-hooks= and =consult-preview-variables=. Files larger than
    445 =consult-preview-raw-size= are previewed literally without syntax highlighting and
    446 without changing the major mode. Delaying the preview is also useful for
    447 =consult-theme=, since the theme preview is slow. The delay results in a smoother
    448 UI experience.
    449 
    450 #+begin_src emacs-lisp
    451   ;; Preview on any key press, but delay 0.5s
    452   (consult-customize consult-theme :preview-key '(:debounce 0.5 any))
    453   ;; Preview immediately on M-., on up/down after 0.5s, on any other key after 1s
    454   (consult-customize consult-theme
    455                      :preview-key
    456                      (list (kbd "M-.")
    457                            :debounce 0.5 (kbd "<up>") (kbd "<down>")
    458                            :debounce 1 'any))
    459 #+end_src
    460 
    461 ** Narrowing and grouping
    462 :properties:
    463 :description: Restricting the completion to a candidate group
    464 :custom_id: narrowing-and-grouping
    465 :end:
    466 #+cindex: narrowing
    467 
    468 Consult has special support for candidate groups. If the completion UI supports
    469 the grouping functionality, the UI separates the groups with thin lines and
    470 shows group titles. Grouping is useful if the list of candidates consists of
    471 candidates of multiple types or candidates from [[#multiple-sources][multiple sources]], like the
    472 =consult-buffer= command, which shows both buffers and recently opened files. Note
    473 that you can disable the group titles by setting the =:group= property of the
    474 corresponding command to nil using the =consult-customize= macro.
    475 
    476 By entering a narrowing prefix or by pressing a narrowing key it is possible to
    477 restrict the completion candidates to a certain candidate group. When you use
    478 the =consult-buffer= command, you can enter the prefix =b SPC= to restrict list of
    479 candidates to buffers only. If you press =DEL= afterwards, the full candidate list
    480 will be shown again. Furthermore a narrowing prefix key and a widening key can
    481 be configured which can be pressed to achieve the same effect, see the
    482 configuration variables =consult-narrow-key= and =consult-widen-key=.
    483 
    484 After pressing =consult-narrow-key=, the possible narrowing keys can be shown by
    485 pressing =C-h=. When pressing =C-h= after some prefix key, the =prefix-help-command=
    486 is invoked, which shows the keybinding help window by default. As a more compact
    487 alternative, there is the =consult-narrow-help= command which can be bound to a
    488 key, for example =?= or =C-h= in the =consult-narrow-map=, as shown in the [[#use-package-example][example
    489 configuration]]. If [[https://github.com/justbur/emacs-which-key][which-key]] is installed, the narrowing keys are automatically
    490 shown in the which-key window after pressing the =consult-narrow-key=.
    491 
    492 ** Asynchronous search
    493 :properties:
    494 :description: Filtering asynchronously generated candidate lists
    495 :end:
    496 #+cindex: asynchronous search
    497 
    498 Consult has support for asynchronous generation of candidate lists. This feature
    499 is used for search commands like =consult-grep=, where the list of matches is
    500 generated dynamically while the user is typing a regular expression. The grep
    501 process is executed in the background. When modifying the regular expression,
    502 the background process is terminated and a new process is started with the
    503 modified regular expression.
    504 
    505 The matches, which have been found, can then be narrowed using the installed
    506 Emacs completion-style. This can be powerful if you are using for example the
    507 =orderless= completion style.
    508 
    509 This two-level filtering is possible by splitting the input string. Part of the
    510 input string is treated as input to grep and part of the input is used for
    511 filtering. There are multiple splitting styles available, configured in
    512 ~consult-async-split-styles-alist~: =nil=, =comma=, =semicolon= and =perl=. The default
    513 splitting style is configured with the variable ~consult-async-split-style~.
    514 
    515 With the =comma= and =semicolon= splitting styles, the first word before the comma
    516 or semicolon is passed to grep, the remaining string is used for filtering. The
    517 =nil= splitting style does not perform any splitting, the whole input is passed to
    518 grep.
    519 
    520 The =perl= splitting style splits the input string at a punctuation character,
    521 using a similar syntax as Perl regular expressions.
    522 
    523 Examples:
    524 
    525 - =#defun=: Search for "defun" using grep.
    526 - =#consult embark=: Search for both "consult" and "embark" using grep in any order.
    527 - =#first.*second=: Search for "first" followed by "second" using grep.
    528 - =#\(consult\|embark\)=: Search for "consult" or "embark" using grep. Note the
    529   usage of Emacs-style regular expressions.
    530 - =#defun#consult=: Search for "defun" using grep, filter with the word
    531   "consult".
    532 - =/defun/consult=: It is also possible to use other punctuation
    533   characters.
    534 - =#to#=: Force searching for "to" using grep, since the grep pattern
    535   must be longer than =consult-async-min-input= characters by default.
    536 - =#defun -- --invert-match#=: Pass argument =--invert-match= to grep.
    537 
    538 Asynchronous processes like =find= and =grep= create an error log buffer
    539 =_*consult-async*= (note the leading space), which is useful for
    540 troubleshooting. The prompt has a small indicator showing the process status:
    541 
    542 - =:= the usual prompt colon, before input is provided.
    543 - =*= with warning face, the process is running.
    544 - =:= with success face, success, process exited with an error code of zero.
    545 - =!= with error face, failure, process exited with a nonzero error code.
    546 - =;= with error face, interrupted, for example if more input is provided.
    547 
    548 ** Multiple sources
    549 :properties:
    550 :description: Combining candidates from different sources
    551 :custom_id: multiple-sources
    552 :end:
    553 #+cindex: multiple sources
    554 
    555 Multiple synchronous candidate sources can be combined. This feature is used by
    556 the =consult-buffer= command to present buffer-like candidates in a single menu
    557 for quick access. By default =consult-buffer= includes buffers, bookmarks, recent
    558 files and project-specific buffers and files. It is possible to configure the
    559 list of sources via the =consult-buffer-sources= variable. Arbitrary custom
    560 sources can be defined.
    561 
    562 As an example, the bookmark source is defined as follows:
    563 
    564 #+begin_src emacs-lisp
    565 (defvar consult--source-bookmark
    566   `(:name     "Bookmark"
    567     :narrow   ?m
    568     :category bookmark
    569     :face     consult-bookmark
    570     :history  bookmark-history
    571     :items    ,#'bookmark-all-names
    572     :action   ,#'consult--bookmark-action))
    573 #+end_src
    574 
    575 Required source fields:
    576 - =:category= Completion category.
    577 - =:items= List of strings to select from or function returning list of strings.
    578   A list of cons cells is not supported.
    579 
    580 Optional source fields:
    581 - =:name= Name of the source, used for narrowing, group titles and annotations.
    582 - =:narrow= Narrowing character or =(character . string)= pair.
    583 - =:preview-key= Preview key or keys which trigger preview.
    584 - =:enabled= Function which must return t if the source is enabled.
    585 - =:hidden= When t candidates of this source are hidden by default.
    586 - =:face= Face used for highlighting the candidates.
    587 - =:annotate= Annotation function called for each candidate, returns string.
    588 - =:history= Name of history variable to add selected candidate.
    589 - =:default= Must be t if the first item of the source is the default value.
    590 - =:action= Function called with the selected candidate.
    591 - =:new= Function called with new candidate name, only if =:require-match= is nil.
    592 - =:state= State constructor for the source, must return the state function.
    593 - Other source fields can be added specifically to the use case.
    594 
    595 The =:state= and =:action= fields of the sources deserve a longer explanation. The
    596 =:action= function takes a single argument and is only called after selection with
    597 the selected candidate, if the selection has not been aborted. This
    598 functionality is provided for convenience and easy definition of sources. The
    599 =:state= field is more general. The =:state= function is a constructor function
    600 without arguments, which can perform some setup necessary for the preview. It
    601 must return a closure which takes an ACTION and a CANDIDATE argument. See the
    602 docstring of =consult--with-preview= for more details about the ACTION argument.
    603 
    604 By default, =consult-buffer= previews buffers, bookmarks and files. Loading recent
    605 files or bookmarks can result in expensive operations. However it is possible to
    606 configure a manual preview as follows.
    607 
    608 #+begin_src emacs-lisp
    609   (consult-customize
    610    consult--source-bookmark consult--source-file-register
    611    consult--source-recent-file consult--source-project-recent-file
    612    :preview-key (kbd "M-."))
    613 #+end_src
    614 
    615 Sources can be added directly to the =consult-buffer-source= list for convenience.
    616 For example views/perspectives can be added to the list of virtual buffers from
    617 a library like [[https://github.com/minad/bookmark-view/][bookmark-view]].
    618 
    619 #+begin_src emacs-lisp
    620 ;; Configure new bookmark-view source
    621 (add-to-list 'consult-buffer-sources
    622               (list :name     "View"
    623                     :narrow   ?v
    624                     :category 'bookmark
    625                     :face     'font-lock-keyword-face
    626                     :history  'bookmark-view-history
    627                     :action   #'consult--bookmark-action
    628                     :items    #'bookmark-view-names)
    629               'append)
    630 
    631 ;; Modify bookmark source, such that views are hidden
    632 (setq consult--source-bookmark
    633       (plist-put
    634        consult--source-bookmark :items
    635        (lambda ()
    636          (bookmark-maybe-load-default-file)
    637          (mapcar #'car
    638                  (seq-remove (lambda (x)
    639                                (eq #'bookmark-view-handler
    640                                    (alist-get 'handler (cdr x))))
    641                              bookmark-alist)))))
    642 #+end_src
    643 
    644 Another useful source lists all Org buffers and lets you create new ones. One
    645 can create similar sources for other major modes, e.g., for Eshell.
    646 
    647 #+begin_src emacs-lisp
    648   (defvar org-source
    649     (list :name     "Org Buffer"
    650           :category 'buffer
    651           :narrow   ?o
    652           :face     'consult-buffer
    653           :history  'buffer-name-history
    654           :state    #'consult--buffer-state
    655           :new
    656           (lambda (name)
    657             (with-current-buffer (get-buffer-create name)
    658               (insert "#+title: " name "\n\n")
    659               (org-mode)
    660               (consult--buffer-action (current-buffer))))
    661           :items
    662           (lambda ()
    663             (mapcar #'buffer-name
    664                     (seq-filter
    665                      (lambda (x)
    666                        (eq (buffer-local-value 'major-mode x) 'org-mode))
    667                      (buffer-list))))))
    668 
    669   (add-to-list 'consult-buffer-sources 'org-source 'append)
    670 #+end_src
    671 
    672 For more details, see the documentation of =consult-buffer= and of the
    673 internal =consult--multi= API. The =consult--multi= function can be used to
    674 create new multi-source commands, but is part of the internal API as of now,
    675 since some details may still change.
    676 
    677 ** Embark integration
    678 :properties:
    679 :description: Actions, Grep/Occur-buffer export
    680 :custom_id: embark-integration
    681 :end:
    682 #+cindex: embark
    683 
    684 *NOTE*: Install the =embark-consult= package from MELPA, which provides
    685 Consult-specific Embark actions and the Occur buffer export.
    686 
    687 Embark is a versatile package which offers context dependent actions, comparable
    688 to a context menu. See the [[https://github.com/oantolin/embark][Embark manual]] for an extensive description of its
    689 capabilities.
    690 
    691 Actions are commands which can operate on the currently selected candidate (or
    692 target in Embark terminology). When completing files, for example the
    693 =delete-file= command is offered. With Embark you can execute arbitrary commands
    694 on the currently selected candidate via =M-x=.
    695 
    696 Furthermore Embark provides the =embark-collect= command, which collects
    697 candidates and presents them in an Embark collect buffer, where further actions
    698 can be applied to them. A related feature is the =embark-export= command, which
    699 exports candidate lists to a buffer of a special type. For example in the case
    700 of file completion, a Dired buffer is opened.
    701 
    702 In the context of Consult, particularly exciting is the possibility to export
    703 the matching lines from =consult-line=, =consult-outline=, =consult-mark= and
    704 =consult-global-mark=. The matching lines are exported to an Occur buffer where
    705 they can be edited via the =occur-edit-mode= (press key =e=). Similarly, Embark
    706 supports exporting the matches found by =consult-grep=, =consult-ripgrep= and
    707 =consult-git-grep= to a Grep buffer, where the matches across files can be edited,
    708 if the [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]] package is installed. These three workflows are symmetric.
    709 
    710 + =consult-line= -> =embark-export= to =occur-mode= buffer -> =occur-edit-mode= for editing of matches in buffer.
    711 + =consult-grep= -> =embark-export= to =grep-mode= buffer -> =wgrep= for editing of all matches.
    712 + =consult-find= -> =embark-export= to =dired-mode= buffer -> =wdired-change-to-wdired-mode= for editing.
    713 
    714 * Configuration
    715 :properties:
    716 :description: Example configuration and customization variables
    717 :end:
    718 
    719 Consult can be installed from [[https://elpa.gnu.org/packages/consult.html][ELPA]] or [[https://melpa.org/#/consult][MELPA]] via the Emacs built-in package
    720 manager. Alternatively it can be directly installed from the development
    721 repository via other non-standard package managers.
    722 
    723 There is the [[https://github.com/minad/consult/wiki][Consult wiki]], where additional configuration examples can be
    724 contributed.
    725 
    726 *IMPORTANT:* It is strongly recommended that you enable [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding.html][lexical binding]] in your
    727 configuration. Consult relies on lambdas and lexical closures. For this reason
    728 many Consult-related snippets require lexical binding.
    729 
    730 ** Use-package example
    731 :properties:
    732 :description: Configuration example based on use-package
    733 :custom_id: use-package-example
    734 :end:
    735 #+cindex: use-package
    736 
    737 The Consult package only provides commands and does not add any keybindings or
    738 modes. Therefore the package is non-intrusive but requires a little setup
    739 effort. In order to use the Consult commands, it is advised to add keybindings
    740 for commands which are accessed often. Rarely used commands can be invoked via
    741 =M-x=. Feel free to only bind the commands you consider useful to your workflow.
    742 The configuration shown here relies on the =use-package= macro, which is a
    743 convenient tool to manage package configurations.
    744 
    745 *NOTE:* There is the [[https://github.com/minad/consult/wiki][Consult wiki]], where you can contribute additional
    746 configuration examples.
    747 
    748 #+begin_src emacs-lisp
    749   ;; Example configuration for Consult
    750   (use-package consult
    751     ;; Replace bindings. Lazily loaded due by `use-package'.
    752     :bind (;; C-c bindings (mode-specific-map)
    753            ("C-c h" . consult-history)
    754            ("C-c m" . consult-mode-command)
    755            ("C-c k" . consult-kmacro)
    756            ;; C-x bindings (ctl-x-map)
    757            ("C-x M-:" . consult-complex-command)     ;; orig. repeat-complex-command
    758            ("C-x b" . consult-buffer)                ;; orig. switch-to-buffer
    759            ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
    760            ("C-x 5 b" . consult-buffer-other-frame)  ;; orig. switch-to-buffer-other-frame
    761            ("C-x r b" . consult-bookmark)            ;; orig. bookmark-jump
    762            ("C-x p b" . consult-project-buffer)      ;; orig. project-switch-to-buffer
    763            ;; Custom M-# bindings for fast register access
    764            ("M-#" . consult-register-load)
    765            ("M-'" . consult-register-store)          ;; orig. abbrev-prefix-mark (unrelated)
    766            ("C-M-#" . consult-register)
    767            ;; Other custom bindings
    768            ("M-y" . consult-yank-pop)                ;; orig. yank-pop
    769            ;; M-g bindings (goto-map)
    770            ("M-g e" . consult-compile-error)
    771            ("M-g f" . consult-flymake)               ;; Alternative: consult-flycheck
    772            ("M-g g" . consult-goto-line)             ;; orig. goto-line
    773            ("M-g M-g" . consult-goto-line)           ;; orig. goto-line
    774            ("M-g o" . consult-outline)               ;; Alternative: consult-org-heading
    775            ("M-g m" . consult-mark)
    776            ("M-g k" . consult-global-mark)
    777            ("M-g i" . consult-imenu)
    778            ("M-g I" . consult-imenu-multi)
    779            ;; M-s bindings (search-map)
    780            ("M-s d" . consult-find)
    781            ("M-s D" . consult-locate)
    782            ("M-s g" . consult-grep)
    783            ("M-s G" . consult-git-grep)
    784            ("M-s r" . consult-ripgrep)
    785            ("M-s l" . consult-line)
    786            ("M-s L" . consult-line-multi)
    787            ("M-s k" . consult-keep-lines)
    788            ("M-s u" . consult-focus-lines)
    789            ;; Isearch integration
    790            ("M-s e" . consult-isearch-history)
    791            :map isearch-mode-map
    792            ("M-e" . consult-isearch-history)         ;; orig. isearch-edit-string
    793            ("M-s e" . consult-isearch-history)       ;; orig. isearch-edit-string
    794            ("M-s l" . consult-line)                  ;; needed by consult-line to detect isearch
    795            ("M-s L" . consult-line-multi)            ;; needed by consult-line to detect isearch
    796            ;; Minibuffer history
    797            :map minibuffer-local-map
    798            ("M-s" . consult-history)                 ;; orig. next-matching-history-element
    799            ("M-r" . consult-history))                ;; orig. previous-matching-history-element
    800 
    801     ;; Enable automatic preview at point in the *Completions* buffer. This is
    802     ;; relevant when you use the default completion UI.
    803     :hook (completion-list-mode . consult-preview-at-point-mode)
    804 
    805     ;; The :init configuration is always executed (Not lazy)
    806     :init
    807 
    808     ;; Optionally configure the register formatting. This improves the register
    809     ;; preview for `consult-register', `consult-register-load',
    810     ;; `consult-register-store' and the Emacs built-ins.
    811     (setq register-preview-delay 0.5
    812           register-preview-function #'consult-register-format)
    813 
    814     ;; Optionally tweak the register preview window.
    815     ;; This adds thin lines, sorting and hides the mode line of the window.
    816     (advice-add #'register-preview :override #'consult-register-window)
    817 
    818     ;; Use Consult to select xref locations with preview
    819     (setq xref-show-xrefs-function #'consult-xref
    820           xref-show-definitions-function #'consult-xref)
    821 
    822     ;; Configure other variables and modes in the :config section,
    823     ;; after lazily loading the package.
    824     :config
    825 
    826     ;; Optionally configure preview. The default value
    827     ;; is 'any, such that any key triggers the preview.
    828     ;; (setq consult-preview-key 'any)
    829     ;; (setq consult-preview-key (kbd "M-."))
    830     ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
    831     ;; For some commands and buffer sources it is useful to configure the
    832     ;; :preview-key on a per-command basis using the `consult-customize' macro.
    833     (consult-customize
    834      consult-theme :preview-key '(:debounce 0.2 any)
    835      consult-ripgrep consult-git-grep consult-grep
    836      consult-bookmark consult-recent-file consult-xref
    837      consult--source-bookmark consult--source-file-register
    838      consult--source-recent-file consult--source-project-recent-file
    839      ;; :preview-key (kbd "M-.")
    840      :preview-key '(:debounce 0.4 any))
    841 
    842     ;; Optionally configure the narrowing key.
    843     ;; Both < and C-+ work reasonably well.
    844     (setq consult-narrow-key "<") ;; (kbd "C-+")
    845 
    846     ;; Optionally make narrowing help available in the minibuffer.
    847     ;; You may want to use `embark-prefix-help-command' or which-key instead.
    848     ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
    849 
    850     ;; By default `consult-project-function' uses `project-root' from project.el.
    851     ;; Optionally configure a different project root function.
    852     ;; There are multiple reasonable alternatives to chose from.
    853     ;;;; 1. project.el (the default)
    854     ;; (setq consult-project-function #'consult--default-project--function)
    855     ;;;; 2. projectile.el (projectile-project-root)
    856     ;; (autoload 'projectile-project-root "projectile")
    857     ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
    858     ;;;; 3. vc.el (vc-root-dir)
    859     ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
    860     ;;;; 4. locate-dominating-file
    861     ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
    862   )
    863 #+end_src
    864 
    865 ** Custom variables
    866 :properties:
    867 :description: Short description of all customization settings
    868 :end:
    869 #+cindex: customization
    870 
    871 *TIP:* If you have [[https://github.com/minad/marginalia][Marginalia]] installed, type =M-x customize-variable RET
    872 ^consult= to see all Consult-specific customizable variables with their current
    873 values and abbreviated description. Alternatively, type =C-h a ^consult= to get
    874 an overview of all Consult variables and functions with their descriptions.
    875 
    876 | Variable                         | Description                                           |
    877 |----------------------------------+-------------------------------------------------------|
    878 | consult-after-jump-hook          | Functions to call after jumping to a location         |
    879 | consult-async-input-debounce     | Input debounce for asynchronous commands              |
    880 | consult-async-input-throttle     | Input throttle for asynchronous commands              |
    881 | consult-async-min-input          | Minimum numbers of letters needed for async process   |
    882 | consult-async-refresh-delay      | Refresh delay for asynchronous commands               |
    883 | consult-async-split-style        | Splitting style used for async commands               |
    884 | consult-async-split-styles-alist | Available splitting styles used for async commands    |
    885 | consult-bookmark-narrow          | Narrowing configuration for =consult-bookmark=          |
    886 | consult-buffer-filter            | Filter for =consult-buffer=                             |
    887 | consult-buffer-sources           | List of virtual buffer sources                        |
    888 | consult-find-args                | Command line arguments for find                       |
    889 | consult-fontify-max-size         | Buffers larger than this limit are not fontified      |
    890 | consult-fontify-preserve         | Preserve fontification for line-based commands.       |
    891 | consult-git-grep-args            | Command line arguments for git-grep                   |
    892 | consult-goto-line-numbers        | Show line numbers for =consult-goto-line=               |
    893 | consult-grep-max-columns         | Maximal number of columns of the matching lines       |
    894 | consult-grep-args                | Command line arguments for grep                       |
    895 | consult-imenu-config             | Mode-specific configuration for =consult-imenu=         |
    896 | consult-line-numbers-widen       | Show absolute line numbers when narrowing is active.  |
    897 | consult-line-start-from-top      | Start the =consult-line= search from the top            |
    898 | consult-locate-args              | Command line arguments for locate                     |
    899 | consult-man-args                 | Command line arguments for man                        |
    900 | consult-mode-command-filter      | Filter for =consult-mode-command=                       |
    901 | consult-mode-histories           | Mode-specific history variables                       |
    902 | consult-narrow-key               | Narrowing prefix key during completion                |
    903 | consult-point-placement          | Placement of the point when jumping to matches        |
    904 | consult-preview-key              | Keys which triggers preview                           |
    905 | consult-preview-allowed-hooks    | List of =find-file= hooks to enable during preview      |
    906 | consult-preview-excluded-files   | Regexps matched against file names during preview     |
    907 | consult-preview-max-count        | Maximum number of files to keep open during preview   |
    908 | consult-preview-max-size         | Files larger than this size are not previewed         |
    909 | consult-preview-raw-size         | Files larger than this size are previewed in raw form |
    910 | consult-preview-variables        | Alist of variables to bind during preview             |
    911 | consult-project-buffer-sources   | List of virtual project buffer sources                |
    912 | consult-project-function         | Function which returns current project root           |
    913 | consult-register-prefix          | Prefix string for register keys during completion     |
    914 | consult-ripgrep-args             | Command line arguments for ripgrep                    |
    915 | consult-themes                   | List of themes to be presented for selection          |
    916 | consult-widen-key                | Widening key during completion                        |
    917 | consult-yank-rotate              | Rotate kill ring                                      |
    918 
    919 ** Fine-tuning of individual commands
    920 :properties:
    921 :alt_title: Fine-tuning
    922 :description: Fine-grained configuration for special requirements
    923 :end:
    924 
    925 *NOTE:* Consult supports fine-grained customization of individual commands. This
    926 configuration feature exists for experienced users with special requirements.
    927 There is the [[https://github.com/minad/consult/wiki][Consult wiki]], where we collect further configuration examples.
    928 
    929 Commands and buffer sources allow flexible, individual customization by using
    930 the =consult-customize= macro. You can override any option passed to the internal
    931 =consult--read= API. The [[https://github.com/minad/consult/wiki][Consult wiki]] already contains a numerous useful
    932 configuration examples. Note that since =consult--read= is part of the internal
    933 API, options could be removed, replaced or renamed in future versions of the
    934 package.
    935 
    936 Useful options are:
    937 - =:prompt= set the prompt string
    938 - =:preview-key= set the preview key, default is =consult-preview-key=
    939 - =:initial= set the initial input
    940 - =:default= set the default value
    941 - =:history= set the history variable symbol
    942 - =:add-history= add items to the future history, for example symbol at point
    943 - =:sort= enable or disable sorting
    944 - =:group= set to nil to disable candidate grouping and titles.
    945 - =:inherit-input-method= set to non-nil to inherit the input method.
    946 
    947 #+begin_src emacs-lisp
    948   (consult-customize
    949    ;; Disable preview for `consult-theme' completely.
    950    consult-theme :preview-key nil
    951    ;; Set preview for `consult-buffer' to key `M-.'
    952    consult-buffer :preview-key (kbd "M-.")
    953    ;; For `consult-line' change the prompt and specify multiple preview
    954    ;; keybindings. Note that you should bind <S-up> and <S-down> in the
    955    ;; `minibuffer-local-completion-map' or `vertico-map' to the commands which
    956    ;; select the previous or next candidate.
    957    consult-line :prompt "Search: "
    958    :preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
    959 #+end_src
    960 
    961 The configuration values are evaluated at runtime, just before the completion
    962 session is started. Therefore you can use for example =thing-at-point= to adjust
    963 the initial input or the future history.
    964 
    965 #+begin_src emacs-lisp
    966   (consult-customize
    967    consult-line
    968    :add-history (seq-some #'thing-at-point '(region symbol)))
    969 
    970   (defalias 'consult-line-thing-at-point 'consult-line)
    971 
    972   (consult-customize
    973    consult-line-thing-at-point
    974    :initial (thing-at-point 'symbol))
    975 #+end_src
    976 
    977 Generally it is possible to modify commands for your individual needs by the
    978 following techniques:
    979 
    980 1. Use =consult-customize= in order to change the command or source settings.
    981 2. Create your own wrapper function which passes modified arguments to the Consult functions.
    982 3. Create your own buffer [[#multiple-sources][multi sources]] for =consult-buffer=.
    983 4. Create advices to modify some internal behavior.
    984 5. Write or propose a patch.
    985 
    986 * Recommended packages
    987 :properties:
    988 :description: Related packages recommended for installation
    989 :end:
    990 
    991 I use and recommend this combination of packages:
    992 
    993 - consult: This package
    994 - [[https://github.com/minad/vertico][vertico]]: Fast and minimal vertical completion system
    995 - [[https://github.com/minad/marginalia][marginalia]]: Annotations for the completion candidates
    996 - [[https://github.com/oantolin/embark][embark and embark-consult]]: Action commands, which can act on the completion candidates
    997 - [[https://github.com/oantolin/orderless][orderless]]: Completion style which offers flexible candidate filtering
    998 
    999 There exist many other fine completion UIs beside Vertico, which are supported
   1000 by Consult. Give them a try and find out which interaction model fits best for
   1001 you.
   1002 
   1003 - The builtin completion UI, which pops up the =*Completions*= buffer.
   1004 - The builtin =icomplete-vertical-mode= in Emacs 28.
   1005 - [[https://git.sr.ht/~protesilaos/mct][mct by Protesilaos Stavrou]]: Minibuffer and Completions in Tandem, which builds
   1006   on the default completion UI (development currently [[https://protesilaos.com/codelog/2022-04-14-emacs-discontinue-mct/][discontinued]]).
   1007 
   1008 Note that all packages are independent and can be exchanged with alternative
   1009 components, since there exist no hard dependencies. Furthermore it is possible
   1010 to get started with only default completion and Consult and add more components
   1011 later to the mix. For example you can omit Marginalia if you don't need
   1012 annotations. I highly recommend the Embark package, but in order to familiarize
   1013 yourself with the other components, you can first start without it - or you could
   1014 use with Embark right away and add the other components later on.
   1015 
   1016 * Auxiliary packages
   1017 :properties:
   1018 :description: Integrations with the wider ecosystem
   1019 :end:
   1020 
   1021 You can integrate Consult with special programs or with other packages in the
   1022 wider Emacs ecosystem. You may want to install some of theses packages depending
   1023 on your preferences and requirements.
   1024 
   1025 - [[https://github.com/yadex205/consult-ag][consult-ag]]: Support for the [[https://github.com/ggreer/the_silver_searcher][Silver Searcher]] in the style of =consult-grep=.
   1026 - [[https://github.com/mohkale/consult-company][consult-company]]: Completion at point using the [[https://github.com/company-mode/company-mode][Company]] backends.
   1027 - [[https://github.com/youngker/consult-codesearch.el][consult-codesearch]]: Integration with [[https://github.com/google/codesearch][Code Search]].
   1028 - [[https://github.com/karthink/consult-dir][consult-dir]]: Directory jumper using Consult multi sources.
   1029 - [[https://codeberg.org/ravi/consult-dash][consult-dash]]: Consult interface to [[https://github.com/dash-docs-el/dash-docs][Dash documentation]]
   1030 - [[https://github.com/mohkale/consult-eglot][consult-eglot]]: Integration with Eglot (LSP client).
   1031 - [[https://github.com/minad/consult-flycheck][consult-flycheck]]: Additional Flycheck integration.
   1032 - [[https://gitlab.com/OlMon/consult-flyspell][consult-flyspell]]: Additional Flyspell integration.
   1033 - [[https://github.com/ghosty141/consult-git-log-grep][consult-git-log-grep]]: Consult interface to git log.
   1034 - [[https://github.com/Nyoho/consult-hatena-bookmark][consult-hatena-bookmark]]: Access Hatena bookmarks.
   1035 - [[https://github.com/rcj/consult-ls-git][consult-ls-git]]: List files from git via Consult.
   1036 - [[https://github.com/gagbo/consult-lsp][consult-lsp]]: Integration with Lsp-mode (LSP client).
   1037 - [[https://codeberg.org/jao/consult-notmuch][consult-notmuch]]: Access the [[https://notmuchmail.org/][Notmuch]] email system using Consult.
   1038 - [[https://github.com/mclear-tools/consult-notes][consult-notes]]: Searching notes with Consult.
   1039 - [[https://github.com/jgru/consult-org-roam][consult-org-roam]]: Integration with [[https://github.com/org-roam/org-roam][Org-roam]].
   1040 - [[https://github.com/Qkessler/consult-project-extra/][consult-project-extra]]: Additional project.el extras and buffer sources.
   1041 - [[https://gitlab.com/OlMon/consult-projectile/][consult-projectile]]: Additional [[https://github.com/bbatsov/projectile][Projectile]] integration and buffer sources.
   1042 - [[https://codeberg.org/jao/consult-recoll][consult-recoll]]: Access the [[https://www.lesbonscomptes.com/recoll/][Recoll]] desktop full-text search using Consult.
   1043 - [[https://codeberg.org/jao/espotify][consult-spotify]]: Access the Spotify API and control your local music player.
   1044 - [[https://github.com/mohkale/consult-yasnippet][consult-yasnippet]]: Integration with Yasnippet.
   1045 - [[https://github.com/minad/affe][affe]]: Asynchronous Fuzzy Finder for Emacs based on Consult.
   1046 
   1047 Not directly related to Consult, but maybe still of interest are the following
   1048 packages. These packages should work well with Consult, follow a similar spirit or
   1049 offer functionality based on ~completing-read~.
   1050 
   1051 - [[https://github.com/minad/corfu][corfu]]: Completion systems for =completion-at-point= using small popups (Alternative to [[https://github.com/company-mode/company-mode][Company]]).
   1052 - [[https://github.com/minad/cape][cape]]: Completion At Point Extensions, which can be used with =consult-completion-in-region= and [[https://github.com/minad/corfu][Corfu]].
   1053 - [[https://github.com/minad/bookmark-view][bookmark-view]]: Store window configuration as bookmarks, possible integration with =consult-buffer=.
   1054 - [[https://github.com/bdarcus/citar][citar]]: Versatile package for citation insertion and bibliography management.
   1055 - [[https://github.com/astoff/devdocs.el][devdocs]]: Emacs viewer for [[https://devdocs.io/][DevDocs]] with a convenient completion interface.
   1056 - [[https://github.com/d12frosted/flyspell-correct][flyspell-correct]]: Apply spelling corrections by selecting via =completing-read=.
   1057 - [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]]: Editing of grep buffers, use together with =consult-grep= via =embark-export=.
   1058 - [[https://github.com/iyefrat/all-the-icons-completion][all-the-icons-completion]]: Icons for the completion UI.
   1059 
   1060 * Bug reports
   1061 :properties:
   1062 :description: How to create reproducible bug reports
   1063 :end:
   1064 
   1065 If you find a bug or suspect that there is a problem with Consult, please carry
   1066 out the following steps:
   1067 
   1068 1. *Update all the relevant packages to the newest version*.
   1069    This includes Consult, Vertico or other completion UIs, Marginalia, Embark
   1070    and Orderless.
   1071 2. Either use the default completion UI or ensure that exactly one of
   1072    =vertico-mode=, =mct-mode=, or =icomplete-mode= is enabled. The unsupported modes
   1073    =ivy-mode=, =helm-mode= and =ido-ubiquitous-mode= must be disabled.
   1074 3. Ensure that the =completion-styles= variable is properly configured. Try to set
   1075    =completion-styles= to a list including =substring= or =orderless=.
   1076 4. Try to reproduce the issue by starting a bare bone Emacs instance with =emacs -Q=
   1077    on the command line. Execute the following minimal code snippets in the
   1078    scratch buffer. This way we can exclude side effects due to configuration
   1079    settings. If other packages are relevant to reproduce the issue, include them
   1080    in the minimal configuration snippet.
   1081 
   1082 Minimal setup with Vertico for =emacs -Q=:
   1083 #+begin_src emacs-lisp
   1084 (package-initialize)
   1085 (require 'consult)
   1086 (require 'vertico)
   1087 (vertico-mode)
   1088 (setq completion-styles '(substring basic))
   1089 #+end_src
   1090 
   1091 Minimal setup with the default completion system for =emacs -Q=:
   1092 #+begin_src emacs-lisp
   1093 (package-initialize)
   1094 (require 'consult)
   1095 (setq completion-styles '(substring basic))
   1096 #+end_src
   1097 
   1098 Please provide the necessary important information with your bug report:
   1099 
   1100 - The minimal configuration snippet used to reproduce the issue.
   1101 - Your completion UI (Default completion, Vertico, Mct or Icomplete).
   1102 - A stack trace in case the bug triggers an exception.
   1103 - Your Emacs version, since bugs may be fixed or introduced in newer versions.
   1104 - Your operating system, since Emacs behavior varies between Linux, Mac and
   1105   Windows.
   1106 - The package manager, e.g., straight.el or package.el, used to install
   1107   the Emacs packages, in order to exclude update issues. Did you install
   1108   Consult as part of the Doom or Spacemacs Emacs distributions?
   1109 - Do you use Evil or other packages which apply deep changes?
   1110   Consult does not provide Evil integration out of the box, but there is some
   1111   support in [[https://github.com/emacs-evil/evil-collection][evil-collection]].
   1112 
   1113 When evaluating Consult-related code snippets you should enable [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding.html][lexical binding]].
   1114 Consult often relies on lambdas and lexical closures.
   1115 
   1116 * Contributions
   1117 :properties:
   1118 :description: Feature requests and pull requests
   1119 :end:
   1120 
   1121 Consult is a community effort, please participate in the discussions.
   1122 Contributions are welcome, but you may want to discuss potential contributions
   1123 first. Since this package is part of [[https://elpa.gnu.org/packages/consult.html][GNU ELPA]] contributions require a copyright
   1124 assignment to the FSF.
   1125 
   1126 If you have a proposal, take a look at the [[https://github.com/consult/issues][Consult issue tracker]] and the [[https://github.com/minad/consult/issues/6][Consult
   1127 wishlist]]. There have been many prior feature discussions. Please search through
   1128 the issue tracker, maybe your issue or feature request has already been
   1129 discussed. You can contribute to the [[https://github.com/minad/consult/wiki][Consult wiki]], in case you want to share
   1130 small configuration or command snippets.
   1131 
   1132 * Acknowledgments
   1133 :properties:
   1134 :description: Contributors and Sources of Inspiration
   1135 :end:
   1136 
   1137 This package took inspiration from [[https://github.com/abo-abo/swiper#counsel][Counsel]] by Oleh Krehel. Some of the Consult
   1138 commands originated in the Counsel package or the wiki of the Selectrum package.
   1139 This package exists only thanks to the help of these great contributors and
   1140 thanks to the feedback of many users. Thank you!
   1141 
   1142 Code contributions:
   1143 - [[https://github.com/oantolin/][Omar Antolín Camarena]]
   1144 - [[https://github.com/s-kostyaev/][Sergey Kostyaev]]
   1145 - [[https://github.com/okamsn/][Earl Hyatt]]
   1146 - [[https://github.com/clemera/][Clemens Radermacher]]
   1147 - [[https://github.com/tomfitzhenry/][Tom Fitzhenry]]
   1148 - [[https://github.com/jakanakaevangeli][jakanakaevangeli]]
   1149 - [[https://hg.serna.eu][Iñigo Serna]]
   1150 - [[https://github.com/aspiers/][Adam Spiers]]
   1151 - [[https://github.com/omar-polo][Omar Polo]]
   1152 - [[https://github.com/astoff][Augusto Stoffel]]
   1153 - [[https://github.com/noctuid][Fox Kiester]]
   1154 - [[https://github.com/tecosaur][Tecosaur]]
   1155 - [[https://github.com/mohamed-abdelnour][Mohamed Abdelnour]]
   1156 - [[https://github.com/thisirs][Sylvain Rousseau]]
   1157 - [[https://github.com/jdtsmith][J.D. Smith]]
   1158 - [[https://github.com/mohkale][Mohsin Kaleem]]
   1159 - [[https://github.com/jyp][Jean-Philippe Bernardy]]
   1160 - [[https://github.com/aagon][Aymeric Agon-Rambosson]]
   1161 - [[https://github.com/geolessel][Geoffrey Lessel]]
   1162 - [[https://github.com/piotrkwiecinski][Piotr Kwiecinski]]
   1163 
   1164 Advice and useful discussions:
   1165 - [[https://github.com/clemera/][Clemens Radermacher]]
   1166 - [[https://github.com/oantolin/][Omar Antolín Camarena]]
   1167 - [[https://protesilaos.com][Protesilaos Stavrou]]
   1168 - [[https://github.com/purcell/][Steve Purcell]]
   1169 - [[https://github.com/alphapapa/][Adam Porter]]
   1170 - [[https://github.com/manuel-uberti/][Manuel Uberti]]
   1171 - [[https://github.com/tomfitzhenry/][Tom Fitzhenry]]
   1172 - [[https://github.com/hmelman/][Howard Melman]]
   1173 - [[https://github.com/monnier/][Stefan Monnier]]
   1174 - [[https://github.com/dgutov/][Dmitry Gutov]]
   1175 - [[https://github.com/iyefrat][Itai Y. Efrat]]
   1176 - [[https://github.com/bdarcus][Bruce d'Arcus]]
   1177 - [[https://github.com/jdtsmith][J.D. Smith]]
   1178 - [[https://github.com/Qkessler][Enrique Kessler Martínez]]
   1179 - [[https://github.com/raxod502][Radon Rosborough]]
   1180 
   1181 Authors of supplementary =consult-*= packages:
   1182 
   1183 - [[https://codeberg.org/jao/][Jose A Ortega Ruiz]] ([[https://codeberg.org/jao/consult-notmuch][consult-notmuch]], [[https://codeberg.org/jao/consult-recoll][consult-recoll]], [[https://codeberg.org/jao/espotify][consult-spotify]])
   1184 - [[https://github.com/gagbo/][Gerry Agbobada]] ([[https://github.com/gagbo/consult-lsp][consult-lsp]])
   1185 - [[https://github.com/karthink][Karthik Chikmagalur]] ([[https://github.com/karthink/consult-dir][consult-dir]])
   1186 - [[https://github.com/mohkale][Mohsin Kaleem]] ([[https://github.com/mohkale/consult-company][consult-company]], [[https://github.com/mohkale/consult-eglot][consult-eglot]], [[https://github.com/mohkale/consult-yasnippet][consult-yasnippet]])
   1187 - [[https://gitlab.com/OlMon][Marco Pawłowski]] ([[https://gitlab.com/OlMon/consult-flyspell][consult-flyspell]], [[https://gitlab.com/OlMon/consult-projectile][consult-projectile]])
   1188 - [[https://github.com/Qkessler][Enrique Kessler Martínez]] ([[https://github.com/Qkessler/consult-project-extra][consult-project-extra]])
   1189 - [[https://github.com/jgru][Jan Gru]] ([[https://github.com/jgru/consult-org-roam][consult-org-roam]])
   1190 - [[https://github.com/yadex205][Kanon Kakuno]] ([[https://github.com/yadex205/consult-ag][consult-ag]])
   1191 - [[https://github.com/rcj][Robin Joy]] ([[https://github.com/rcj/consult-ls-git][consult-ls-git]])
   1192 - [[https://codeberg.org/ravi][Ravi R Kiran]] [[https://codeberg.org/ravi/consult-dash][(consult-dash]])
   1193 - [[https://github.com/mclearc][Colin McLear]] ([[https://github.com/mclear-tools/consult-notes][consult-notes]])
   1194 - [[https://github.com/Nyoho][Yukinori Kitadai]] ([[https://github.com/Nyoho/consult-hatena-bookmark][consult-hatena-bookmark]])
   1195 - [[https://github.com/ghosty141][ghosty141]] ([[https://github.com/ghosty141/consult-git-log-grep][consult-git-log-grep]])
   1196 - [[https://github.com/youngker][YoungJoo Lee]] ([[https://github.com/youngker/consult-codesearch.el][consult-codesearch]])
   1197 
   1198 #+html: <!--
   1199 
   1200 * Indices
   1201 :properties:
   1202 :description: Indices of concepts and functions
   1203 :end:
   1204 
   1205 ** Function index
   1206 :properties:
   1207 :description: List of all Consult commands
   1208 :index:    fn
   1209 :end:
   1210 
   1211 ** Concept index
   1212 :properties:
   1213 :description: List of all Consult-specific concepts
   1214 :index:    cp
   1215 :end:
   1216 
   1217 #+html: -->