From 50d28f2ec1274feb43a5bc6dfb84ebbf140b619b Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 11 Jun 2021 19:44:35 +0100 Subject: email tagging tweaks --- email.org | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'email.org') diff --git a/email.org b/email.org index d641ede..8b86842 100644 --- a/email.org +++ b/email.org @@ -359,7 +359,9 @@ (defun jao-notmuch--q (d0 d1 &optional k qs st) (let ((q (or (when qs (mapconcat #'identity qs " AND ")) - (format "folder:%s/%s and tag:\"/^(unread|new)$/\"" d0 d1)))) + (concat "tag:\"/^(unread|new)$/\" AND " + (mapconcat (lambda (d) (when d (concat "tag:" d))) + (list d0 d1) " AND "))))) (list :name (concat d0 (when d1 "/") d1) :key k :query q :search-type (or st 'tree) :sort-order 'oldest-first))) @@ -367,20 +369,17 @@ (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)))) + (mapcar (lambda (m) (jao-notmuch--q box (car m) (concat bp (cdr m)))) (shorten-strings (sort ms #'string<))))) (setq notmuch-saved-searches - `(,(jao-notmuch--q "bigml/inbox" nil "bi" - '("tag:new" "tag:bigml" "tag:inbox")) - ,(jao-notmuch--q "bigml/support" nil "bs" - '("tag:new" "tag:support")) + `(,(jao-notmuch--q "bigml" "inbox" "bi") + ,(jao-notmuch--q "bigml" "support" "bs") + ,(jao-notmuch--q "bigml" "bug" "bb") ,@(jao-notmuch--mboxes-search "bigml" "inbox" "support") ,@(jao-notmuch--mboxes-search "jao") ,@(jao-notmuch--mboxes-search "feeds") - ,(jao-notmuch--q "gmane/emacs" nil "e" - '("tag:gmane" "tag:new" "tag:emacs")) + ,(jao-notmuch--q "gmane" "emacs" "e") ,(jao-notmuch--q "gmane" nil "g" '("tag:gmane" "tag:new" "not tag:emacs")) ,(jao-notmuch--q "bml/today" nil "tb" '("tag:bigml" "date:1d..") t) @@ -391,8 +390,9 @@ #+end_src *** package #+begin_src emacs-lisp - (when (< emacs-major-version 28) - (jao-load-path "notmuch")) + (if (< emacs-major-version 28) + (jao-load-path "notmuch") + (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/")) (use-package notmuch ;; :ensure t @@ -700,11 +700,9 @@ #+end_src *** consult #+begin_src emacs-lisp - (when (< emacs-major-version 28) - (jao-load-path "consult-notmuch")) + (jao-load-path "consult-notmuch") (use-package consult-notmuch - ;; :ensure t :init (setq consult-notmuch-authors-width 30) :config (consult-customize consult-notmuch :preview-key 'any)) @@ -786,7 +784,7 @@ } function tag_list () { - notmuch tag "+$1" -- tag:new AND List:${2:-$1} + notmuch tag "+$1" $3 -- tag:new AND List:${2:-$1} } tag_directory bigml @@ -810,8 +808,9 @@ tag_list scheme $l done - tag_list emacs-bugs bug-gnu-emacs - tag_list mailutils bug-mailutils + tag_list emacs-bugs bug-gnu-emacs -lists + tag_list mailutils bug-mailutils -lists + tag_list feeds Lobsters +programming -lists #+end_src *** expiry shell script #+begin_src bash :shebang "#!/bin/bash" :tangle ./bin/notmuch-expire.sh :tangle-mode (identity #o755) @@ -822,17 +821,12 @@ notmuch tag +deleted -- "$1 AND date:..${2:-3d} AND NOT $spared_tags" } - function tag_deleted_foldr { - tag_deleted "folder:\"/$1/\"" $2 - } - - tag_deleted_foldr "bigml.(drivel|lists|deploys|bugs)" 3d - tag_deleted_foldr "bigml.reports" 1d - tag_deleted_foldr "jao.(drivel|lists|books|think|local)" 3d + tag_deleted "tag:bigml and tag:\"/^(drivel|lists|deploys|bugs)$/\"" 3d + tag_deleted "tag:bigml and tag:reports" 1d + tag_deleted "tag:bigml AND tag:support" 7d + tag_deleted "tag:jao and tag:\"/^(drivel|lists|books|think|local)$/\"" 3d tag_deleted "tag:feeds" 3d - tag_deleted "tag:support AND tag:bigml" 7d - notmuch new > $HOME/var/log/notmuch-expire.log 2>&1 notmuch compact >> $HOME/var/log/notmuch-expire.log 2>&1 #+end_src @@ -840,6 +834,6 @@ #+begin_src bash :shebang "#!/bin/bash" :tangle ./bin/notmuch-delete.sh :tangle-mode (identity #o755) notmuch search --output=files --format=text0 tag:deleted | xargs -r0 rm - notmuch new > $HOME/var/log/notmuch-expire.log 2>&1 - notmuch compact >> $HOME/var/log/notmuch-expire.log 2>&1 + notmuch new > $HOME/var/log/notmuch-delete.log 2>&1 + notmuch compact >> $HOME/var/log/notmuch-delete.log 2>&1 #+end_src -- cgit v1.2.3