Skip to content

ERC buffer source and narrowing #290

@grolongo

Description

@grolongo

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))))
    ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions