Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6C535431FD2 for ; Mon, 23 Mar 2015 10:45:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.438 X-Spam-Level: ** X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 40URh2cYGN4v for ; Mon, 23 Mar 2015 10:45:50 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 1EF25431FC0 for ; Mon, 23 Mar 2015 10:45:50 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 916371000F4; Mon, 23 Mar 2015 19:45:24 +0200 (EET) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [DRAFT PATCH] emacs: show local date next to Date: in case value differs Date: Mon, 23 Mar 2015 19:45:22 +0200 Message-Id: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.0.0 Cc: tomi.ollila@iki.fi, Tomi Ollila X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 17:45:53 -0000 From: Tomi Ollila 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