1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 6C535431FD2
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Mar 2015 10:45:53 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 40URh2cYGN4v for <notmuch@notmuchmail.org>;
\r
16 Mon, 23 Mar 2015 10:45:50 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 1EF25431FC0
\r
19 for <notmuch@notmuchmail.org>; Mon, 23 Mar 2015 10:45:50 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 916371000F4; Mon, 23 Mar 2015 19:45:24 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [DRAFT PATCH] emacs: show local date next to Date: in case value
\r
26 Date: Mon, 23 Mar 2015 19:45:22 +0200
\r
27 Message-Id: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi>
\r
28 X-Mailer: git-send-email 2.0.0
\r
29 Cc: tomi.ollila@iki.fi, Tomi Ollila <too@iki.fi>
\r
30 X-BeenThere: notmuch@notmuchmail.org
\r
31 X-Mailman-Version: 2.1.13
\r
33 List-Id: "Use and development of the notmuch mail system."
\r
34 <notmuch.notmuchmail.org>
\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
36 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
38 List-Post: <mailto:notmuch@notmuchmail.org>
\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
42 X-List-Received-Date: Mon, 23 Mar 2015 17:45:53 -0000
\r
44 From: Tomi Ollila <too@iki.fi>
\r
46 When adding Date: header of a message to notmuch-show buffer, compare the
\r
47 date string with local representation of it and if these differ, output
\r
48 Date: {original-date-string} ({local-date-representation})
\r
50 This is useful e.g. when mail system provides Date: strings with
\r
51 different timezone information than the sender is located at.
\r
54 emacs/notmuch-show.el | 25 +++++++++++++++++++------
\r
55 1 file changed, 19 insertions(+), 6 deletions(-)
\r
57 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
58 index f15f981..7e81859 100644
\r
59 --- a/emacs/notmuch-show.el
\r
60 +++ b/emacs/notmuch-show.el
\r
61 @@ -460,15 +460,28 @@ (defun notmuch-show-insert-header (header header-value)
\r
62 "Insert a single header."
\r
63 (insert header ": " (notmuch-sanitize header-value) "\n"))
\r
65 -(defun notmuch-show-insert-headers (headers)
\r
66 +(defun notmuch--make-date (timestamp)
\r
67 + (if (> timestamp 2147483647)
\r
68 + (message-make-date (seconds-to-time timestamp))
\r
69 + (message-make-date (encode-time timestamp 0 0 1 1 1970 t))))
\r
71 +(defun notmuch-show-insert-headers (headers &optional timestamp)
\r
72 "Insert the headers of the current message."
\r
73 - (let ((start (point)))
\r
74 + (let ((start (point))
\r
76 (mapc (lambda (header)
\r
77 (let* ((header-symbol (intern (concat ":" header)))
\r
78 (header-value (plist-get headers header-symbol)))
\r
79 - (if (and header-value
\r
80 - (not (string-equal "" header-value)))
\r
81 - (notmuch-show-insert-header header header-value))))
\r
82 + (when (and header-value
\r
83 + (not (string-equal "" header-value)))
\r
84 + (if (and timestamp
\r
85 + (string-equal header "Date")
\r
86 + (not (string-equal
\r
87 + (setq date-local (notmuch--make-date timestamp))
\r
89 + (setq header-value
\r
90 + (format "%s (%s)" header-value date-local)))
\r
91 + (notmuch-show-insert-header header header-value))))
\r
92 notmuch-message-headers)
\r
95 @@ -1012,7 +1025,7 @@ (defun notmuch-show-insert-msg (msg depth)
\r
96 ;; Set `headers-start' to point after the 'Subject:' header to be
\r
97 ;; compatible with the existing implementation. This just sets it
\r
98 ;; to after the first header.
\r
99 - (notmuch-show-insert-headers headers)
\r
100 + (notmuch-show-insert-headers headers (plist-get msg :timestamp))
\r
102 (goto-char content-start)
\r
103 ;; If the subject of this message is the same as that of the
\r