[PATCH v3 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / 27 / d2ae32ab384247c912b38b990caa514bfe7374
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 olra.theworths.org (Postfix) with ESMTP id 18CA9431FC2\r
6         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 01:34:37 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 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] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 1NPQ5qt6cz6U for <notmuch@notmuchmail.org>;\r
17         Wed, 29 Oct 2014 01:34:29 -0700 (PDT)\r
18 Received: from mail1.qmul.ac.uk (mail1.qmul.ac.uk [138.37.6.7])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id DBC1F431FB6\r
22         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 01:34:28 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail1.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1XjOhy-0008Kb-2R; Wed, 29 Oct 2014 08:34:24 +0000\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1XjOhx-0001Bh-Mv; Wed, 29 Oct 2014 08:34:21 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Jesse Rosenthal <jrosenthal@jhu.edu>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH] Avoid empty thread names if possible.\r
34 In-Reply-To: <87oatnakqy.fsf@jhu.edu>\r
35 References: <87oatnakqy.fsf@jhu.edu>\r
36 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
37         (x86_64-pc-linux-gnu)\r
38 Date: Wed, 29 Oct 2014 08:34:19 +0000\r
39 Message-ID: <87tx2nuvec.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 87.81.223.162\r
43 X-QM-Geographic: According to ripencc,\r
44         this message was delivered by a machine in Britain (UK) (GB).\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: 1a4550a7ce54ec42d6da23d121094105 (of first 20000 bytes)\r
47 X-SpamAssassin-Score: -0.1\r
48 X-SpamAssassin-SpamBar: /\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
50         determine if it is\r
51         spam. We require at least 5.0 points to mark a message as spam.\r
52         This message scored -0.1 points.\r
53         Summary of the scoring: \r
54         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
55         provider *      (markwalters1009[at]gmail.com)\r
56         * -0.1 AWL AWL: From: address is in the auto white-list\r
57 X-QM-Scan-Virus: ClamAV says the message is clean\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Wed, 29 Oct 2014 08:34:37 -0000\r
71 \r
72 \r
73 Hi\r
74 \r
75 On Tue, 07 Oct 2014, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:\r
76 > Currently the thread is named based on either the oldest or newest\r
77 > matching message (depending on the search order). If this message has\r
78 > an empty subject, though, the thread will show up with an empty\r
79 > subject in the search results. (See the thread starting with\r
80 > `id:1412371140-21051-1-git-send-email-david@tethera.net` for an\r
81 > example.)\r
82 >\r
83 > This patch changes the behavior to name based on the oldest/newest\r
84 > matching non-empty subject. This is particularly helpful for patchsets.\r
85 > If the only subjects are empty, the thread subject will still be empty.\r
86 \r
87 I approve of the change in the output but I am unsure about the\r
88 implementation. It would be nice to have a clear rule about which\r
89 subject is taken. Eg: \r
90 \r
91         if sort is oldest first then it is the subject of the oldest\r
92         matching message with a non-empty subject. Similarly if sort\r
93         is newest first.\r
94 \r
95 Also, it would be nice if the implementation did not rely on what order\r
96 we call _thread_add_matched_message on the matching messages in the\r
97 thread. I think in some ways we already rely on the order (for the order\r
98 of the author list), but if you want to rely on the order here I think\r
99 it at least deserves a comment.\r
100 \r
101 >\r
102 > Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
103 > ---\r
104 >  lib/thread.cc | 6 ++++--\r
105 >  1 file changed, 4 insertions(+), 2 deletions(-)\r
106 >\r
107 > diff --git a/lib/thread.cc b/lib/thread.cc\r
108 > index 8922403..ea10295 100644\r
109 > --- a/lib/thread.cc\r
110 > +++ b/lib/thread.cc\r
111 > @@ -348,18 +348,20 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
112 >  {\r
113 >      time_t date;\r
114 >      notmuch_message_t *hashed_message;\r
115 > +    const char *cur_subject;\r
116 >  \r
117 >      date = notmuch_message_get_date (message);\r
118 > +    cur_subject = notmuch_thread_get_subject (thread);\r
119 >  \r
120 >      if (date < thread->oldest || ! thread->matched_messages) {\r
121 >       thread->oldest = date;\r
122 > -     if (sort == NOTMUCH_SORT_OLDEST_FIRST)\r
123 > +     if (sort == NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)\r
124 >           _thread_set_subject_from_message (thread, message);\r
125 >      }\r
126 >  \r
127 >      if (date > thread->newest || ! thread->matched_messages) {\r
128 >       thread->newest = date;\r
129 > -     if (sort != NOTMUCH_SORT_OLDEST_FIRST)\r
130 > +     if (sort != NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)\r
131 >           _thread_set_subject_from_message (thread, message);\r
132 >      }\r
133 \r
134 So looking at the above I think the oldest first gives the subject in\r
135 my suggestion above (since the messages are supplied in oldest first\r
136 order). But newest first may not: indeed if the subject starts out as\r
137 something and becomes empty then this will set the subject empty and\r
138 then leave it empty.\r
139 \r
140 (Note _thread_set_subject_from_message calls notmuch_message_get_header\r
141 which returns an empty string "" if the subject line is empty or not\r
142 present).\r
143 \r
144 Best wishes\r
145 \r
146 Mark\r
147 \r
148 \r
149 >  \r
150 > -- \r
151 > 2.1.2\r
152 >\r
153 > _______________________________________________\r
154 > notmuch mailing list\r
155 > notmuch@notmuchmail.org\r
156 > http://notmuchmail.org/mailman/listinfo/notmuch\r