1 Return-Path: <tomi.ollila@iki.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 4502A431FBC
\r
6 for <notmuch@notmuchmail.org>; Mon, 5 Mar 2012 07:23:23 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 8cva7FRuGbw1 for <notmuch@notmuchmail.org>;
\r
16 Mon, 5 Mar 2012 07:23:22 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])
\r
18 by olra.theworths.org (Postfix) with ESMTP id EF853431FAE
\r
19 for <notmuch@notmuchmail.org>; Mon, 5 Mar 2012 07:23:21 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 64C0768055; Mon, 5 Mar 2012 17:23:20 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: Daniel Schoepe <daniel@schoepe.org>,
\r
24 Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH v2] emacs: Pass a copy to
\r
26 notmuch-saved-search-sort-function
\r
27 In-Reply-To: <87399n2t60.fsf@schoepe.localhost>
\r
28 References: <1330613059-5130-1-git-send-email-daniel@schoepe.org>
\r
29 <1330633478-1974-1-git-send-email-daniel@schoepe.org>
\r
30 <1330633478-1974-2-git-send-email-daniel@schoepe.org>
\r
31 <87booblrcv.fsf@gmail.com> <87399n2t60.fsf@schoepe.localhost>
\r
32 User-Agent: Notmuch/0.11.1+288~g4b3af0e (http://notmuchmail.org) Emacs/23.3.1
\r
33 (x86_64-unknown-linux-gnu)
\r
34 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
35 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
36 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
37 Date: Mon, 05 Mar 2012 17:23:20 +0200
\r
38 Message-ID: <m24nu33wd3.fsf@guru.guru-group.fi>
\r
40 Content-Type: text/plain; charset=us-ascii
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Mon, 05 Mar 2012 15:23:23 -0000
\r
55 On Mon, 05 Mar 2012 12:17:43 +0100, Daniel Schoepe <daniel@schoepe.org> wrote:
\r
56 > On Mon, 05 Mar 2012 06:21:52 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
57 > > On Thu, 1 Mar 2012 21:24:38 +0100, Daniel Schoepe <daniel@schoepe.org> wrote:
\r
58 > > > notmuch-saved-search-sort-function might destructively modify its
\r
59 > > > input (`sort' does that, for instance), so it should not be given
\r
60 > > > notmuch-saved-searches directly.
\r
65 > > I think we should require `notmuch-saved-search-sort-function' not to
\r
66 > > have side effects. Current documentation should be more clear about
\r
67 > > this. We need to fix `notmuch-sort-saved-searches' to copy the list
\r
68 > > before calling `sort'. But we should not do it in
\r
69 > > `notmuch-hello-insert-saved-searches' for any sorting function (which
\r
70 > > may not need this copying).
\r
72 > My reasoning was that since sort is such a common function, many users
\r
73 > will probably use sort for their own sorting functions, not realizing
\r
74 > that it has side effects. This will lead to confusing behavior that's
\r
75 > not so easy to track down.
\r
77 > Copying the list of saved searches when running notmuch-hello does not
\r
78 > seem be relevant to performance to me, since it's a) not called that
\r
79 > often and b) the list of saved searches will rarely exceed 30 elements.
\r
81 > Hence, this way we can avoid some headaches for users who define their
\r
82 > own sorting functions at a negligible (performance) cost. Incidentally,
\r
83 > this is also how notmuch-hello did it before the user-defined sections
\r
86 Hard to say -- maybe the alternative:
\r
88 (defun notmuch-sort-saved-searches (alist)
\r
89 "Generate an alphabetically sorted saved searches alist."
\r
90 - (sort alist (lambda (a b) (string< (car a) (car b)))))
\r
91 + (sort (copy-sequence alist) (lambda (a b) (string< (car a) (car b)))))
\r
93 matches better with the current documentation
\r
94 (of notmuch-saved-search-sort-function).
\r
96 Both sort and copy-sequence are blazingly fast...
\r
98 For more information, read
\r
99 http://www.emacswiki.org/emacs/DestructiveOperations
\r