unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files
@ 2022-09-22 21:26 Tomi Ollila
  2022-11-05 17:45 ` David Bremner
  0 siblings, 1 reply; 9+ messages in thread
From: Tomi Ollila @ 2022-09-22 21:26 UTC (permalink / raw)
  To: notmuch; +Cc: 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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-15 14:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 21:26 [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files Tomi Ollila
2022-11-05 17:45 ` David Bremner
2022-11-06 14:08   ` Tomi Ollila
2022-11-11 21:48     ` [PATCH 1/3] emacs/show: use plist to pass message info to n-s-insert-headerline David Bremner
2022-11-11 21:48       ` [PATCH 2/3] emacs/show: add optional orig-tags argument to n-s-i-headerline David Bremner
2022-11-11 21:48       ` [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags David Bremner
2022-11-13 18:11         ` Tomi Ollila
2022-11-15 11:59           ` David Bremner
2022-11-15 14:01             ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).