unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files
Date: Fri, 23 Sep 2022 00:26:04 +0300	[thread overview]
Message-ID: <20220922212604.222570-1-tomi.ollila@iki.fi> (raw)

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

             reply	other threads:[~2022-09-22 21:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 21:26 Tomi Ollila [this message]
2022-11-05 17:45 ` [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220922212604.222570-1-tomi.ollila@iki.fi \
    --to=tomi.ollila@iki.fi \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).