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 1/3] emacs/show: use plist to pass message info to n-s-insert-headerline
Date: Fri, 11 Nov 2022 16:48:29 -0500	[thread overview]
Message-ID: <20221111214831.46716-1-david@tethera.net> (raw)
In-Reply-To: <y38m6ja.737nfk-too@iki.fi>

This should allow calling notmuch-show-insert-headerline from other
places without duplicating the set of plist accesses.
---
 emacs/notmuch-show.el | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec998ede..b7a8de6a 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -530,11 +530,18 @@ Return unchanged ADDRESS if parsing fails."
 	  (plist-put msg :height height)
 	  height))))
 
-(defun notmuch-show-insert-headerline (headers date tags depth duplicate file-count)
+(defun notmuch-show-insert-headerline (msg-plist depth tags)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
-  (let ((start (point))
-	(from (notmuch-sanitize
+  (let* ((start (point))
+	 (headers (plist-get msg-plist :headers))
+	 (duplicate (or (plist-get msg-plist :duplicate) 0))
+	 (file-count (length (plist-get msg-plist :filename)))
+	 (date (or (and notmuch-show-relative-dates
+			(plist-get msg-plist :date_relative))
+		   (plist-get headers :Date)))
+    	 (duplicate (or (plist-get msg-plist :duplicate) 0))
+	 (from (notmuch-sanitize
 	       (notmuch-show-clean-address (plist-get headers :From)))))
     (when (string-match "\\cR" from)
       ;; If the From header has a right-to-left character add
@@ -1171,8 +1178,6 @@ is out of range."
 (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
@@ -1180,11 +1185,7 @@ is out of range."
 	 headers-start headers-end
 	 (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))
     (setq message-start (point-marker))
-    (notmuch-show-insert-headerline headers
-				    (or (and notmuch-show-relative-dates
-					     (plist-get msg :date_relative))
-					(plist-get headers :Date))
-				    (plist-get msg :tags) depth duplicate files)
+    (notmuch-show-insert-headerline msg depth (plist-get msg :tags))
     (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.1

  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     ` David Bremner [this message]
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=20221111214831.46716-1-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).