From 472495bfba28cc371ecaf567bc856d9a3aa04b92 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 25 Feb 2022 17:12:24 +0000 Subject: notmuch searches oblivious of folders --- notmuch.org | 133 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 65 deletions(-) (limited to 'notmuch.org') diff --git a/notmuch.org b/notmuch.org index 82e3710..125db3d 100644 --- a/notmuch.org +++ b/notmuch.org @@ -58,64 +58,59 @@ (defun jao-notmuch--qn (d0 d1 k qs &optional st) (jao-notmuch--q d0 d1 k (cons jao-notmuch--new qs) st)) - (defun jao-notmuch--mboxes-search (box &rest excluded) - (let ((ms (seq-difference (jao-list-mailboxes box) excluded)) - (bp (substring box 0 1))) - (mapcar (lambda (m) (jao-notmuch--q box (car m) (concat bp (cdr m)))) - (shorten-strings (sort ms #'string<))))) - - (defun jao-notmuch--sec (q) (append q '(:secondary t))) - (defun jao-notmuch--sq (tag &optional k d0 d1) - (jao-notmuch--sec (jao-notmuch--qn (or d0 "feeds") (or d1 tag) k - (list (concat "tag:" tag))))) + (jao-notmuch--qn (or d0 "feeds") (or d1 tag) k (list (concat "tag:" tag)))) - (defun jao-notmuch--feed-tags (w) - (let* ((cmd (concat "notmuch search --output=tags tag:" w)) - (ts (split-string (shell-command-to-string cmd)))) - (seq-difference ts '("new" "unread" "flagged" "signed" "attachment" - "gmane" "feeds" "rss" "mce" "trove" "prog" "emacs")))) - - (defvar jao-notmuch--feed-tags - '("news" - "fun" - "words" - "computers" - "mailutils" - "notmuch" - "lobsters" - "clojure" - "haskell" - "idris" - "pharo" - "lisp" - "scheme" - "xmobar" - "geiser" - "philosophy" - "math" - "physics" - "sci" - "gr-qc" - "quant-ph")) + (defvar jao-notmuch--shared-tags + '("new" "unread" "flagged" "signed" "sent" "attachment" "forwarded" + "encrypted" "gmane" "feeds" "rss" "mce" "trove" "prog" "emacs")) - (setq notmuch-saved-searches - `(,(jao-notmuch--q "bigml" "inbox" "bi") - ,(jao-notmuch--q "bigml" "support" "bs") - ,(jao-notmuch--q "bigml" "bugs" "bb") - ,@(jao-notmuch--mboxes-search "bigml" "inbox" "support") - ,@(jao-notmuch--mboxes-search "jao" "drafts") - ,(jao-notmuch--q "jao" "mdk" "jm") - ,(jao-notmuch--sq "local" "l" "local" "") - ,@(mapcar #'jao-notmuch--sq jao-notmuch--feed-tags) - ,(jao-notmuch--sec - (jao-notmuch--qn "feeds" "prog" "fp" - (cons "tag:prog" - (mapcar (lambda (tag) - (format "not tag:%s" tag)) - `("emacs" - "emacs-orgmode" - ,@jao-notmuch--feed-tags))))))) + (defun jao-notmuch--subtags (tag &rest excl) + (let* ((cmd (concat "notmuch search --output=tags tag:" tag)) + (ts (split-string (shell-command-to-string cmd)))) + (seq-difference ts (append jao-notmuch--shared-tags (cons tag excl))))) + + (defvar jao-notmuch-feed-searches + (append (mapcar #'jao-notmuch--sq '("news" + "fun" + "words" + "computers" + "mailutils" + "notmuch" + "lobsters" + "clojure" + "haskell" + "idris" + "pharo" + "lisp" + "scheme" + "xmobar" + "geiser" + "philosophy" + "math" + "physics" + "sci" + "gr-qc" + "quant-ph")) + `(,(jao-notmuch--qn "feeds" "prog" "fp" + '("tag:prog" "not tag:\"/emacs/\""))))) + + (defvar jao-notmuch-bigml-searches + `(,(jao-notmuch--q "bigml" "inbox" "bi") + ,(jao-notmuch--q "bigml" "support" "bs") + ,(jao-notmuch--q "bigml" "bugs" "bb") + ,(jao-notmuch--q "bigml" "drivel" "bd") + ,(jao-notmuch--q "bigml" "lists" "bl"))) + + (defvar jao-notmuch-jao-searches + `(,(jao-notmuch--q "jao" "inbox" "ji") + ,(jao-notmuch--q "jao" "bills" "jb") + ,(jao-notmuch--q "jao" "drivel" "jd") + ,(jao-notmuch--q "jao" "mdk" "jm") + ,(jao-notmuch--q "jao" "local" "l"))) + + (defvar jao-notmuch-inbox-searches + (append jao-notmuch-bigml-searches jao-notmuch-jao-searches)) (defvar jao-notmuch-emacs-searches `(,(jao-notmuch--sq "emacs" "ee" "emacs" "feeds") @@ -125,6 +120,12 @@ ,(jao-notmuch--sq "emacs-diffs" "ec" "emacs" "diffs") ,(jao-notmuch--sq "emacs-orgmode" "eo" "emacs" "org"))) + (setq notmuch-saved-searches + (append jao-notmuch-bigml-searches + jao-notmuch-jao-searches + jao-notmuch-feed-searches + jao-notmuch-emacs-searches)) + (defvar jao-notmuch-dynamic-searches `(,(jao-notmuch--q "jao" "draft" "d" '("tag:draft")) ,(jao-notmuch--q "bml" "today" "tb" '("tag:bigml" "date:24h..")) @@ -241,15 +242,17 @@ (notmuch-hello-insert-buttons searches)) (indent-rigidly start (point) notmuch-hello-indent)))) - (defun jao-notmuch-hello-insert-primary-searches () - (jao-notmuch-hello--insert-searches - (seq-remove (lambda (q) (plist-get q :secondary)) notmuch-saved-searches) - "inbox")) + (defun jao-notmuch-hello-insert-bigml-searches () + (jao-notmuch-hello--insert-searches jao-notmuch-bigml-searches "work")) + + (defun jao-notmuch-hello-insert-jao-searches () + (jao-notmuch-hello--insert-searches jao-notmuch-jao-searches "jao")) + + (defun jao-notmuch-hello-insert-inbox-searches () + (jao-notmuch-hello--insert-searches jao-notmuch-inbox-searches "inbox")) - (defun jao-notmuch-hello-insert-secondary-searches () - (jao-notmuch-hello--insert-searches - (seq-filter (lambda (q) (plist-get q :secondary)) notmuch-saved-searches) - "feeds")) + (defun jao-notmuch-hello-insert-feeds-searches () + (jao-notmuch-hello--insert-searches jao-notmuch-feed-searches "feeds")) (defun jao-notmuch-hello-insert-emacs-searches () (jao-notmuch-hello--insert-searches jao-notmuch-emacs-searches "emacs")) @@ -306,8 +309,8 @@ (use-package notmuch-hello :init (setq notmuch-column-control t - notmuch-hello-sections '(jao-notmuch-hello-insert-primary-searches - jao-notmuch-hello-insert-secondary-searches + notmuch-hello-sections '(jao-notmuch-hello-insert-inbox-searches + jao-notmuch-hello-insert-feeds-searches jao-notmuch-hello-insert-emacs-searches jao-notmuch-hello-insert-dynamic-searches notmuch-hello-insert-alltags -- cgit v1.2.3