unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [DRAFT PATCH] emacs: show local date next to Date: in case value differs
@ 2015-03-23 17:45 Tomi Ollila
  2015-04-01 23:30 ` David Bremner
  2015-04-06  8:02 ` Mark Walters
  0 siblings, 2 replies; 7+ messages in thread
From: Tomi Ollila @ 2015-03-23 17:45 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila, Tomi Ollila

From: Tomi Ollila <too@iki.fi>

When adding Date: header of a message to notmuch-show buffer, compare the
date string with local representation of it and if these differ, output
Date: {original-date-string}  ({local-date-representation})

This is useful e.g. when mail system provides Date: strings with
different timezone information than the sender is located at.

---
 emacs/notmuch-show.el | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f15f981..7e81859 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -460,15 +460,28 @@ (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
   (insert header ": " (notmuch-sanitize header-value) "\n"))
 
-(defun notmuch-show-insert-headers (headers)
+(defun notmuch--make-date (timestamp)
+  (if (> timestamp 2147483647)
+      (message-make-date (seconds-to-time timestamp))
+    (message-make-date (encode-time timestamp 0 0 1 1 1970 t))))
+
+(defun notmuch-show-insert-headers (headers &optional timestamp)
   "Insert the headers of the current message."
-  (let ((start (point)))
+  (let ((start (point))
+	date-local)
     (mapc (lambda (header)
 	    (let* ((header-symbol (intern (concat ":" header)))
 		   (header-value (plist-get headers header-symbol)))
-	      (if (and header-value
-		       (not (string-equal "" header-value)))
-		  (notmuch-show-insert-header header header-value))))
+	      (when (and header-value
+			 (not (string-equal "" header-value)))
+		(if (and timestamp
+			 (string-equal header "Date")
+			 (not (string-equal
+			       (setq date-local (notmuch--make-date timestamp))
+			       header-value)))
+		    (setq header-value
+			  (format "%s  (%s)" header-value date-local)))
+		(notmuch-show-insert-header header header-value))))
 	  notmuch-message-headers)
     (save-excursion
       (save-restriction
@@ -1012,7 +1025,7 @@ (defun notmuch-show-insert-msg (msg depth)
     ;; Set `headers-start' to point after the 'Subject:' header to be
     ;; compatible with the existing implementation. This just sets it
     ;; to after the first header.
-    (notmuch-show-insert-headers headers)
+    (notmuch-show-insert-headers headers (plist-get msg :timestamp))
     (save-excursion
       (goto-char content-start)
       ;; If the subject of this message is the same as that of the
-- 
1.9.1

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

end of thread, other threads:[~2015-08-17 12:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-23 17:45 [DRAFT PATCH] emacs: show local date next to Date: in case value differs Tomi Ollila
2015-04-01 23:30 ` David Bremner
2015-04-07  8:42   ` Tomi Ollila
2015-08-16 10:15     ` David Bremner
2015-08-16 19:43       ` Tomi Ollila
2015-08-17 12:29         ` David Bremner
2015-04-06  8:02 ` Mark Walters

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).