ERC buffer source and narrowing · Issue #290 · minad/consult (original) (raw)

Hi,

Following the model used for Org files narrowing that I found in the wiki, maybe you could add this one that I'm using for ERC buffers:

(defvar erc-buffer-source `(:name "ERC" :hidden t :narrow ?e :category buffer :state ,#'consult--buffer-state :items ,(lambda () (mapcar #'buffer-name (erc-buffer-list)))))

(autoload 'erc-buffer-list "erc") (add-to-list 'consult-buffer-sources 'erc-buffer-source 'append)

Now, is it possible to use narrowing only under some conditions? For eg, I tried to have initial narrowing when I'm under a buffer whose major-mode is erc-mode and keep the default (no narrowing) on other buffers. I also tried it with tabs name. My tests didn't work though (most probably because my elisp is so bad).

(defvar consult-initial-narrow-config (if (eq major-mode 'erc-mode) '((consult-buffer . ?e)) '((consult-buffer))))

and with tab-bar-mode I used this instead of (eq major-mode 'erc-mode)

(defvar consult-initial-narrow-config (when (string-equal "ERC" (alist-get 'name (alist-get 'current-tab (tab-bar-tabs)))) ...)