From 211ecc643cdca54f3f9f403e4c8961108ddac0e9 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 21 May 2021 02:32:25 +0100 Subject: narrowing frenzy (chat buffers) --- completion.org | 25 +++++++++++++++++++++++++ eww.org | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/completion.org b/completion.org index 741bb26..04d09dc 100644 --- a/completion.org +++ b/completion.org @@ -185,11 +185,36 @@ (add-hook 'minibuffer-setup-hook #'jao-consult-initial-narrow) + (defmacro jao-consult--mode-buffers (&rest modes) + `(lambda () + (seq-map #'buffer-name + (seq-filter (lambda (b) + (with-current-buffer b + (derived-mode-p ,@modes))) + (buffer-list))))) + (defun jao-consult-add-buffer-source (src &optional aframe key) (add-to-list 'consult-buffer-sources src t) (when (and aframe key) (add-to-list 'jao-consult-narrow (cons aframe key)))) #+end_src +*** narrowing chats + #+begin_src emacs-lisp + (defvar jao-chat-buffer-source + (list :name "chats" + :category 'buffer + :action #'pop-to-buffer + :hidden t + :narrow (cons ?c "chats") + :items (jao-consult--mode-buffers 'erc-mode + 'signel-chat-mode + 'slack-message-buffer-mode + 'slack-thread-message-buffer-mode + 'telega-root-mode + 'telega-chat-mode))) + (jao-consult-add-buffer-source 'jao-chat-buffer-source) + #+end_src + * embark *** packages #+begin_src emacs-lisp diff --git a/eww.org b/eww.org index 0dd04bb..3801215 100644 --- a/eww.org +++ b/eww.org @@ -78,7 +78,7 @@ (eq 'eww-mode (buffer-local-value 'major-mode b))) (buffer-list)))))) - (jao-consult-add-buffer-source jao-eww-buffer-source "Web" ?e)) + (jao-consult-add-buffer-source 'jao-eww-buffer-source "Web" ?e)) #+end_src * Images #+begin_src emacs-lisp -- cgit v1.2.3