From: Daniel Schoepe Date: Mon, 5 Mar 2012 11:17:43 +0000 (+0100) Subject: Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7414b44b064dfbaf0a6db03846a452c50d9a1dd0;p=notmuch-archives.git Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function --- diff --git a/9f/f4917bcfd327264c2385ec6db8a8901ab277ff b/9f/f4917bcfd327264c2385ec6db8a8901ab277ff new file mode 100644 index 000000000..811fe629f --- /dev/null +++ b/9f/f4917bcfd327264c2385ec6db8a8901ab277ff @@ -0,0 +1,140 @@ +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 F2672431FBC + for ; Mon, 5 Mar 2012 03:17:55 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.8 +X-Spam-Level: +X-Spam-Status: No, score=-0.8 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + 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 sGCS-OhSGvAU for ; + Mon, 5 Mar 2012 03:17:55 -0800 (PST) +Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com + [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DEAA2431FAE + for ; Mon, 5 Mar 2012 03:17:54 -0800 (PST) +Received: by eaa1 with SMTP id 1so1934172eaa.26 + for ; Mon, 05 Mar 2012 03:17:53 -0800 (PST) +Received-SPF: pass (google.com: domain of daniel@schoepe.org designates + 10.14.200.132 as permitted sender) client-ip=10.14.200.132; +Authentication-Results: mr.google.com; + spf=pass (google.com: domain of daniel@schoepe.org + designates 10.14.200.132 as permitted sender) + smtp.mail=daniel@schoepe.org; + dkim=pass header.i=daniel@schoepe.org +Received: from mr.google.com ([10.14.200.132]) + by 10.14.200.132 with SMTP id z4mr11058657een.122.1330946273634 + (num_hops = 1); Mon, 05 Mar 2012 03:17:53 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schoepe.org; s=google; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=TNVaYUw/KRvzuOfAuR98uI98faZiW9jcMiGvlWWYgOs=; + b=QelIH3apG5ANm8VgXwAdxlfM8/X7Grvx8dDpA5X8/HxyWBlC7MrWbkIOmbX75wJYAd + 0F4ha5cX9fS0JlXZ6coKXC5Q/7h8+ow8ITGTjDMpupgYQtFSVGBBIJmX3xjk17mclfLK + I+hexbRxHAacz2m7OH/OkiRh4jQvJOSxCYetY= +Received: by 10.14.200.132 with SMTP id z4mr8376564een.122.1330946273521; + Mon, 05 Mar 2012 03:17:53 -0800 (PST) +Received: from localhost (dslb-088-069-139-015.pools.arcor-ip.net. + [88.69.139.15]) + by mx.google.com with ESMTPS id v51sm60569269eef.2.2012.03.05.03.17.51 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 05 Mar 2012 03:17:52 -0800 (PST) +From: Daniel Schoepe +To: Dmitry Kurochkin , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] emacs: Pass a copy to + notmuch-saved-search-sort-function +In-Reply-To: <87booblrcv.fsf@gmail.com> +References: <1330613059-5130-1-git-send-email-daniel@schoepe.org> + <1330633478-1974-1-git-send-email-daniel@schoepe.org> + <1330633478-1974-2-git-send-email-daniel@schoepe.org> + <87booblrcv.fsf@gmail.com> +User-Agent: Notmuch/0.11.1+212~gcd799cb (http://notmuchmail.org) + Emacs/24.0.93.1 (x86_64-pc-linux-gnu) +Date: Mon, 05 Mar 2012 12:17:43 +0100 +Message-ID: <87399n2t60.fsf@schoepe.localhost> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha1; protocol="application/pgp-signature" +X-Gm-Message-State: + ALoCoQmidj6oU4mCSVbqoNVHCZj7hSlym6QzG/Z2rQ6OeujXqlAfPAqoPFbl/8NdFd+bXPFOEy8Z +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 11:17:56 -0000 + +--=-=-= +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin wrote: +> On Thu, 1 Mar 2012 21:24:38 +0100, Daniel Schoepe w= +rote: +> > 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. +> > --- +>=20 +> -1 +>=20 +> 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. + +Cheers, +Daniel + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iQIcBAEBAgAGBQJPVKDXAAoJEIaTAtce+Z+JExkP/iM8DDMQ/QXJZzH/XTTvajXI +cv1R0tG5gNfy88j+8Oy206ysSn9QO3ajUMZol3N7ZxBquHt1rvrwsKlkYgdi7DX0 +iPAw+fiutzEmCoac4kl2Tz0Boy8TXPEb47ZcnW8W6QdNxt0BOKX0fbg/dRgiYMVF +s1TiyHyU+OnB7bIiUReum4F5VNN9bTxSD7vB/L+ciVEs1hGorBvPjBeDcr1hGsF6 +bmZXoKduNY8IX4hDXGTqEwieHmL7vzSHPdQzfkfjpcc+hOYAXOsTx6ht2pDS1JSa +ko/by737i17Iyfz4ut7+q86H5YX00C3WmfIY6X5dIYgBADgQWkgGz6HRvYlkddIO +G0zoqM5cQoif3MuRx/7i8MXGTnYTyXcYqbYDRz0OKyKIACMtiAJpVuwxqAEQu/Un +FCqFmb1wGkCWYsY5LTCCPX1HrVnfmjFk5AzWmrRxE6DCSG5u9OSYlMmx+ddzohjN +Nr3IfzPt9LmNxBZDamjk1103w+ZMckymHz6+XSux3gUi3xtRh17gj+eXrF4/Y/bD +Sud2awOe0IRVpAF4+qsPTd+5fTUzSRVaV6ewOLRO1EBf2xeSRSBuLREVCmp51qak +XB97KFOdhUd80PXZw7KY38EF4xJRZtdNXU8U3di6thhSGZX17uNVNbI6kPl/dzHX +k5/3iYRNe3TudrKxej+W +=VdWI +-----END PGP SIGNATURE----- +--=-=-=--