summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-10-29 04:42:40 +0100
committerjao <jao@gnu.org>2021-10-29 04:42:40 +0100
commitbb250f452fae2f3030c94e9781e780da83c56784 (patch)
tree000f043d7ed334c597424b2828fd7a558f77ca08
parent12e08cd8deee703d7b0ac59f78d8322bed0b30bf (diff)
downloadelibs-bb250f452fae2f3030c94e9781e780da83c56784.tar.gz
elibs-bb250f452fae2f3030c94e9781e780da83c56784.tar.bz2
notmuch hello: sectioned saved searches
-rw-r--r--notmuch.org126
1 files changed, 77 insertions, 49 deletions
diff --git a/notmuch.org b/notmuch.org
index b5a8f26..71e31ba 100644
--- a/notmuch.org
+++ b/notmuch.org
@@ -7,22 +7,20 @@
(defvar jao-notmuch-minibuffer-queries
'((:name "" :query "tag:new" :face jao-themes-f00)
- (:name "B" :query "tag:new and tag:bigml and tag:inbox")
+ (:name "B" :query "tag:new and tag:bigml and tag:inbox" :face default)
(:name "b" :query "tag:new and tag:bigml and tag:bugs"
:face jao-themes-error)
- (:name "S" :query "tag:new and tag:bigml and tag:support")
- (:name "W" :query "tag:new and tag:bigml" :face jao-themes-dimm)
- (:name "H" :query "tag:new and tag:jao and tag:hacking" :face jao-themes-dimm)
- (:name "T" :query "tag:new and tag:jao and tag:think" :face jao-themes-dimm)
- (:name "E" :query "tag:new and tag:\"/emacs/\"" :face jao-themes-dimm)
- (:name "l" :query "tag:new and tag:local" :face jao-themes-dimm)
- (:name "J" :query
- "tag:new and tag:jao and not tag:\"/local|emacs|hacking|think/\""
- :face jao-themes-dimm)
- (:name "F" :query "tag:new and tag:feeds and not tag:\"/emacs/\""
- :face jao-themes-dimm)
- (:name "G" :query "tag:new and tag:gmane and not tag:\"/emacs|papers/\""
- :face jao-themes-dimm)))
+ (:name "S" :query "tag:new and tag:bigml and tag:support" :face default)
+ (:name "W" :query "tag:new and tag:bigml" :face default)
+ (:name "H" :query "tag:new and tag:jao and tag:hacking")
+ (:name "T" :query "tag:new and tag:think")
+ (:name "E" :query "tag:new and tag:\"/emacs/\"")
+ (:name "l" :query "tag:new and tag:local")
+ (:name "J" :query "tag:new and tag:jao and not tag:\"/local|hacking/\""
+ :face default)
+ (:name "F" :query "tag:new and tag:feeds and not tag:\"/emacs|papers/\"")
+ (:name "G" :query "tag:new and tag:gmane and not tag:\"/emacs|papers/\"")
+ (:name "P" :query "tag:new and tag:papers")))
(defun jao-notmuch-notify ()
(let ((cnts (notmuch-hello-query-counts jao-notmuch-minibuffer-queries)))
@@ -31,7 +29,8 @@
(propertize (format "%s%s"
(plist-get c :name)
(plist-get c :count))
- 'face (plist-get c :face)))
+ 'face (or (plist-get c :face)
+ 'jao-themes-dimm)))
cnts
" "))
(jao-minibuffer-refresh)))
@@ -48,7 +47,7 @@
(concat jao-notmuch--newa
(mapconcat (lambda (d) (when d (concat "tag:" d)))
(list d0 d1) " AND ")))))
- (list :name (concat d0 (when d1 "/") 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)))
@@ -61,41 +60,52 @@
(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 k &optional d0 d1)
+ (jao-notmuch--sec (jao-notmuch--qn (or d0 "feeds") (or d1 tag) k
+ (list (concat "tag:" tag)))))
+
(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--qn "local" nil "l" '("tag:local"))
- ,(jao-notmuch--qn "emacs" "feeds" "ee" '("tag:emacs"))
- ,(jao-notmuch--qn "emacs" "github" "eg" '("tag:emacs-github"))
- ,(jao-notmuch--qn "emacs" "devel" "ed" '("tag:emacs-devel"))
- ,(jao-notmuch--qn "emacs" "bugs" "eb" '("tag:emacs-bugs"))
- ,(jao-notmuch--qn "emacs" "diffs" "ec" '("tag:emacs-diffs"))
- ,(jao-notmuch--qn "feeds" "clojure" "fc" '("tag:clojure"))
- ,(jao-notmuch--qn "feeds" "elixir" "fex" '("tag:elixir"))
- ,(jao-notmuch--qn "feeds" "erlang" "fe" '("tag:erlang"))
- ,(jao-notmuch--qn "feeds" "gnus" "fg" '("tag:gnus"))
- ,(jao-notmuch--qn "feeds" "haskell" "fh" '("tag:haskell"))
- ,(jao-notmuch--qn "feeds" "idris" "fid" '("tag:idris"))
- ,(jao-notmuch--qn "feeds" "lobsters" "fl" '("tag:lobsters"))
- ,(jao-notmuch--qn "feeds" "mailutils" "fm" '("tag:mailutils"))
- ,(jao-notmuch--qn "feeds" "notmuch" "fn" '("tag:notmuch"))
- ,(jao-notmuch--qn "feeds" "papers" "fax" '("tag:papers"))
- ,(jao-notmuch--qn "feeds" "scheme" "fl" '("tag:scheme"))
- ,(jao-notmuch--qn "feeds" "xmobar" "fx" '("tag:xmobar"))
- ,(jao-notmuch--qn "feeds" "prog" "fp"
- '("tag:prog" "not tag:\"/(lobsters|clojure|xmobar|gmane)/\""))
- ,@(jao-notmuch--mboxes-search "feeds" "emacs" "prog")
- ,(jao-notmuch--q "jao" "draft" "d" '("tag:draft"))
- ,(jao-notmuch--q "bml" "today" "tb" '("tag:bigml" "date:24h.."))
- ,(jao-notmuch--q "jao" "today" "tj"
- '("tag:jao" "date:24h.."
- "not tag:\"/(feeds|spam|local)/\""))
- ,(jao-notmuch--q "bml" "flagged" "rb" '("tag:flagged" "tag:bigml"))
- ,(jao-notmuch--q "jao" "flagged" "rj" '("tag:flagged" "not tag:bigml"))
- ,(jao-notmuch--q "unread" nil "n" '("tag:unread"))))
+ ,(jao-notmuch--sq "local" "l" "local" "")
+ ,(jao-notmuch--sq "emacs" "ee" "emacs" "feeds")
+ ,(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--sq "clojure" "fc")
+ ,(jao-notmuch--sq "elixir" "fex")
+ ,(jao-notmuch--sq "erlang" "fe")
+ ,(jao-notmuch--sq "gnus" "fg")
+ ,(jao-notmuch--sq "haskell" "fh")
+ ,(jao-notmuch--sq "idris" "fid")
+ ,(jao-notmuch--sq "lobsters" "fl")
+ ,(jao-notmuch--sq "mailutils" "fm")
+ ,(jao-notmuch--sq "notmuch" "fn")
+ ,(jao-notmuch--sq "papers" "fax")
+ ,(jao-notmuch--sq "scheme" "fl")
+ ,(jao-notmuch--sq "xmobar" "fx")
+ ,(jao-notmuch--sec
+ (jao-notmuch--qn "feeds" "prog" "fp"
+ '("tag:prog"
+ "not tag:\"/(lobsters|clojure|xmobar|gmane)/\"")))
+ ,@(mapcar #'jao-notmuch--sec
+ (jao-notmuch--mboxes-search "feeds" "emacs" "prog"))))
+
+ (defvar jao-notmuch-dynamic-searches
+ `(,(jao-notmuch--q "jao" "draft" "d" '("tag:draft"))
+ ,(jao-notmuch--q "bml" "today" "tb" '("tag:bigml" "date:24h.."))
+ ,(jao-notmuch--q "jao" "today" "tj"
+ '("tag:jao" "date:24h.."
+ "not tag:\"/(feeds|spam|local)/\""))
+ ,(jao-notmuch--q "bml" "flagged" "rb" '("tag:flagged" "tag:bigml"))
+ ,(jao-notmuch--q "jao" "flagged" "rj" '("tag:flagged" "not tag:bigml"))
+ ,(jao-notmuch--q "unread" nil "n" '("tag:unread"))))
(defun jao-notmuch-tree-widen-search ()
(interactive)
@@ -188,14 +198,30 @@
#+end_src
* hello
#+begin_src emacs-lisp
- (defun jao-notmuch-hello-insert-searches ()
- (when-let (searches (notmuch-hello-query-counts notmuch-saved-searches))
- (widget-insert "Saved searches:\n\n")
+ (defun jao-notmuch-hello--insert-searches (searches title)
+ (when-let (searches (notmuch-hello-query-counts searches))
+ (let ((cnt (seq-reduce (lambda (c q) (+ c (or (plist-get q :count) 0)))
+ searches
+ 0)))
+ (widget-insert (format "%d %s\n\n" cnt title)))
(let ((start (point)))
(let ((notmuch-column-control t))
(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-secondary-searches ()
+ (jao-notmuch-hello--insert-searches
+ (seq-filter (lambda (q) (plist-get q :secondary)) notmuch-saved-searches)
+ "feeds"))
+
+ (defun jao-notmuch-hello-insert-dynamic-searches ()
+ (jao-notmuch-hello--insert-searches jao-notmuch-dynamic-searches "dynamic"))
+
(defun jao-notmuch-refresh-agenda ()
(interactive)
(save-window-excursion (org-agenda-list))
@@ -219,7 +245,9 @@
(use-package notmuch-hello
:init
(setq notmuch-column-control t
- notmuch-hello-sections '(jao-notmuch-hello-insert-searches
+ notmuch-hello-sections '(jao-notmuch-hello-insert-primary-searches
+ jao-notmuch-hello-insert-secondary-searches
+ jao-notmuch-hello-insert-dynamic-searches
notmuch-hello-insert-alltags
notmuch-hello-insert-header)
notmuch-hello-thousands-separator ","