Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Mon, 5 Mar 2012 21:09:38 +0000 (01:09 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:15 +0000 (09:45 -0800)
81/7f5151792e430c4044875578ccf721d2786f1f [new file with mode: 0644]

diff --git a/81/7f5151792e430c4044875578ccf721d2786f1f b/81/7f5151792e430c4044875578ccf721d2786f1f
new file mode 100644 (file)
index 0000000..697baf0
--- /dev/null
@@ -0,0 +1,171 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\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 6E5B7431FAF\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 13:11:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=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 hMnMqPMEMq1v for <notmuch@notmuchmail.org>;\r
+       Mon,  5 Mar 2012 13:11:09 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 86BB6431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 13:11:09 -0800 (PST)\r
+Received: by bkwj4 with SMTP id j4so4144258bkw.26\r
+       for <notmuch@notmuchmail.org>; Mon, 05 Mar 2012 13:11:06 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com\r
+       designates 10.205.122.73 as permitted sender)\r
+       client-ip=10.205.122.73; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+       dmitry.kurochkin@gmail.com designates 10.205.122.73 as\r
+       permitted sender) smtp.mail=dmitry.kurochkin@gmail.com;\r
+       dkim=pass header.i=dmitry.kurochkin@gmail.com\r
+Received: from mr.google.com ([10.205.122.73])\r
+       by 10.205.122.73 with SMTP id gf9mr10235481bkc.96.1330981866892\r
+       (num_hops = 1); Mon, 05 Mar 2012 13:11:06 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+       :message-id:mime-version:content-type;\r
+       bh=Q1wPuHcV5+7ZbPXPiz49g0ROLpnu91MX4H39d6QL/gg=;\r
+       b=kc9YNQBP5MHMR11G6Nia3Ft6U4+BlxC7RfGEcnGOK6KpMAPgNdoI5Wb0PkxW6zFvLE\r
+       iZrcxhCwNuxdv/JRunV2iqIv/vwtPfPVKD8n3BZQOVPVO8FWJ5Iu0+klHCP9rKDgBFg2\r
+       KwbOJ6azaPxYRAAUR/msHAd+eGg5Md2zyuDNcKJnrBE3ozzZBjBUCA/fQ1BgRTOSHA4e\r
+       LPM9dNgUxS7VpBiuCoZWsilz3APTsTavdA0CESC0GdELyfdDFTB0vjg+MNDU2abeL+ga\r
+       vIHMUz9stm63uM5pcGaHhPImTE/qyHgvpZKlkV9fNGSsoVhL8BBt0lZ5oY43j8Ojpa2q\r
+       5DAw==\r
+Received: by 10.205.122.73 with SMTP id gf9mr8092294bkc.96.1330981866741;\r
+       Mon, 05 Mar 2012 13:11:06 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id x22sm27828976bkw.11.2012.03.05.13.11.05\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 05 Mar 2012 13:11:06 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH v2] emacs: Pass a copy to\r
+       notmuch-saved-search-sort-function\r
+In-Reply-To:\r
+ <CAB+hUn-iQbXq_UDcj97h2Duq=gJdxpiJjOn6YzmVcZw+GEgK0A@mail.gmail.com>\r
+References: <1330613059-5130-1-git-send-email-daniel@schoepe.org>\r
+       <1330613059-5130-2-git-send-email-daniel@schoepe.org>\r
+       <CAB+hUn-iQbXq_UDcj97h2Duq=gJdxpiJjOn6YzmVcZw+GEgK0A@mail.gmail.com>\r
+User-Agent: Notmuch/0.11.1+288~g4b3af0e (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 06 Mar 2012 01:09:38 +0400\r
+Message-ID: <87zkbukb59.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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 21:11:10 -0000\r
+\r
+On Mon, 5 Mar 2012 22:55:54 +0200, Jani Nikula <jani@nikula.org> wrote:\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).\r
+\r
+Valid point.\r
+\r
+> 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
+\r
+All of these are invalid usages of `notmuch-saved-search-sort-function'.\r
+The function is meant for sorting only (hence the name).  So the code\r
+might assume that the function does only sorting.\r
+\r
+I do not understand why we need such functionality (renaming,\r
+capitalizing, etc.).  You can just rename the query itself if you want\r
+to.  Should be easier IMO.  But if we need such functionality, we should\r
+not misuse sorting function for it.  We can add `notmuch-saved-searches'\r
+function which would return saved searches list (sorted, renamed and\r
+mangled in any other way).  By default it would return\r
+`notmuch-saved-searches' variable as is.\r
+\r
+Regards,\r
+  Dmitry\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
+Non-text part: text/html\r