dotemacs

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

README.org (58484B)


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