1 Return-Path: <jani@nikula.org>
\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 874BA431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 6 Mar 2012 00:20:29 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 2w-l4cFUj+9W for <notmuch@notmuchmail.org>;
\r
16 Tue, 6 Mar 2012 00:20:25 -0800 (PST)
\r
17 Received: from mail-pz0-f45.google.com (mail-pz0-f45.google.com
\r
18 [209.85.210.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 79689431FAE
\r
21 for <notmuch@notmuchmail.org>; Tue, 6 Mar 2012 00:20:25 -0800 (PST)
\r
22 Received: by dadp14 with SMTP id p14so4753431dad.18
\r
23 for <notmuch@notmuchmail.org>; Tue, 06 Mar 2012 00:20:23 -0800 (PST)
\r
24 Received-SPF: pass (google.com: domain of jani@nikula.org designates
\r
25 10.68.239.195 as permitted sender) client-ip=10.68.239.195;
\r
26 Authentication-Results: mr.google.com;
\r
27 spf=pass (google.com: domain of jani@nikula.org
\r
28 designates 10.68.239.195 as permitted sender)
\r
29 smtp.mail=jani@nikula.org
\r
30 Received: from mr.google.com ([10.68.239.195])
\r
31 by 10.68.239.195 with SMTP id vu3mr29119326pbc.49.1331022023585
\r
32 (num_hops = 1); Tue, 06 Mar 2012 00:20:23 -0800 (PST)
\r
34 Received: by 10.68.239.195 with SMTP id vu3mr25105581pbc.49.1331022023409;
\r
35 Tue, 06 Mar 2012 00:20:23 -0800 (PST)
\r
36 Received: by 10.68.12.103 with HTTP; Tue, 6 Mar 2012 00:20:23 -0800 (PST)
\r
37 Received: by 10.68.12.103 with HTTP; Tue, 6 Mar 2012 00:20:23 -0800 (PST)
\r
38 In-Reply-To: <87zkbukb59.fsf@gmail.com>
\r
39 References: <1330613059-5130-1-git-send-email-daniel@schoepe.org>
\r
40 <1330613059-5130-2-git-send-email-daniel@schoepe.org>
\r
41 <CAB+hUn-iQbXq_UDcj97h2Duq=gJdxpiJjOn6YzmVcZw+GEgK0A@mail.gmail.com>
\r
42 <87zkbukb59.fsf@gmail.com>
\r
43 Date: Tue, 6 Mar 2012 10:20:23 +0200
\r
45 <CAB+hUn-jcxyS8wR7UfC1skRsUtF+r04hCc-oVrBwUsvZefNPzw@mail.gmail.com>
\r
46 Subject: Re: [PATCH v2] emacs: Pass a copy to
\r
47 notmuch-saved-search-sort-function
\r
48 From: Jani Nikula <jani@nikula.org>
\r
49 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
50 Content-Type: multipart/alternative; boundary=047d7b33d5cce4bfa104ba8eb662
\r
52 ALoCoQkkZWmRJUzPGJ8IzVvJjStyYZMwy7rS9BfK1ngtNpK3IOwCF2KBhsmx6irk5rzMTkA9fbvg
\r
53 Cc: notmuch@notmuchmail.org
\r
54 X-BeenThere: notmuch@notmuchmail.org
\r
55 X-Mailman-Version: 2.1.13
\r
57 List-Id: "Use and development of the notmuch mail system."
\r
58 <notmuch.notmuchmail.org>
\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
62 List-Post: <mailto:notmuch@notmuchmail.org>
\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
66 X-List-Received-Date: Tue, 06 Mar 2012 08:20:29 -0000
\r
68 --047d7b33d5cce4bfa104ba8eb662
\r
69 Content-Type: text/plain; charset=UTF-8
\r
71 On Mar 5, 2012 11:11 PM, "Dmitry Kurochkin" <dmitry.kurochkin@gmail.com>
\r
74 > On Mon, 5 Mar 2012 22:55:54 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
75 > > On Mar 5, 2012 5:43 PM, "Dmitry Kurochkin" <dmitry.kurochkin@gmail.com>
\r
78 > > > On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe <daniel@schoepe.org
\r
81 > > > > On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin <
\r
82 > > dmitry.kurochkin@gmail.com> wrote:
\r
83 > > > > > On Thu, 1 Mar 2012 21:24:38 +0100, Daniel Schoepe <
\r
86 > > > > > > notmuch-saved-search-sort-function might destructively modify
\r
88 > > > > > > input (`sort' does that, for instance), so it should not be
\r
90 > > > > > > notmuch-saved-searches directly.
\r
95 > > > > > I think we should require `notmuch-saved-search-sort-function'
\r
97 > > > > > have side effects. Current documentation should be more clear
\r
99 > > > > > this. We need to fix `notmuch-sort-saved-searches' to copy the
\r
101 > > > > > before calling `sort'. But we should not do it in
\r
102 > > > > > `notmuch-hello-insert-saved-searches' for any sorting function
\r
104 > > > > > may not need this copying).
\r
106 > > > > My reasoning was that since sort is such a common function, many
\r
108 > > > > will probably use sort for their own sorting functions, not
\r
110 > > > > that it has side effects. This will lead to confusing behavior
\r
112 > > > > not so easy to track down.
\r
114 > > > > Copying the list of saved searches when running notmuch-hello does
\r
116 > > > > seem be relevant to performance to me, since it's a) not called that
\r
117 > > > > often and b) the list of saved searches will rarely exceed 30
\r
120 > > > > Hence, this way we can avoid some headaches for users who define
\r
122 > > > > own sorting functions at a negligible (performance) cost.
\r
124 > > > > this is also how notmuch-hello did it before the user-defined
\r
129 > > > I do not buy the argument that we should help users who implement
\r
131 > > > own sorting functions but do not read documentation for functions they
\r
132 > > > use. Apparently, those who implemented the `sort' function had
\r
134 > > > ideas. And I do not think it is our job to add workarounds for it.
\r
136 > > > An alternative (and IMO better) solution would be to allow
\r
138 > > > of compare function used for sorting instead of the sorting function
\r
141 > > Providing the customization of the sort function is more powerful than
\r
143 > > compare function. In the case of saved searches I can imagine people
\r
145 > > want to partially use the original order while sort the rest (e.g.
\r
146 > > important ones first in predefined order, others sorted).
\r
150 > > In fact this also
\r
151 > > allows dropping out some elements. And renaming. And changing the
\r
154 > > (I had something like that in mind originally but then settled with just
\r
155 > > capitalizing the important ones to show them first.)
\r
158 > All of these are invalid usages of `notmuch-saved-search-sort-function'.
\r
159 > The function is meant for sorting only (hence the name). So the code
\r
160 > might assume that the function does only sorting.
\r
162 > I do not understand why we need such functionality (renaming,
\r
163 > capitalizing, etc.). You can just rename the query itself if you want
\r
164 > to. Should be easier IMO.
\r
166 Just for the record, I have a few important searches capitalized in the
\r
167 saved searches and just use the regular sort. Capitalized entries sort
\r
168 before the lowercase ones.
\r
170 > But if we need such functionality, we should
\r
171 > not misuse sorting function for it. We can add `notmuch-saved-searches'
\r
172 > function which would return saved searches list (sorted, renamed and
\r
173 > mangled in any other way). By default it would return
\r
174 > `notmuch-saved-searches' variable as is.
\r
178 As to the problem at hand, we should just fix the sort function not to
\r
179 modify its input. I wouldn't hold my breath waiting for someone to provide
\r
180 patches for the rest...
\r
185 --047d7b33d5cce4bfa104ba8eb662
\r
186 Content-Type: text/html; charset=UTF-8
\r
187 Content-Transfer-Encoding: quoted-printable
\r
190 On Mar 5, 2012 11:11 PM, "Dmitry Kurochkin" <<a href=3D"mailto=
\r
191 :dmitry.kurochkin@gmail.com">dmitry.kurochkin@gmail.com</a>> wrote:<br>
\r
193 > On Mon, 5 Mar 2012 22:55:54 +0200, Jani Nikula <<a href=3D"mailto:j=
\r
194 ani@nikula.org">jani@nikula.org</a>> wrote:<br>
\r
195 > > On Mar 5, 2012 5:43 PM, "Dmitry Kurochkin" <<a href=
\r
196 =3D"mailto:dmitry.kurochkin@gmail.com">dmitry.kurochkin@gmail.com</a>><b=
\r
198 > > wrote:<br>
\r
200 > > > On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe <<a hr=
\r
201 ef=3D"mailto:daniel@schoepe.org">daniel@schoepe.org</a>><br>
\r
202 > > wrote:<br>
\r
203 > > > > On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin &l=
\r
205 > > <a href=3D"mailto:dmitry.kurochkin@gmail.com">dmitry.kurochkin@gm=
\r
206 ail.com</a>> wrote:<br>
\r
207 > > > > > On Thu, =C2=A01 Mar 2012 21:24:38 +0100, Daniel Sc=
\r
208 hoepe <<a href=3D"mailto:daniel@schoepe.org">daniel@schoepe.org</a>><=
\r
210 > > wrote:<br>
\r
211 > > > > > > notmuch-saved-search-sort-function might dest=
\r
212 ructively modify its<br>
\r
213 > > > > > > input (`sort' does that, for instance), s=
\r
214 o it should not be given<br>
\r
215 > > > > > > notmuch-saved-searches directly.<br>
\r
216 > > > > > > ---<br>
\r
217 > > > > ><br>
\r
218 > > > > > -1<br>
\r
219 > > > > ><br>
\r
220 > > > > > I think we should require `notmuch-saved-search-so=
\r
221 rt-function' not to<br>
\r
222 > > > > > have side effects. =C2=A0Current documentation sho=
\r
223 uld be more clear about<br>
\r
224 > > > > > this. =C2=A0We need to fix `notmuch-sort-saved-sea=
\r
225 rches' to copy the list<br>
\r
226 > > > > > before calling `sort'. =C2=A0But we should not=
\r
228 > > > > > `notmuch-hello-insert-saved-searches' for any =
\r
229 sorting function (which<br>
\r
230 > > > > > may not need this copying).<br>
\r
231 > > > ><br>
\r
232 > > > > My reasoning was that since sort is such a common funct=
\r
233 ion, many users<br>
\r
234 > > > > will probably use sort for their own sorting functions,=
\r
236 > > > > that it has side effects. This will lead to confusing b=
\r
237 ehavior that's<br>
\r
238 > > > > not so easy to track down.<br>
\r
239 > > > ><br>
\r
240 > > > > Copying the list of saved searches when running notmuch=
\r
241 -hello does not<br>
\r
242 > > > > seem be relevant to performance to me, since it's a=
\r
243 ) not called that<br>
\r
244 > > > > often and b) the list of saved searches will rarely exc=
\r
245 eed 30 elements.<br>
\r
246 > > > ><br>
\r
247 > > > > Hence, this way we can avoid some headaches for users w=
\r
248 ho define their<br>
\r
249 > > > > own sorting functions at a negligible (performance) cos=
\r
250 t. Incidentally,<br>
\r
251 > > > > this is also how notmuch-hello did it before the user-d=
\r
252 efined sections<br>
\r
253 > > > > patches.<br>
\r
254 > > > ><br>
\r
256 > > > I do not buy the argument that we should help users who impl=
\r
258 > > > own sorting functions but do not read documentation for func=
\r
260 > > > use. =C2=A0Apparently, those who implemented the `sort' =
\r
261 function had similar<br>
\r
262 > > > ideas. =C2=A0And I do not think it is our job to add workaro=
\r
265 > > > An alternative (and IMO better) solution would be to allow c=
\r
267 > > > of compare function used for sorting instead of the sorting =
\r
269 > > > itself.<br>
\r
271 > > Providing the customization of the sort function is more powerful=
\r
273 > > compare function. In the case of saved searches I can imagine peo=
\r
275 > > want to partially use the original order while sort the rest (e.g=
\r
277 > > important ones first in predefined order, others sorted).<br>
\r
279 > Valid point.<br>
\r
281 > > In fact this also<br>
\r
282 > > allows dropping out some elements. And renaming. And changing the=
\r
285 > > (I had something like that in mind originally but then settled wi=
\r
287 > > capitalizing the important ones to show them first.)<br>
\r
290 > All of these are invalid usages of `notmuch-saved-search-sort-function=
\r
292 > The function is meant for sorting only (hence the name). =C2=A0So the =
\r
294 > might assume that the function does only sorting.<br>
\r
296 > I do not understand why we need such functionality (renaming,<br>
\r
297 > capitalizing, etc.). =C2=A0You can just rename the query itself if you=
\r
299 > to. =C2=A0Should be easier IMO. =C2=A0</p>
\r
300 <p>Just for the record, I have a few important searches capitalized in the =
\r
301 saved searches and just use the regular sort. Capitalized entries sort befo=
\r
302 re the lowercase ones.</p>
\r
303 <p>> But if we need such functionality, we should<br>
\r
304 > not misuse sorting function for it. =C2=A0We can add `notmuch-saved-se=
\r
306 > function which would return saved searches list (sorted, renamed and<b=
\r
308 > mangled in any other way). =C2=A0By default it would return<br>
\r
309 > `notmuch-saved-searches' variable as is.</p>
\r
311 <p>As to the problem at hand, we should just fix the sort function not to m=
\r
312 odify its input. I wouldn't hold my breath waiting for someone to provi=
\r
313 de patches for the rest...</p>
\r
318 --047d7b33d5cce4bfa104ba8eb662--
\r