From 63c7742de1cb4ec8d63abd6f8553367531d3847d Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 8 Jun 2021 02:52:45 +0100 Subject: generic narrowing for mail workspace --- email.org | 54 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'email.org') diff --git a/email.org b/email.org index c67a9d0..fb0a2c1 100644 --- a/email.org +++ b/email.org @@ -254,6 +254,42 @@ (seq-difference (directory-files dir) '("." ".." "sent" "inbox" "trash")))) #+end_src +* consult narrowing + #+begin_src emacs-lisp + (defvar jao-mail-consult-buffer-history nil) + + (defun jao-mail-buffer-p (b) + (or (member (buffer-name b) + '("*Calendar*" "inbox.org" "*Org Agenda*" + "*Fancy Diary Entries*" "diary")) + (with-current-buffer b + (derived-mode-p 'notmuch-show-mode + 'notmuch-search-mode + 'notmuch-tree-mode + 'notmuch-hello-mode + 'notmuch-message-mode + 'gnus-group-mode + 'gnus-summary-mode + 'gnus-article-mode)))) + + (defvar jao-mail-consult-source + (list :name "mail buffer" + :category 'buffer + :hidden t + :narrow (cons ?n "mail buffer") + :history 'jao-mail-consult-buffer-history + :action (lambda (b) + (when (not (string-blank-p (or b ""))) + (jao-afio--goto-mail) + (if (get-buffer-window b) + (pop-to-buffer b) + (pop-to-buffer-same-window b)))) + :items (lambda () + (mapcar #'buffer-name + (seq-filter #'jao-mail-buffer-p (buffer-list)))))) + + (jao-consult-add-buffer-source 'jao-mail-consult-source "Mail" ?n) + #+end_src * gnus *** Directories #+begin_src emacs-lisp @@ -622,25 +658,11 @@ #+begin_src emacs-lisp (when (< emacs-major-version 28) (jao-load-path "consult-notmuch")) + (use-package consult-notmuch ;; :ensure t :init (setq consult-notmuch-authors-width 30) - :config - (add-to-list 'consult-config '(consult-notmuch :preview-key any)) - - (defvar jao-notmuch-consult-buffer-history nil) - (defvar jao-notmuch-consult-source - (list :name "mail buffer" - :category 'buffer - :hidden t - :narrow (cons ?n "mail buffer") - :history 'jao-notmuch-consult-buffer-history - :require-match t - :action (lambda (b) (jao-afio--goto-mail) (pop-to-buffer b)) - :items (lambda () - (append (consult-notmuch--interesting-buffers) - '("*Calendar*" "inbox.org" "*Org Agenda*"))))) - (jao-consult-add-buffer-source 'jao-notmuch-consult-source "Mail" ?n)) + :config (consult-customize consult-notmuch :preview-key 'any)) (defvar jao-consult-notmuch-folders (seq-mapcat (lambda (base) -- cgit v1.2.3