diff options
| -rw-r--r-- | custom/jao-custom-notmuch.el | 122 | ||||
| -rw-r--r-- | init.el | 1 |
2 files changed, 62 insertions, 61 deletions
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index 3e68215..8b985d7 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -44,6 +44,10 @@ (jao-when-darwin (jao-notmuch-xbar)) (jao-minibuffer-refresh))) +(defun jao-notmuch-notify-and-update () + (jao-notmuch-notify) + (with-current-buffer "*notmuch-hello*" (notmuch-refresh-this-buffer))) + (when jao-notmuch-enabled (jao-minibuffer-add-variable 'jao-notmuch-minibuffer-string -20)) @@ -51,20 +55,17 @@ (defvar jao-notmuch--new "tag:\"/^(unread|new)$/\"") (defvar jao-notmuch--newa (concat jao-notmuch--new " AND ")) -(defun jao-notmuch--q (d0 d1 &optional k qs st) +(defun jao-notmuch--q (d0 &optional k d1 qs st) (let ((q (or (when qs (mapconcat #'identity qs " AND ")) - (concat jao-notmuch--newa - (mapconcat (lambda (d) (when d (concat "tag:" d))) - (list d0 d1) " AND "))))) + (concat jao-notmuch--new + (mapconcat (lambda (d) (when d (concat " AND tag:" d))) + (list d0 d1)))))) (list :name (concat d0 (when (and d1 (not (string= "" d1))) "/") d1) :key k :query q :search-type (or st 'tree) :sort-order 'oldest-first))) -(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--sq (tag &optional k d0 d1) - (jao-notmuch--qn (or d0 "feeds") (or d1 tag) k (list (concat "tag:" tag)))) +(defun jao-notmuch--q-feed (q) + (apply #'jao-notmuch--q (cons "feeds" q))) (defun jao-notmuch-tree-widen-search () (interactive) @@ -94,7 +95,7 @@ (notmuch-hello-insert-buttons searches)))) (defun jao-notmuch--replace (lst s) - (let ((n (plist-get s :name))) + (let ((name (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))) @@ -108,7 +109,8 @@ (declare (indent 1)) (let ((name (and name (format "%s" name))) (id (intern (format "jao-notmuch-%s-searches" (or name (gensym)))))) - `(progn (defvar ,id ,searches) + `(progn (defvar ,id nil) + (setq ,id ,searches) (defun ,id () (jao-notmuch-hello--insert-searches ,id ,name)) ,@(unless no-save `((jao-notmuch-add-saved-searches ,id))) (add-to-list 'notmuch-hello-sections ',id t)))) @@ -118,75 +120,64 @@ (setq notmuch-hello-sections nil notmuch-saved-searches nil) (jao-notmuch-def-searches inbox - `(,(jao-notmuch--q "jao" "inbox" "ji") - ,(jao-notmuch--qn "jao" "bills" "jb" '("tag:bills")) - ,(jao-notmuch--qn "jao" "write" "jw" '("tag:write")) - ,(jao-notmuch--q "jao" "drivel" "jd") - ,(jao-notmuch--q "jao" "mdk" "jm") - ,(jao-notmuch--qn "jao" "hacking" "jh" - '("tag:hacking" "not tag:\"/emacs/\"")) - ,(jao-notmuch--qn "jao" "local" "jl" '("tag:local")))) + `(,(jao-notmuch--q "inbox" "i") + ,(jao-notmuch--q "write" "w") + ,(jao-notmuch--q "drivel" "d") + ,(jao-notmuch--q "hacking" "h") + ,(jao-notmuch--q "local" "x"))) (jao-notmuch-def-searches news - (mapcar #'jao-notmuch--sq - '("news" "noticias" "fun" "words" "computers" "pens"))) + (mapcar 'jao-notmuch--q-feed + '(("fn" "news") + ("fd" "noticias") + ("ff" "fun") + ("fw" "words") + ("fc" "computers") + ("fp" "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 - '("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-help" "eh" "emacs" "help") - ,(jao-notmuch--sq "emacs-github" "eg" "emacs" "github") - ,(jao-notmuch--sq "emacs-devel" "ed" "emacs" "devel") - ,(jao-notmuch--sq "emacs-bugs" "eb" "emacs" "bugs") - ,(jao-notmuch--sq "emacs-diffs" "ec" "emacs" "diffs"))) + `(,(jao-notmuch--q "hacking" "h") + ,(jao-notmuch--q "prog" "p") + ,(jao-notmuch--q "lists" "lr" "rust") + ,(jao-notmuch--q "lists" "lx" "xmobar") + ,(jao-notmuch--q "lists" "lg" "geiser") + ,(jao-notmuch--q "lists" "ln" "notmuch") + ,(jao-notmuch--q "lists" "ls" "scheme") + ,(jao-notmuch--q "lists" "lh" "haskell"))) (jao-notmuch-def-searches sci - (mapcar #'jao-notmuch--sq - '("philosophy" "math" "physics" "sci" "gr-qc" "quant-ph"))) + (mapcar 'jao-notmuch--q-feed + '(("sp" "philosophy") + ("sm" "math") + ("sp" "physics") + ("ss" "sci") + ("sg" "gr-qc") + ("sq" "quant-ph")))) (jao-notmuch-def-searches flags (jao-notmuch-widen-searches notmuch-saved-searches " AND tag:flagged") t) (jao-notmuch-def-searches nil - `(,(jao-notmuch--q "bml" "flagged" "rb" '("tag:flagged" "tag:bigml")) - ,(jao-notmuch--q "jao" "flagged" "rj" '("tag:flagged" "tag:jao")) - ,(jao-notmuch--q "feeds" "flagged" "rf" '("tag:flagged" "tag:feeds")))) + `(,(jao-notmuch--q "jao" "F" "flagged" '("tag:flagged" "tag:jao")))) (jao-notmuch-def-searches today - `(,(jao-notmuch--q "new" nil "nn" '("tag:new" "not tag:draft")) - ,(jao-notmuch--q "jao" "drafts" "d" '("tag:draft")) - ,(jao-notmuch--q "bml" "sent" "ts" - '("tag:bigml" "date:1d.." "tag:sent")) - ,(jao-notmuch--q "jao" "sent" "tS" - '("tag:\"/jao|hacking/\"" "date:1d.." "tag:sent")) - ,(jao-notmuch--q "bml" "today" "tb" - '("not tag:sent" "tag:bigml" "date:24h..")) - ,(jao-notmuch--q "jao" "today" "tj" + `(,(jao-notmuch--q "new" "N" nil '("tag:new" "not tag:draft")) + ,(jao-notmuch--q "jao" "D" "drafts" '("tag:draft")) + ,(jao-notmuch--q "jao" "S" "sent" '("date:1d.." "tag:sent")) + ,(jao-notmuch--q "jao" "T" "today" '("tag:jao" "date:24h.." "not tag:\"/(sent|feeds|spam|local)/\"")))) (jao-notmuch-def-searches trove - (mapcar (lambda (m) (list :query (concat "tag:trove and tag:" m) - :name (concat "trove/" m) - :key (concat "t" (substring m 0 1)) - :search-type 'tree)) - '("jao" "hacking" "feeds" "bills"))) + '((:query "tag:trove" :name "jao/trove" :search-type tree) + (:query "tag:hacking" :name "jao/hacking" :search-type tree) + (:query "not tag:trove and not tag:hacking" :name "untroved" + :search-type tree) + (:query "tag:sent" :name "jao/sent" :search-type tree))) (jao-notmuch-def-searches nil - '((:query "not tag:trove and not tag:hacking" :name "jao/untroved" - :search-type tree) - (:query "tag:sent" :name "jao/sent" :search-type tree) - (:query "*" :name "messages" :search-type tree))) + '((:query "*" :name "messages" :search-type tree))) (defun jao-notmuch-jump-search (&optional widen) (interactive "P") @@ -194,6 +185,13 @@ (if widen jao-notmuch-widened-searches notmuch-saved-searches))) (notmuch-jump-search))) +(defun jao-notmuch-jump () + "Jump to a saved, non-zero count search." + (interactive) + (let ((notmuch-saved-searches + (notmuch-hello-query-counts notmuch-saved-searches))) + (notmuch-jump-search))) + ;;; tags (defvar jao-notmuch--shared-tags '("new" "unread" "flagged" "signed" "sent" "attachment" "forwarded" "inbox" @@ -497,7 +495,9 @@ (defun jao-notmuch-after-tree-quit (&optional _both) (when (not (derived-mode-p 'notmuch-tree-mode 'notmuch-hello-mode)) - (jump-to-register ?G)) + (jump-to-register ?G) + (when (not (derived-mode-p 'notmuch-hello-mode)) + (jao-notmuch-notify-and-update))) (jao-notmuch-refresh-hello (= 0 (mod (cl-incf jao-notmuch--visits) 5)))) (defun jao-notmuch-tree--sentinel (proc) @@ -1857,6 +1857,7 @@ ["Network" ("s" "ssh" jao-ssh) ("r" "r2e" jao-r2e) + ("j" "notmuch jump" jao-notmuch-jump) ("S" "sieve" jao-sieve-manage)] ["Utilities" ("m" "mpc" jao-transient-media) |
