Function: consult-focus-lines

consult-focus-lines is an autoloaded, interactive and byte-compiled function defined in consult.el.

Signature

(consult-focus-lines FILTER &optional SHOW INITIAL)

Documentation

Show only matching lines using overlays.

In contrast to consult-keep-lines the buffer is not modified. The FILTER selects the lines which are shown. When called interactively, the lines selected are those that match the minibuffer input. In order to match the inverse of the input, prefix the input with ! . With optional prefix argument SHOW reveal the hidden lines. Alternatively rerun the command and exit the minibuffer directly without input to reveal the lines. When called from Elisp, the filtering is performed by a FILTER function. If the buffer is narrowed to a region, the command only acts on this region.

FILTER is the filter function, called for each line. SHOW is the prefix argument, if non-nil reveal all hidden lines. INITIAL is the initial input.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
;;;###autoload
(defun consult-focus-lines (filter &optional show initial)
  "Show only matching lines using overlays.

In contrast to `consult-keep-lines' the buffer is not modified.  The
FILTER selects the lines which are shown.  When called interactively,
the lines selected are those that match the minibuffer input.  In order
to match the inverse of the input, prefix the input with `! '.  With
optional prefix argument SHOW reveal the hidden lines.  Alternatively
rerun the command and exit the minibuffer directly without input to
reveal the lines.  When called from Elisp, the filtering is performed by
a FILTER function.  If the buffer is narrowed to a region, the command
only acts on this region.

FILTER is the filter function, called for each line.
SHOW is the prefix argument, if non-nil reveal all hidden lines.
INITIAL is the initial input."
  (interactive
   (list (lambda (pattern cands)
           ;; Use consult-location completion category when filtering lines
           (consult--completion-filter-dispatch
            pattern cands 'consult-location nil))
         current-prefix-arg))
  (if show
      (progn
        (mapc #'delete-overlay consult--focus-lines-overlays)
        (setq consult--focus-lines-overlays nil)
        (message "All lines revealed"))
    (consult--forbid-minibuffer)
    (consult--with-increased-gc
      (consult--prompt
       :prompt
       (if consult--focus-lines-overlays
           "Focus on lines (RET to reveal): "
         "Focus on lines: ")
       :initial initial
       :history 'consult--line-history
       :state (consult--focus-lines-state filter))))
  (cl-callf2 assq-delete-all 'consult--focus-lines-overlays mode-line-misc-info)
  (when (and consult--focus-lines-overlays consult--focus-lines-indicator)
    (push `(consult--focus-lines-overlays ,consult--focus-lines-indicator)
          mode-line-misc-info)))