diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/jao-notmuch.el | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index 320e898..c7dc1fb 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -238,7 +238,7 @@ (string= (or (plist-get q :query) "") notmuch-tree-basic-query)) notmuch-saved-searches))) - (or (plist-get q :name) notmuch-tree-basic-query)))))) + (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))) @@ -248,7 +248,7 @@ (plist-get (or msg (notmuch-tree-get-message-properties)) :first)) (defun jao-notmuch--unread-counts (&optional thread) - (let ((cnt) (total) (msg)) + (let ((cnt) (total 0) (match 0) (msg)) (save-excursion (if thread (while (and (not (jao-notmuch-tree--first-p)) @@ -258,38 +258,35 @@ (or (not cnt) (not thread) (not (jao-notmuch-tree--first-p msg)))) - (unless cnt (setq cnt 0 total 0)) + (unless cnt (setq cnt 0)) (setq total (1+ total)) - (when (jao-notmuch--looking-at-new-p msg) - (setq cnt (1+ cnt))) + (when (plist-get msg :match) (setq match (1+ match))) + (when (jao-notmuch--looking-at-new-p msg) (setq cnt (1+ cnt))) (forward-line 1))) - (when cnt (list total cnt)))) + (when cnt (list total match cnt)))) -(defvar jao-notmuch-tree-buffer-name-format "%Q [%N / %T] %n / %t") +(defvar jao-notmuch-tree-buffer-name-format "%Q [%N / %M] %n / %m") -(defun jao-notmuch-tree--format-name (query total new ttotal tnew) +(defun jao-notmuch-tree--format-name (query total match new ttotal tmatch tnew) (format-spec jao-notmuch-tree-buffer-name-format - `((?T . ,total) (?N . ,new) (?Q . ,query) - (?t . ,ttotal) (?n . ,tnew)))) + `((?Q . ,query) (?T . ,total) (?N . ,new) (?M . ,match) + (?t . ,ttotal) (?n . ,tnew) (?m . ,tmatch)))) (defun jao-notmuch--tree-update-buffer-name () (when-let* ((n (jao-notmuch--unread-counts)) - (nc (jao-notmuch--unread-counts t)) + (nc (append n (jao-notmuch--unread-counts t))) (q (jao-notmuch--query-name))) - (prog1 - (rename-buffer - (apply #'jao-notmuch-tree--format-name q (append n nc))) + (prog1 (rename-buffer (apply #'jao-notmuch-tree--format-name 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)) - (tb (seq-find (lambda (b) - (with-current-buffer b - (and (derived-mode-p 'notmuch-tree-mode) - (eq notmuch-tree-message-buffer mb) - b))) - (buffer-list)))) - (with-current-buffer tb (jao-notmuch--tree-update-buffer-name)))) + (when-let ((mb (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)))) + (buffer-list)))) (add-hook 'notmuch-after-tag-hook #'jao-notmuch-tree--find-update-buffer-name) |