From 8146fb01f7593fd6808cf841eef2e706c0863671 Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Tue, 6 Mar 2012 01:09:38 +0400 Subject: [PATCH] Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function --- 81/7f5151792e430c4044875578ccf721d2786f1f | 171 ++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 81/7f5151792e430c4044875578ccf721d2786f1f diff --git a/81/7f5151792e430c4044875578ccf721d2786f1f b/81/7f5151792e430c4044875578ccf721d2786f1f new file mode 100644 index 000000000..697baf0fb --- /dev/null +++ b/81/7f5151792e430c4044875578ccf721d2786f1f @@ -0,0 +1,171 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6E5B7431FAF + for ; Mon, 5 Mar 2012 13:11:10 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id hMnMqPMEMq1v for ; + Mon, 5 Mar 2012 13:11:09 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 86BB6431FAE + for ; Mon, 5 Mar 2012 13:11:09 -0800 (PST) +Received: by bkwj4 with SMTP id j4so4144258bkw.26 + for ; Mon, 05 Mar 2012 13:11:06 -0800 (PST) +Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com + designates 10.205.122.73 as permitted sender) + client-ip=10.205.122.73; +Authentication-Results: mr.google.com; spf=pass (google.com: domain of + dmitry.kurochkin@gmail.com designates 10.205.122.73 as + permitted sender) smtp.mail=dmitry.kurochkin@gmail.com; + dkim=pass header.i=dmitry.kurochkin@gmail.com +Received: from mr.google.com ([10.205.122.73]) + by 10.205.122.73 with SMTP id gf9mr10235481bkc.96.1330981866892 + (num_hops = 1); Mon, 05 Mar 2012 13:11:06 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:in-reply-to:references:user-agent:date + :message-id:mime-version:content-type; + bh=Q1wPuHcV5+7ZbPXPiz49g0ROLpnu91MX4H39d6QL/gg=; + b=kc9YNQBP5MHMR11G6Nia3Ft6U4+BlxC7RfGEcnGOK6KpMAPgNdoI5Wb0PkxW6zFvLE + iZrcxhCwNuxdv/JRunV2iqIv/vwtPfPVKD8n3BZQOVPVO8FWJ5Iu0+klHCP9rKDgBFg2 + KwbOJ6azaPxYRAAUR/msHAd+eGg5Md2zyuDNcKJnrBE3ozzZBjBUCA/fQ1BgRTOSHA4e + LPM9dNgUxS7VpBiuCoZWsilz3APTsTavdA0CESC0GdELyfdDFTB0vjg+MNDU2abeL+ga + vIHMUz9stm63uM5pcGaHhPImTE/qyHgvpZKlkV9fNGSsoVhL8BBt0lZ5oY43j8Ojpa2q + 5DAw== +Received: by 10.205.122.73 with SMTP id gf9mr8092294bkc.96.1330981866741; + Mon, 05 Mar 2012 13:11:06 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id x22sm27828976bkw.11.2012.03.05.13.11.05 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 05 Mar 2012 13:11:06 -0800 (PST) +From: Dmitry Kurochkin +To: Jani Nikula +Subject: Re: [PATCH v2] emacs: Pass a copy to + notmuch-saved-search-sort-function +In-Reply-To: + +References: <1330613059-5130-1-git-send-email-daniel@schoepe.org> + <1330613059-5130-2-git-send-email-daniel@schoepe.org> + +User-Agent: Notmuch/0.11.1+288~g4b3af0e (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Tue, 06 Mar 2012 01:09:38 +0400 +Message-ID: <87zkbukb59.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 05 Mar 2012 21:11:10 -0000 + +On Mon, 5 Mar 2012 22:55:54 +0200, Jani Nikula wrote: +> On Mar 5, 2012 5:43 PM, "Dmitry Kurochkin" +> wrote: +> > +> > On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe +> wrote: +> > > On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin < +> dmitry.kurochkin@gmail.com> wrote: +> > > > On Thu, 1 Mar 2012 21:24:38 +0100, Daniel Schoepe +> wrote: +> > > > > notmuch-saved-search-sort-function might destructively modify its +> > > > > input (`sort' does that, for instance), so it should not be given +> > > > > notmuch-saved-searches directly. +> > > > > --- +> > > > +> > > > -1 +> > > > +> > > > I think we should require `notmuch-saved-search-sort-function' not to +> > > > have side effects. Current documentation should be more clear about +> > > > this. We need to fix `notmuch-sort-saved-searches' to copy the list +> > > > before calling `sort'. But we should not do it in +> > > > `notmuch-hello-insert-saved-searches' for any sorting function (which +> > > > may not need this copying). +> > > +> > > My reasoning was that since sort is such a common function, many users +> > > will probably use sort for their own sorting functions, not realizing +> > > that it has side effects. This will lead to confusing behavior that's +> > > not so easy to track down. +> > > +> > > Copying the list of saved searches when running notmuch-hello does not +> > > seem be relevant to performance to me, since it's a) not called that +> > > often and b) the list of saved searches will rarely exceed 30 elements. +> > > +> > > Hence, this way we can avoid some headaches for users who define their +> > > own sorting functions at a negligible (performance) cost. Incidentally, +> > > this is also how notmuch-hello did it before the user-defined sections +> > > patches. +> > > +> > +> > I do not buy the argument that we should help users who implement their +> > own sorting functions but do not read documentation for functions they +> > use. Apparently, those who implemented the `sort' function had similar +> > ideas. And I do not think it is our job to add workarounds for it. +> > +> > An alternative (and IMO better) solution would be to allow customization +> > of compare function used for sorting instead of the sorting function +> > itself. +> +> Providing the customization of the sort function is more powerful than the +> compare function. In the case of saved searches I can imagine people might +> want to partially use the original order while sort the rest (e.g. +> important ones first in predefined order, others sorted). + +Valid point. + +> In fact this also +> allows dropping out some elements. And renaming. And changing the queries... +> +> (I had something like that in mind originally but then settled with just +> capitalizing the important ones to show them first.) +> + +All of these are invalid usages of `notmuch-saved-search-sort-function'. +The function is meant for sorting only (hence the name). So the code +might assume that the function does only sorting. + +I do not understand why we need such functionality (renaming, +capitalizing, etc.). You can just rename the query itself if you want +to. Should be easier IMO. But if we need such functionality, we should +not misuse sorting function for it. We can add `notmuch-saved-searches' +function which would return saved searches list (sorted, renamed and +mangled in any other way). By default it would return +`notmuch-saved-searches' variable as is. + +Regards, + Dmitry + +> BR, +> Jani. +> +> > +> > Regards, +> > Dmitry +> > +> > > Cheers, +> > > Daniel +> > _______________________________________________ +> > notmuch mailing list +> > notmuch@notmuchmail.org +> > http://notmuchmail.org/mailman/listinfo/notmuch +Non-text part: text/html -- 2.26.2