unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Tomi Ollila <tomi.ollila@iki.fi>,
	David Bremner <david@tethera.net>,
	notmuch@notmuchmail.org
Subject: [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags
Date: Fri, 11 Nov 2022 16:48:31 -0500	[thread overview]
Message-ID: <20221111214831.46716-3-david@tethera.net> (raw)
In-Reply-To: <20221111214831.46716-1-david@tethera.net>

Although this has more steps than the previous regular expression
search and replace, it should be more robust against changes in the
headerline format, such as the inclusion of duplicate numbers (which
broke the previous version).
---
 emacs/notmuch-show.el | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5fb5ab31..c4e88be2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -452,14 +452,20 @@ operation on the contents of the current buffer."
 (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))
-			       ")"))))))
+    (let ((inhibit-read-only t)
+	  (start (notmuch-show-message-top))
+	  (depth (notmuch-show-get-prop :depth))
+	  (orig-tags (notmuch-show-get-prop :orig-tags))
+	  (props (notmuch-show-get-message-properties))
+	  (extent (notmuch-show-message-extent)))
+      (goto-char start)
+      (notmuch-show-insert-headerline props depth tags orig-tags)
+      (put-text-property start (1+ start)
+			 :notmuch-message-properties props)
+      (put-text-property (car extent) (cdr extent) :notmuch-message-extent extent)
+      ;; delete original headerline, but do not save to kill ring
+      (delete-region
+       (point) (save-excursion (end-of-line nil) (1+ (point)))))))
 
 (defun notmuch-clean-address (address)
   "Try to clean a single email ADDRESS for display. Return a cons
-- 
2.35.1

  parent reply	other threads:[~2022-11-11 21:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` David Bremner [this message]
2022-11-13 18:11         ` [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags 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=20221111214831.46716-3-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /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).