Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function
authorDaniel Schoepe <daniel@schoepe.org>
Mon, 5 Mar 2012 11:17:43 +0000 (12:17 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:15 +0000 (09:45 -0800)
9f/f4917bcfd327264c2385ec6db8a8901ab277ff [new file with mode: 0644]

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