Re: talloc_abort in notmuch_thread_get_tags () when db has been modified
[notmuch-archives.git] / c1 / b7d2e11429cdc57504a60afef5608a6a98b86f
1 Return-Path: <m.walters@qmul.ac.uk>\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 arlo.cworth.org (Postfix) with ESMTP id C63256DE1BD9\r
6  for <notmuch@notmuchmail.org>; Mon,  6 Apr 2015 01:02:22 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.648\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.648 tagged_above=-999 required=5\r
12  tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13  NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\r
15  RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01,\r
16  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
17 Received: from arlo.cworth.org ([127.0.0.1])\r
18  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
19  with ESMTP id v4x-foidR_dK for <notmuch@notmuchmail.org>;\r
20  Mon,  6 Apr 2015 01:02:19 -0700 (PDT)\r
21 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
22  by arlo.cworth.org (Postfix) with ESMTPS id 04AD06DE1BD5\r
23  for <notmuch@notmuchmail.org>; Mon,  6 Apr 2015 01:02:17 -0700 (PDT)\r
24 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
25  by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
26  (envelope-from <m.walters@qmul.ac.uk>)\r
27  id 1Yf1z0-0008Fd-7u; Mon, 06 Apr 2015 09:02:12 +0100\r
28 Received: from 188.30.14.65.threembb.co.uk ([188.30.14.65] helo=localhost)\r
29  by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
30  (envelope-from <m.walters@qmul.ac.uk>)\r
31  id 1Yf1yy-0004mR-NP; Mon, 06 Apr 2015 09:02:09 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
34 Subject: Re: [DRAFT PATCH] emacs: show local date next to Date: in case\r
35  value  differs\r
36 In-Reply-To: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi>\r
37 References: <1427132722-20346-1-git-send-email-tomi.ollila@iki.fi>\r
38 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
39  (x86_64-pc-linux-gnu)\r
40 Date: Mon, 06 Apr 2015 09:02:02 +0100\r
41 Message-ID: <876199sn0l.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 188.30.14.65\r
45 X-QM-Geographic: According to ripencc,\r
46  this message was delivered by a machine in Britain (UK) (GB).\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: fc86f14ff3bd18906a41bb88a710de30 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -0.0\r
50 X-SpamAssassin-SpamBar: /\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52  determine if it is\r
53  spam. We require at least 5.0 points to mark a message as spam.\r
54  This message scored -0.0 points.\r
55  Summary of the scoring: \r
56  *  0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider\r
57  *      (markwalters1009[at]gmail.com)\r
58  * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
59  *      domain\r
60 X-QM-Scan-Virus: ClamAV says the message is clean\r
61 Cc: tomi.ollila@iki.fi, Tomi Ollila <too@iki.fi>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.18\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Mon, 06 Apr 2015 08:02:22 -0000\r
75 \r
76 On Mon, 23 Mar 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
77 > From: Tomi Ollila <too@iki.fi>\r
78 >\r
79 > When adding Date: header of a message to notmuch-show buffer, compare the\r
80 > date string with local representation of it and if these differ, output\r
81 > Date: {original-date-string}  ({local-date-representation})\r
82 >\r
83 > This is useful e.g. when mail system provides Date: strings with\r
84 > different timezone information than the sender is located at.\r
85 \r
86 I think this could be useful. I have to admit that until David pointed\r
87 it out in his reply I hadn't noticed the date in the headerline and I do\r
88 think the date header is a natural place to display this.\r
89 \r
90 Jani made a comment on irc that the display could be rather cluttered\r
91 so I think it should be customizable. Ideally I would suggest having the\r
92 options of none (ie display just the sender date as now), local full\r
93 date (as your patch), and  relative (to put the relative date in the\r
94 date header).\r
95 \r
96 I have some small comments on the implementation: \r
97 \r
98 > ---\r
99 >  emacs/notmuch-show.el | 25 +++++++++++++++++++------\r
100 >  1 file changed, 19 insertions(+), 6 deletions(-)\r
101 >\r
102 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
103 > index f15f981..7e81859 100644\r
104 > --- a/emacs/notmuch-show.el\r
105 > +++ b/emacs/notmuch-show.el\r
106 > @@ -460,15 +460,28 @@ (defun notmuch-show-insert-header (header header-value)\r
107 >    "Insert a single header."\r
108 >    (insert header ": " (notmuch-sanitize header-value) "\n"))\r
109 >  \r
110 > -(defun notmuch-show-insert-headers (headers)\r
111 > +(defun notmuch--make-date (timestamp)\r
112 > +  (if (> timestamp 2147483647)\r
113 > +      (message-make-date (seconds-to-time timestamp))\r
114 > +    (message-make-date (encode-time timestamp 0 0 1 1 1970 t))))\r
115 > +\r
116 > +(defun notmuch-show-insert-headers (headers &optional timestamp)\r
117 \r
118 I suggest passing msg as an  optional argument instead of timestamp. I\r
119 think it will be more flexible if people want to have other\r
120 header modification functions in the future (for example we could add\r
121 the senders name to the from line if we know it from other messages).\r
122 \r
123 >    "Insert the headers of the current message."\r
124 > -  (let ((start (point)))\r
125 > +  (let ((start (point))\r
126 > +     date-local)\r
127 >      (mapc (lambda (header)\r
128 >           (let* ((header-symbol (intern (concat ":" header)))\r
129 >                  (header-value (plist-get headers header-symbol)))\r
130 \r
131 > -           (if (and header-value\r
132 > -                    (not (string-equal "" header-value)))\r
133 > -               (notmuch-show-insert-header header header-value))))\r
134 \r
135 > +           (when (and header-value\r
136 > +                      (not (string-equal "" header-value)))\r
137 > +             (if (and timestamp\r
138 > +                      (string-equal header "Date")\r
139 > +                      (not (string-equal\r
140 > +                            (setq date-local (notmuch--make-date timestamp))\r
141 > +                            header-value)))\r
142 > +                 (setq header-value\r
143 > +                       (format "%s  (%s)" header-value date-local)))\r
144 \r
145 I think I would extract this block as a date-header-wash function. Then\r
146 the one special case doesn't interrupt the main function. Something like\r
147 \r
148     (let ((washed-header-value (if (string-equal header "Date")\r
149                                     (notmuch-date-header-wash header msg)\r
150                                   header-value)))\r
151 \r
152 (This could go inside or outside the "when")\r
153 \r
154 Best wishes\r
155 \r
156 Mark\r
157 \r
158 > +             (notmuch-show-insert-header header header-value))))\r
159 >         notmuch-message-headers)\r
160 >      (save-excursion\r
161 >        (save-restriction\r
162 > @@ -1012,7 +1025,7 @@ (defun notmuch-show-insert-msg (msg depth)\r
163 >      ;; Set `headers-start' to point after the 'Subject:' header to be\r
164 >      ;; compatible with the existing implementation. This just sets it\r
165 >      ;; to after the first header.\r
166 > -    (notmuch-show-insert-headers headers)\r
167 > +    (notmuch-show-insert-headers headers (plist-get msg :timestamp))\r
168 >      (save-excursion\r
169 >        (goto-char content-start)\r
170 >        ;; If the subject of this message is the same as that of the\r
171 > -- \r
172 > 1.9.1\r
173 >\r
174 > _______________________________________________\r
175 > notmuch mailing list\r
176 > notmuch@notmuchmail.org\r
177 > http://notmuchmail.org/mailman/listinfo/notmuch\r