Skip to content

Automatically narrow consult buffer for certain major-modes #1072

Closed Answered by johnhamelink
johnhamelink asked this question in Q&A
Discussion options

You must be logged in to vote

With a little bit of help from others on Mastodon, I was able to come up with this:

(defvar consult-initial-narrow-per-mode-config
    '((rcirc-mode . ((consult-buffer . ?c)))))

(defun consult-initial-narrow ()
    "Narrow consult buffers differently for different major modes.

Allows consult to have initial narrowing for configurable buffer types
and consult command types, contained in
`consult-initial-narrow-per-mode-config'."
    (when minibuffer--original-buffer
    (when-let* ((original-mode (with-current-buffer minibuffer--original-buffer major-mode))
                (mode-config (alist-get original-mode consult-initial-narrow-per-mode-config))
                (command-prefix (alis…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by johnhamelink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant