Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function
authorJani Nikula <jani@nikula.org>
Mon, 5 Mar 2012 20:55:54 +0000 (22:55 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:15 +0000 (09:45 -0800)
40/16418e0cfd39709b41a7452a9871af01084104 [new file with mode: 0644]

diff --git a/40/16418e0cfd39709b41a7452a9871af01084104 b/40/16418e0cfd39709b41a7452a9871af01084104
new file mode 100644 (file)
index 0000000..01c2d7a
--- /dev/null
@@ -0,0 +1,238 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id CFABC431FAF\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 12:55:57 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id MH1XNHoACuj0 for <notmuch@notmuchmail.org>;\r
+       Mon,  5 Mar 2012 12:55:57 -0800 (PST)\r
+Received: from mail-pw0-f53.google.com (mail-pw0-f53.google.com\r
+       [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id BFEFB431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 12:55:56 -0800 (PST)\r
+Received: by pbcuo1 with SMTP id uo1so2937889pbc.26\r
+       for <notmuch@notmuchmail.org>; Mon, 05 Mar 2012 12:55:54 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of jani@nikula.org designates\r
+       10.68.244.99 as permitted sender) client-ip=10.68.244.99; \r
+Authentication-Results: mr.google.com;\r
+       spf=pass (google.com: domain of jani@nikula.org\r
+       designates 10.68.244.99 as permitted sender)\r
+       smtp.mail=jani@nikula.org\r
+Received: from mr.google.com ([10.68.244.99])\r
+       by 10.68.244.99 with SMTP id xf3mr31943011pbc.154.1330980954856\r
+       (num_hops = 1); Mon, 05 Mar 2012 12:55:54 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.68.244.99 with SMTP id xf3mr27794218pbc.154.1330980954646;\r
+       Mon, 05 Mar 2012 12:55:54 -0800 (PST)\r
+Received: by 10.68.12.103 with HTTP; Mon, 5 Mar 2012 12:55:54 -0800 (PST)\r
+Received: by 10.68.12.103 with HTTP; Mon, 5 Mar 2012 12:55:54 -0800 (PST)\r
+In-Reply-To: <1330613059-5130-2-git-send-email-daniel@schoepe.org>\r
+References: <1330613059-5130-1-git-send-email-daniel@schoepe.org>\r
+       <1330613059-5130-2-git-send-email-daniel@schoepe.org>\r
+Date: Mon, 5 Mar 2012 22:55:54 +0200\r
+Message-ID:\r
+ <CAB+hUn-iQbXq_UDcj97h2Duq=gJdxpiJjOn6YzmVcZw+GEgK0A@mail.gmail.com>\r
+Subject: Re: [PATCH v2] emacs: Pass a copy to\r
+       notmuch-saved-search-sort-function\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+Content-Type: multipart/alternative; boundary=047d7b33cc1e01282304ba8527e8\r
+X-Gm-Message-State:\r
+ ALoCoQmjdANh73fr7xQuzX0jtrH17qlCe0u0zuScxGQOiJgDzjZRvtxlXGoWfEs0dF1p4aPbyQY1\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 05 Mar 2012 20:55:58 -0000\r
+\r
+--047d7b33cc1e01282304ba8527e8\r
+Content-Type: text/plain; charset=UTF-8\r
+\r
+On Mar 5, 2012 5:43 PM, "Dmitry Kurochkin" <dmitry.kurochkin@gmail.com>\r
+wrote:\r
+>\r
+> On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe <daniel@schoepe.org>\r
+wrote:\r
+> > On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin <\r
+dmitry.kurochkin@gmail.com> wrote:\r
+> > > On Thu,  1 Mar 2012 21:24:38 +0100, Daniel Schoepe <daniel@schoepe.org>\r
+wrote:\r
+> > > > notmuch-saved-search-sort-function might destructively modify its\r
+> > > > input (`sort' does that, for instance), so it should not be given\r
+> > > > notmuch-saved-searches directly.\r
+> > > > ---\r
+> > >\r
+> > > -1\r
+> > >\r
+> > > I think we should require `notmuch-saved-search-sort-function' not to\r
+> > > have side effects.  Current documentation should be more clear about\r
+> > > this.  We need to fix `notmuch-sort-saved-searches' to copy the list\r
+> > > before calling `sort'.  But we should not do it in\r
+> > > `notmuch-hello-insert-saved-searches' for any sorting function (which\r
+> > > may not need this copying).\r
+> >\r
+> > My reasoning was that since sort is such a common function, many users\r
+> > will probably use sort for their own sorting functions, not realizing\r
+> > that it has side effects. This will lead to confusing behavior that's\r
+> > not so easy to track down.\r
+> >\r
+> > Copying the list of saved searches when running notmuch-hello does not\r
+> > seem be relevant to performance to me, since it's a) not called that\r
+> > often and b) the list of saved searches will rarely exceed 30 elements.\r
+> >\r
+> > Hence, this way we can avoid some headaches for users who define their\r
+> > own sorting functions at a negligible (performance) cost. Incidentally,\r
+> > this is also how notmuch-hello did it before the user-defined sections\r
+> > patches.\r
+> >\r
+>\r
+> I do not buy the argument that we should help users who implement their\r
+> own sorting functions but do not read documentation for functions they\r
+> use.  Apparently, those who implemented the `sort' function had similar\r
+> ideas.  And I do not think it is our job to add workarounds for it.\r
+>\r
+> An alternative (and IMO better) solution would be to allow customization\r
+> of compare function used for sorting instead of the sorting function\r
+> itself.\r
+\r
+Providing the customization of the sort function is more powerful than the\r
+compare function. In the case of saved searches I can imagine people might\r
+want to partially use the original order while sort the rest (e.g.\r
+important ones first in predefined order, others sorted). In fact this also\r
+allows dropping out some elements. And renaming. And changing the queries...\r
+\r
+(I had something like that in mind originally but then settled with just\r
+capitalizing the important ones to show them first.)\r
+\r
+BR,\r
+Jani.\r
+\r
+>\r
+> Regards,\r
+>  Dmitry\r
+>\r
+> > Cheers,\r
+> > Daniel\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--047d7b33cc1e01282304ba8527e8\r
+Content-Type: text/html; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<p><br>\r
+On Mar 5, 2012 5:43 PM, &quot;Dmitry Kurochkin&quot; &lt;<a href=3D"mailto:=\r
+dmitry.kurochkin@gmail.com">dmitry.kurochkin@gmail.com</a>&gt; wrote:<br>\r
+&gt;<br>\r
+&gt; On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe &lt;<a href=3D"mail=\r
+to:daniel@schoepe.org">daniel@schoepe.org</a>&gt; wrote:<br>\r
+&gt; &gt; On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin &lt;<a href=\r
+=3D"mailto:dmitry.kurochkin@gmail.com">dmitry.kurochkin@gmail.com</a>&gt; w=\r
+rote:<br>\r
+&gt; &gt; &gt; On Thu, =C2=A01 Mar 2012 21:24:38 +0100, Daniel Schoepe &lt;=\r
+<a href=3D"mailto:daniel@schoepe.org">daniel@schoepe.org</a>&gt; wrote:<br>\r
+&gt; &gt; &gt; &gt; notmuch-saved-search-sort-function might destructively =\r
+modify its<br>\r
+&gt; &gt; &gt; &gt; input (`sort&#39; does that, for instance), so it shoul=\r
+d not be given<br>\r
+&gt; &gt; &gt; &gt; notmuch-saved-searches directly.<br>\r
+&gt; &gt; &gt; &gt; ---<br>\r
+&gt; &gt; &gt;<br>\r
+&gt; &gt; &gt; -1<br>\r
+&gt; &gt; &gt;<br>\r
+&gt; &gt; &gt; I think we should require `notmuch-saved-search-sort-functio=\r
+n&#39; not to<br>\r
+&gt; &gt; &gt; have side effects. =C2=A0Current documentation should be mor=\r
+e clear about<br>\r
+&gt; &gt; &gt; this. =C2=A0We need to fix `notmuch-sort-saved-searches&#39;=\r
+ to copy the list<br>\r
+&gt; &gt; &gt; before calling `sort&#39;. =C2=A0But we should not do it in<=\r
+br>\r
+&gt; &gt; &gt; `notmuch-hello-insert-saved-searches&#39; for any sorting fu=\r
+nction (which<br>\r
+&gt; &gt; &gt; may not need this copying).<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; My reasoning was that since sort is such a common function, many =\r
+users<br>\r
+&gt; &gt; will probably use sort for their own sorting functions, not reali=\r
+zing<br>\r
+&gt; &gt; that it has side effects. This will lead to confusing behavior th=\r
+at&#39;s<br>\r
+&gt; &gt; not so easy to track down.<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; Copying the list of saved searches when running notmuch-hello doe=\r
+s not<br>\r
+&gt; &gt; seem be relevant to performance to me, since it&#39;s a) not call=\r
+ed that<br>\r
+&gt; &gt; often and b) the list of saved searches will rarely exceed 30 ele=\r
+ments.<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; Hence, this way we can avoid some headaches for users who define =\r
+their<br>\r
+&gt; &gt; own sorting functions at a negligible (performance) cost. Inciden=\r
+tally,<br>\r
+&gt; &gt; this is also how notmuch-hello did it before the user-defined sec=\r
+tions<br>\r
+&gt; &gt; patches.<br>\r
+&gt; &gt;<br>\r
+&gt;<br>\r
+&gt; I do not buy the argument that we should help users who implement thei=\r
+r<br>\r
+&gt; own sorting functions but do not read documentation for functions they=\r
+<br>\r
+&gt; use. =C2=A0Apparently, those who implemented the `sort&#39; function h=\r
+ad similar<br>\r
+&gt; ideas. =C2=A0And I do not think it is our job to add workarounds for i=\r
+t.<br>\r
+&gt;<br>\r
+&gt; An alternative (and IMO better) solution would be to allow customizati=\r
+on<br>\r
+&gt; of compare function used for sorting instead of the sorting function<b=\r
+r>\r
+&gt; itself.</p>\r
+<p>Providing the customization of the sort function is more powerful than t=\r
+he compare function. In the case of saved searches I can imagine people mig=\r
+ht want to partially use the original order while sort the rest (e.g. impor=\r
+tant ones first in predefined order, others sorted). In fact this also allo=\r
+ws dropping out some elements. And renaming. And changing the queries...</p=\r
+>\r
+\r
+<p>(I had something like that in mind originally but then settled with just=\r
+ capitalizing the important ones to show them first.)</p>\r
+<p>BR,<br>\r
+Jani.</p>\r
+<p>&gt;<br>\r
+&gt; Regards,<br>\r
+&gt; =C2=A0Dmitry<br>\r
+&gt;<br>\r
+&gt; &gt; Cheers,<br>\r
+&gt; &gt; Daniel<br>\r
+&gt; _______________________________________________<br>\r
+&gt; notmuch mailing list<br>\r
+&gt; <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a>=\r
+<br>\r
+&gt; <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch">http://not=\r
+muchmail.org/mailman/listinfo/notmuch</a><br>\r
+</p>\r
+\r
+--047d7b33cc1e01282304ba8527e8--\r