[RFC PATCH v2 7/7] WIP/emacs: display count of duplicates in headerline

Subject: [RFC PATCH v2 7/7] WIP/emacs: display count of duplicates in headerline

Date: Sun, 19 Jun 2022 20:21:53 -0300

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


---
 emacs/notmuch-show.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1777756b..32d0edc5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -493,7 +493,7 @@ Return unchanged ADDRESS if parsing fails."
       ;; Otherwise format the name and address together.
       (concat p-name " <" p-address ">"))))
 
-(defun notmuch-show-insert-headerline (headers date tags depth)
+(defun notmuch-show-insert-headerline (headers date tags depth duplicate file-count)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point))
@@ -513,7 +513,14 @@ message at DEPTH in the current thread."
 	    date
 	    ") ("
 	    (notmuch-tag-format-tags tags tags)
-	    ")\n")
+	    ")")
+    (insert
+     (if (> file-count 1)
+	 (let ((txt (format "%d/%d\n" duplicate file-count)))
+	   (concat
+	    (notmuch-show-spaces-n (- (window-width) (+ (current-column) (length txt))))
+	    txt))
+       "\n"))
     (overlay-put (make-overlay start (point))
 		 'face 'notmuch-message-summary-face)))
 
@@ -1104,6 +1111,8 @@ is t, hide the part initially and show the button."
 (defun notmuch-show-insert-msg (msg depth)
   "Insert the message MSG at depth DEPTH in the current thread."
   (let* ((headers (plist-get msg :headers))
+	 (duplicate (or (plist-get msg :duplicate) 0))
+	 (files (length (plist-get msg :filename)))
 	 ;; Indentation causes the buffer offset of the start/end
 	 ;; points to move, so we must use markers.
 	 message-start message-end
@@ -1115,7 +1124,7 @@ is t, hide the part initially and show the button."
 				    (or (and notmuch-show-relative-dates
 					     (plist-get msg :date_relative))
 					(plist-get headers :Date))
-				    (plist-get msg :tags) depth)
+				    (plist-get msg :tags) depth duplicate files)
     (setq content-start (point-marker))
     ;; Set `headers-start' to point after the 'Subject:' header to be
     ;; compatible with the existing implementation. This just sets it
-- 
2.35.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: