Re: [PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function
authorTomi Ollila <tomi.ollila@iki.fi>
Mon, 5 Mar 2012 15:23:20 +0000 (17:23 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:15 +0000 (09:45 -0800)
91/bec31f91e3525f2491b7a6248d7f18398848e7 [new file with mode: 0644]

diff --git a/91/bec31f91e3525f2491b7a6248d7f18398848e7 b/91/bec31f91e3525f2491b7a6248d7f18398848e7
new file mode 100644 (file)
index 0000000..0b4b2a0
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <tomi.ollila@iki.fi>\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 4502A431FBC\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 07:23:23 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 8cva7FRuGbw1 for <notmuch@notmuchmail.org>;\r
+       Mon,  5 Mar 2012 07:23:22 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
+       by olra.theworths.org (Postfix) with ESMTP id EF853431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  5 Mar 2012 07:23:21 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 64C0768055; Mon,  5 Mar 2012 17:23:20 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Daniel Schoepe <daniel@schoepe.org>,\r
+       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: <87399n2t60.fsf@schoepe.localhost>\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> <87399n2t60.fsf@schoepe.localhost>\r
+User-Agent: Notmuch/0.11.1+288~g4b3af0e (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 05 Mar 2012 17:23:20 +0200\r
+Message-ID: <m24nu33wd3.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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 15:23:23 -0000\r
+\r
+On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe <daniel@schoepe.org> wrote:\r
+> On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> > On Thu,  1 Mar 2012 21:24:38 +0100, Daniel Schoepe <daniel@schoepe.org> 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
+Hard to say -- maybe the alternative:\r
+\r
+ (defun notmuch-sort-saved-searches (alist)\r
+   "Generate an alphabetically sorted saved searches alist."\r
+-  (sort alist (lambda (a b) (string< (car a) (car b)))))\r
++  (sort (copy-sequence alist) (lambda (a b) (string< (car a) (car b)))))\r
+\r
+matches better with the current documentation \r
+(of notmuch-saved-search-sort-function).\r
+\r
+Both sort and copy-sequence are blazingly fast...\r
+\r
+For more information, read\r
+http://www.emacswiki.org/emacs/DestructiveOperations\r
+\r
+> Cheers,\r
+> Daniel\r
+\r
+Tomi\r