summaryrefslogtreecommitdiffhomepage
path: root/custom/jao-custom-notmuch.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2025-11-08 18:26:41 +0000
committerjao <jao@gnu.org>2025-11-08 18:26:41 +0000
commit75fb115377a9f57e6fdceb7f3a32903faf0fd479 (patch)
tree14ae71af29335fd459c6511e9d0333fdcc57f7c4 /custom/jao-custom-notmuch.el
parentea763e39f7c491f78297135ddf1c3de0e8c2d49b (diff)
downloadelibs-75fb115377a9f57e6fdceb7f3a32903faf0fd479.tar.gz
elibs-75fb115377a9f57e6fdceb7f3a32903faf0fd479.tar.bz2
notmuch: custom search-jump command
Diffstat (limited to 'custom/jao-custom-notmuch.el')
-rw-r--r--custom/jao-custom-notmuch.el32
1 files changed, 27 insertions, 5 deletions
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el
index b0e7043..3f714b3 100644
--- a/custom/jao-custom-notmuch.el
+++ b/custom/jao-custom-notmuch.el
@@ -53,6 +53,7 @@
;;; saved searches
(defvar jao-notmuch--new "tag:\"/^(unread|new)$/\"")
+(defvar jao-notmuch--new-rx (regexp-quote jao-notmuch--new))
(defvar jao-notmuch--newa (concat jao-notmuch--new " AND "))
(defun jao-notmuch--q (d0 &optional k d1 qs st)
@@ -188,12 +189,32 @@
(if widen jao-notmuch-widened-searches notmuch-saved-searches)))
(notmuch-jump-search)))
+(defun jao-notmuch--searches-w/new (searches)
+ (seq-filter (lambda (s)
+ (string-match-p jao-notmuch--new-rx (plist-get s :query)))
+ (notmuch-hello-query-counts searches)))
+
+(defconst jao-notmuch--search-keys '("a" "s" "d" "f" "g" "h" "j" "k" "l"))
+
+(defun jao-notmuch--index-searches (searches)
+ (seq-map-indexed (lambda (q i)
+ (plist-put q :key (or (elt jao-notmu
+ch--search-keys i)
+ (format "%s" i))))
+ searches))
+
(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)))
+ (if-let* ((searches (jao-notmuch--searches-w/new notmuch-saved-searches)))
+ (if (= 1 (length searches))
+ (let* ((q (car searches))
+ (of (eq 'oldest-first (plist-get q :sort-order)))
+ (query (plist-get q :query)))
+ (notmuch-tree query nil nil nil nil nil nil of t))
+ (let ((notmuch-saved-searches (jao-notmuch--index-searches searches)))
+ (notmuch-jump-search)))
+ (jao-notmuch-jump-search t)))
;;; tags
(defvar jao-notmuch--shared-tags
@@ -335,7 +356,8 @@
(when jao-notmuch-enabled
(add-hook 'jao-afio-switch-hook #'jao-notmuch-refresh-hello))
- :bind (:map notmuch-hello-mode-map
+ :bind (("s-j" . jao-notmuch-jump)
+ :map notmuch-hello-mode-map
(("a" . jao-notmuch-refresh-agenda)
("A" . jao-afio-open-mail)
("g" . jao-notmuch-refresh-hello)
@@ -489,7 +511,7 @@
(defun jao-notmuch-before-tree (&rest _args)
(window-configuration-to-register ?G)
- (when (string= (buffer-name) "*notmuch-hello*")
+ (when t ;; (string= (buffer-name) "*notmuch-hello*")
(when (< (frame-width) 230) (delete-other-windows))
(split-window-right 40)
(other-window 1)))