(defun ft-get-erc-buffers-of-mode (mode)
"Return list of buffer where major-mode is MODE"
(let ((result))
(dolist (item (buffer-list))
(with-current-buffer item
(when (string= major-mode mode)
(push (buffer-name item) result))))
result))
(defvar consult--source-erc-buffers
`(:name "IRC"
:narrow ?i
:category buffer
:face consult-buffer
:action ,#'consult--buffer-action
:state ,#'consult--buffer-state
:history buffer-name-history
:items ,(lambda () (ft-get-erc-buffers-of-mode "erc-mode")))
"consult source for IRC buffers")
(add-to-list 'consult-buffer-sources 'consult--source-erc-buffers 'append)