summaryrefslogtreecommitdiffhomepage
path: root/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/jao-notmuch.el64
1 files changed, 24 insertions, 40 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index ea8dc2a..f11556e 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -228,18 +228,6 @@
;;;; Keeping track of unread messages in current tree view
-(defvar-local jao-notmuch--query-name nil)
-
-(defun jao-notmuch--query-name ()
- (when notmuch-tree-basic-query
- (or jao-notmuch--query-name
- (setq jao-notmuch--query-name
- (let ((q (seq-find (lambda (q)
- (string= (or (plist-get q :query) "")
- notmuch-tree-basic-query))
- notmuch-saved-searches)))
- (or (plist-get q :name) notmuch-tree-basic-query))))))
-
(defun jao-notmuch--looking-at-new-p (&optional p)
(when-let (ts (if p (plist-get p :tags) (notmuch-show-get-tags)))
(or (member "unread" ts) (member "new" ts))))
@@ -247,7 +235,7 @@
(defsubst jao-notmuch-tree--first-p (&optional msg)
(plist-get (or msg (notmuch-tree-get-message-properties)) :first))
-(defun jao-notmuch--unread-counts (&optional thread)
+(defun jao-notmuch--message-counts (&optional thread)
(let ((cnt) (total 0) (match 0) (msg))
(save-excursion
(if thread
@@ -265,41 +253,38 @@
(forward-line 1)))
(when cnt (list total match cnt))))
-(defvar jao-notmuch-tree-buffer-name-format "%Q")
-(defvar jao-notmuch-header-line-format "[%N / %M / %T] %n / %m / %t - %S")
+(defvar jao-notmuch-header-line-format "%S - %Q [%N / %M / %T] %n / %m / %t")
-(defun jao-notmuch-tree--format-name (sb query total match new ttotal tmatch tnew)
- (format-spec (if sb
- jao-notmuch-header-line-format
- jao-notmuch-tree-buffer-name-format)
+(defun jao-notmuch--format-counts (sb query total match new ttotal tmatch tnew)
+ (format-spec jao-notmuch-header-line-format
`((?S . ,sb) (?Q . ,query) (?T . ,total) (?N . ,new) (?M . ,match)
(?t . ,ttotal) (?n . ,tnew) (?m . ,tmatch))))
-(defun jao-notmuch--update-header-line (q nc)
- (let ((s (thread-last (notmuch-show-get-subject)
- (notmuch-show-strip-re)
- (notmuch-sanitize))))
- (setq-local header-line-format
- (apply 'jao-notmuch-tree--format-name s q nc))))
-
-(defun jao-notmuch--tree-update-buffer-name (&optional mb)
- (when-let* ((n (jao-notmuch--unread-counts))
- (nc (append n (jao-notmuch--unread-counts t)))
- (q (jao-notmuch--query-name)))
- (prog1 (rename-buffer (apply #'jao-notmuch-tree--format-name nil q nc))
- (when mb (with-current-buffer mb (jao-notmuch--update-header-line q nc)))
- (when (fboundp 'jao-minibuffer-refresh) (jao-minibuffer-refresh)))))
-
-(defun jao-notmuch-tree--find-update-buffer-name (&rest _args)
- (when-let ((mb (window-buffer notmuch-tree-message-window)))
+(defun jao-notmuch--update-header-line (mb)
+ (let* ((n (or (jao-notmuch--message-counts) '(0 0 0)))
+ (nc (append n (or (jao-notmuch--message-counts t) '(0 0 0))))
+ (q (buffer-name)))
+ (with-current-buffer mb
+ (let ((s (thread-last (notmuch-show-get-subject)
+ (notmuch-show-strip-re)
+ (notmuch-sanitize))))
+ (setq-local header-line-format
+ (apply 'jao-notmuch--format-counts s q nc))))))
+
+(defun jao-notmuch-tree--find-update-header-line (&rest _args)
+ (when-let ((mb (if (derived-mode-p 'notmuch-show-mode)
+ (current-buffer)
+ (window-buffer notmuch-tree-message-window))))
(seq-find (lambda (b)
(with-current-buffer b
(and (derived-mode-p 'notmuch-tree-mode)
- (eq notmuch-tree-message-buffer mb)
- (jao-notmuch--tree-update-buffer-name mb))))
+ (or (null notmuch-tree-message-buffer)
+ (eq notmuch-tree-message-buffer mb))
+ (jao-notmuch--update-header-line mb))))
(buffer-list))))
-(add-hook 'notmuch-after-tag-hook #'jao-notmuch-tree--find-update-buffer-name)
+(add-hook 'notmuch-after-tag-hook #'jao-notmuch-tree--find-update-header-line)
+(add-hook 'notmuch-show-hook #'jao-notmuch-tree--find-update-header-line)
;;;; Outline mode for tree view
@@ -375,7 +360,6 @@
(defun jao-notmuch--tree-sentinel (proc &rest _)
(when (eq (process-status proc) 'exit)
- (jao-notmuch--tree-update-buffer-name)
(jao-notmuch-tree-hide-others)))
(defun jao-notmuch-tree-setup (&optional prefix)