Function: consult-history
consult-history is an autoloaded, interactive and byte-compiled
function defined in consult.el.
Signature
(consult-history &optional HISTORY INDEX BOL)
Documentation
Insert string from HISTORY of current buffer.
In order to select from a specific HISTORY, pass the history
variable as argument. INDEX is the name of the index variable to
update, if any. BOL is the function which jumps to the beginning
of the prompt. See also cape-history from the Cape package.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
;;;###autoload
(defun consult-history (&optional history index bol)
"Insert string from HISTORY of current buffer.
In order to select from a specific HISTORY, pass the history
variable as argument. INDEX is the name of the index variable to
update, if any. BOL is the function which jumps to the beginning
of the prompt. See also `cape-history' from the Cape package."
(interactive)
(declare-function ring-elements "ring")
(pcase-let* ((`(,history ,index ,bol) (if history
(list history index bol)
(consult--current-history)))
(history (if (ring-p history) (ring-elements history) history))
(`(,beg . ,end)
(if (minibufferp)
(cons (minibuffer-prompt-end) (point-max))
(if bol
(save-excursion
(funcall bol)
(cons (point) (pos-eol)))
(cons (point) (point)))))
(str (consult--local-let ((enable-recursive-minibuffers t))
(consult--read
(or (consult--remove-dups history)
(user-error "History is empty"))
:prompt "History: "
:history t ;; disable history
:category ;; Report category depending on history variable
(and (minibufferp)
(pcase minibuffer-history-variable
('extended-command-history 'command)
('buffer-name-history 'buffer)
('face-name-history 'face)
('read-envvar-name-history 'environment-variable)
('bookmark-history 'bookmark)
('file-name-history 'file)))
:sort nil
:initial (buffer-substring-no-properties beg end)
:lookup #'consult--lookup-member
:state (consult--insertion-preview beg end)))))
(delete-region beg end)
(when index
(set index (seq-position history str)))
(insert (substring-no-properties str))))