[PATCH] emacs: fix notmuch-show-update-tags to support duplicate files

Subject: [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files

Date: Fri, 23 Sep 2022 00:26:04 +0300

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


With duplicate files, the headerlines of messages in notmuch-show
buffer contains (initially) 1/n at the end of line.

Update the regexp used to search and replace tag changes to
match the current line -- drop unnecessary capturing of the
(tags), but capture the duplicates indicator.

Update the headerline pretty much like notmuch-show-insert-headerline
does, like the changes introduced mostly in commit 5ea5a5557d9a.
---

Is this getting too complex (well, we may have other stuff with
similar complexity there ;/) ?

Is there any better solutions ?

 emacs/notmuch-show.el | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec998ede..0527c3a5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -453,13 +453,20 @@ (defun notmuch-show-update-tags (tags)
   "Update the displayed tags of the current message."
   (save-excursion
     (goto-char (notmuch-show-message-top))
-    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
-      (let ((inhibit-read-only t))
-	(replace-match (concat "("
-			       (notmuch-tag-format-tags
-				tags
-				(notmuch-show-get-prop :orig-tags))
-			       ")"))))))
+    (when (re-search-forward "([^()]*) *\\([^()]*\\)$" (line-end-position) t)
+      (let ((inhibit-read-only t)
+	    (tags-str (notmuch-tag-format-tags
+		       tags (notmuch-show-get-prop :orig-tags)))
+	    (txt (match-string 1)))
+	(replace-match (concat "(" tags-str ")"
+			       (and (string-lessp "" txt)
+				    (notmuch-show-spaces-n
+				     (max 0 (- (window-width)
+					       (- (match-beginning 0)
+						  (notmuch-show-message-top))
+					       (length tags-str)
+					       (length txt) 3))))
+			       txt))))))
 
 (defun notmuch-clean-address (address)
   "Try to clean a single email ADDRESS for display. Return a cons
-- 
2.30.2

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

Thread: