summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2025-11-05 18:23:28 +0000
committerjao <jao@gnu.org>2025-11-05 18:23:28 +0000
commitb393aafc3201d9ada1ddab941ee8001fa6108d15 (patch)
tree93ebbaaf54c5ec7bb49707daf1e68cf1f064b0bb /custom
parent144e63edbe007c4fac3918a67e6cf0d957fa832b (diff)
downloadelibs-b393aafc3201d9ada1ddab941ee8001fa6108d15.tar.gz
elibs-b393aafc3201d9ada1ddab941ee8001fa6108d15.tar.bz2
notmuch: idempotent hello and saved queries
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-notmuch.el51
1 files changed, 26 insertions, 25 deletions
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el
index 383fe85..68a7d99 100644
--- a/custom/jao-custom-notmuch.el
+++ b/custom/jao-custom-notmuch.el
@@ -73,12 +73,13 @@
(notmuch-tree-close-message-window)
(notmuch-tree (string-replace jao-notmuch--newa "" query)))))
+(defun jao-notmuch--widen (s &optional extra)
+ (let* ((q (plist-get s :query))
+ (qs (string-replace jao-notmuch--newa "" q)))
+ (plist-put (copy-sequence s) :query (concat qs extra))))
+
(defun jao-notmuch-widen-searches (searches &optional extra)
- (mapcar (lambda (s)
- (let* ((q (plist-get s :query))
- (qs (string-replace jao-notmuch--newa "" q)))
- (plist-put (copy-sequence s) :query (concat qs extra))))
- searches))
+ (mapcar (lambda (s) (jao-notmuch--widen s extra)) searches))
(defun jao-notmuch-hello--insert-searches (searches title)
(when-let (searches (notmuch-hello-query-counts searches))
@@ -92,26 +93,29 @@
(widget-insert (propertize title 'face 'jao-themes-f00))
(notmuch-hello-insert-buttons searches))))
+(defun jao-notmuch--replace (lst s)
+ (let ((n (plist-get s :name)))
+ (set lst (seq-remove (lambda (s0) (string= name (plist-get s0 :name)))
+ (symbol-value lst)))
+ (add-to-list lst s t)))
+
+(defun jao-notmuch-add-saved-searches (searches)
+ (dolist (s searches)
+ (jao-notmuch--replace 'notmuch-saved-searches s)
+ (jao-notmuch--replace 'jao-notmuch-widened-searches s)))
+
(defmacro jao-notmuch-def-searches (name searches &optional no-save)
(declare (indent 1))
(let ((name (and name (format "%s" name)))
(id (intern (format "jao-notmuch-%s-searches" (or name (gensym))))))
`(progn (defvar ,id ,searches)
(defun ,id () (jao-notmuch-hello--insert-searches ,id ,name))
- ,@(unless no-save
- `((setq notmuch-saved-searches
- (append notmuch-saved-searches ,id))))
+ ,@(unless no-save `((jao-notmuch-add-saved-searches ,id)))
(add-to-list 'notmuch-hello-sections ',id t))))
-(setq notmuch-hello-sections nil notmuch-saved-searches nil)
+(defvar jao-notmuch-widened-searches nil)
-;; (jao-notmuch-def-searches bigml
-;; `(,(jao-notmuch--q "bigml" "inbox" "bi")
-;; ,(jao-notmuch--q "bigml" "alba" "ba")
-;; ,(jao-notmuch--q "bigml" "support" "bs")
-;; ,(jao-notmuch--q "bigml" "bugs" "bb")
-;; ,(jao-notmuch--q "bigml" "drivel" "bd")
-;; ,(jao-notmuch--q "bigml" "lists" "bl")))
+(setq notmuch-hello-sections nil notmuch-saved-searches nil)
(jao-notmuch-def-searches inbox
`(,(jao-notmuch--q "jao" "inbox" "ji")
@@ -124,20 +128,21 @@
,(jao-notmuch--qn "jao" "local" "jl" '("tag:local"))))
(jao-notmuch-def-searches news
- (mapcar #'jao-notmuch--sq '("news" "noticias" "fun" "words" "computers")))
+ (mapcar #'jao-notmuch--sq
+ '("news" "noticias" "fun" "words" "computers" "pens")))
(jao-notmuch-def-searches hacking
(mapcar #'jao-notmuch--sq '("xmobar" "geiser" "mdk" "mailutils" "notmuch")))
(jao-notmuch-def-searches prog
(append (mapcar #'jao-notmuch--sq
- '("lobsters" "clojure" "lisp" "scheme"
+ '("emacs" "lobsters" "clojure" "lisp" "scheme"
"haskell" "idris" "erlang" "pharo" "rust"))
`(,(jao-notmuch--qn "feeds" "prog" "fp"
'("tag:prog" "not tag:\"/emacs/\"")))))
(jao-notmuch-def-searches emacs
- `(,(jao-notmuch--sq "emacs" "ee" "emacs" "feeds")
+ `(;; ,(jao-notmuch--sq "emacs" "ee" "emacs" "feeds")
,(jao-notmuch--sq "emacs-help" "eh" "emacs" "help")
,(jao-notmuch--sq "emacs-github" "eg" "emacs" "github")
,(jao-notmuch--sq "emacs-devel" "ed" "emacs" "devel")
@@ -178,15 +183,11 @@
'("jao" "hacking" "feeds" "bills")))
(jao-notmuch-def-searches nil
- '((:query "not tag:trove and not tag:bigml" :name "jao/untroved"
+ '((:query "not tag:trove and not tag:hacking" :name "jao/untroved"
:search-type tree)
- (:query "tag:sent and tag:bigml" :name "bigml/sent" :search-type tree)
- (:query "tag:sent and not tag:bigml" :name "jao/sent" :search-type tree)
+ (:query "tag:sent" :name "jao/sent" :search-type tree)
(:query "*" :name "messages" :search-type tree)))
-(defvar jao-notmuch-widened-searches
- (jao-notmuch-widen-searches notmuch-saved-searches))
-
(defun jao-notmuch-jump-search (&optional widen)
(interactive "P")
(let ((notmuch-saved-searches