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 arlo.cworth.org (Postfix) with ESMTP id 59A066DE1A5E
\r
6 for <notmuch@notmuchmail.org>; Mon, 6 Apr 2015 09:48:37 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=1.202 tagged_above=-999 required=5 tests=[AWL=0.550,
\r
12 SPF_NEUTRAL=0.652] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 1Umx1Eyd6W-W for <notmuch@notmuchmail.org>;
\r
16 Mon, 6 Apr 2015 09:48:33 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id 96A5A6DE1A34
\r
19 for <notmuch@notmuchmail.org>; Mon, 6 Apr 2015 09:48:33 -0700 (PDT)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id E347910019F;
\r
22 Mon, 6 Apr 2015 19:48:09 +0300 (EEST)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: "W. Trevor King" <wking@tremily.us>
\r
25 Subject: Re: [PATCH] nmbug-status: add support for specifying sort order for
\r
27 In-Reply-To: <20150406155659.GS10467@odin.tremily.us>
\r
28 References: <20150406155659.GS10467@odin.tremily.us>
\r
29 User-Agent: Notmuch/0.19+107~gab55bdb (http://notmuchmail.org) Emacs/24.3.1
\r
30 (x86_64-unknown-linux-gnu)
\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
32 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
33 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
34 Date: Mon, 06 Apr 2015 19:48:09 +0300
\r
35 Message-ID: <m2r3rx9p9y.fsf@guru.guru-group.fi>
\r
37 Content-Type: text/plain
\r
38 Cc: notmuch@notmuchmail.org
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.18
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Mon, 06 Apr 2015 16:48:37 -0000
\r
53 On Mon, Apr 06 2015, "W. Trevor King" <wking@tremily.us> wrote:
\r
55 > On Fri, Apr 03 2015, Jani Nikula <jani@nikula.org> wrote:
\r
56 >> Let each view have "sort" key with possible values "oldest-first",
\r
57 >> "newest-first", and "unsorted", and sort the results
\r
58 >> accordingly. Oldest first remains the default.
\r
60 > I like it, but have a few suggestions to tweak the implementation.
\r
62 >> def _write_view(self, database, view, stream):
\r
64 >> + 'oldest-first': notmuch.Query.SORT.OLDEST_FIRST,
\r
65 >> + 'newest-first': notmuch.Query.SORT.NEWEST_FIRST,
\r
66 >> + 'unsorted': notmuch.Query.SORT.UNSORTED
\r
69 > I'd rather have this mapping defined in a global variable
\r
70 > (_SORT_TERMS?) or a class-wide attribute (Page.sort_terms?).
\r
71 > Alternatively, you could do something dynamic like:
\r
73 > sort_key = view.get('sort', 'oldest-first')
\r
74 > sort_attribute = sort_key.upper().replace('-', '_'))
\r
76 > sort = getattr(notmuch.Query.SORT, sort_attribute)
\r
77 > except AttributeError:
\r
78 > raise ConfigError('Invalid setting for {}: {!r}'.format(
\r
79 > view['title'], sort_key))
\r
81 > which would automatically keep the implementation in sync with the
\r
82 > available values in notmuch.Query.SORT.
\r
84 I like how this suggestion looks like.
\r
89 >> - q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
\r
90 >> + if 'sort' in view and view['sort'] in sort:
\r
91 >> + q.set_sort(sort[view['sort']])
\r
93 >> + q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
\r
95 > Instead of silently falling back to oldest-first if the requested
\r
96 > sort-key isn't available, I think we should be raising ConfigError so
\r
97 > the user knows they need to update their config.
\r
103 > This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
\r
104 > For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
\r