From: Mark Walters Date: Mon, 6 Apr 2015 08:02:02 +0000 (+0100) Subject: Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2662760b9d6db189a75d5012690bddac67b940d9;p=notmuch-archives.git Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs --- diff --git a/c1/b7d2e11429cdc57504a60afef5608a6a98b86f b/c1/b7d2e11429cdc57504a60afef5608a6a98b86f new file mode 100644 index 000000000..64607415b --- /dev/null +++ b/c1/b7d2e11429cdc57504a60afef5608a6a98b86f @@ -0,0 +1,177 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id C63256DE1BD9 + for ; Mon, 6 Apr 2015 01:02:22 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -1.648 +X-Spam-Level: +X-Spam-Status: No, score=-1.648 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id v4x-foidR_dK for ; + Mon, 6 Apr 2015 01:02:19 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + by arlo.cworth.org (Postfix) with ESMTPS id 04AD06DE1BD5 + for ; Mon, 6 Apr 2015 01:02:17 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Yf1z0-0008Fd-7u; Mon, 06 Apr 2015 09:02:12 +0100 +Received: from 188.30.14.65.threembb.co.uk ([188.30.14.65] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Yf1yy-0004mR-NP; Mon, 06 Apr 2015 09:02:09 +0100 +From: Mark Walters +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [DRAFT PATCH] emacs: show local date next to Date: in case + value differs +In-Reply-To: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi> +References: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 06 Apr 2015 09:02:02 +0100 +Message-ID: <876199sn0l.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 188.30.14.65 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: fc86f14ff3bd18906a41bb88a710de30 (of first 20000 bytes) +X-SpamAssassin-Score: -0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.0 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider + * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain +X-QM-Scan-Virus: ClamAV says the message is clean +Cc: tomi.ollila@iki.fi, Tomi Ollila +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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, 06 Apr 2015 08:02:22 -0000 + +On Mon, 23 Mar 2015, Tomi Ollila wrote: +> 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. + +I think this could be useful. I have to admit that until David pointed +it out in his reply I hadn't noticed the date in the headerline and I do +think the date header is a natural place to display this. + +Jani made a comment on irc that the display could be rather cluttered +so I think it should be customizable. Ideally I would suggest having the +options of none (ie display just the sender date as now), local full +date (as your patch), and relative (to put the relative date in the +date header). + +I have some small comments on the implementation: + +> --- +> 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) + +I suggest passing msg as an optional argument instead of timestamp. I +think it will be more flexible if people want to have other +header modification functions in the future (for example we could add +the senders name to the from line if we know it from other messages). + +> "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))) + +I think I would extract this block as a date-header-wash function. Then +the one special case doesn't interrupt the main function. Something like + + (let ((washed-header-value (if (string-equal header "Date") + (notmuch-date-header-wash header msg) + header-value))) + +(This could go inside or outside the "when") + +Best wishes + +Mark + +> + (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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch