From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] nmbug-status: add support for specifying sort order for each view
Date: Fri, 3 Apr 2015 10:57:12 +0300 [thread overview]
Message-ID: <1428047832-14922-1-git-send-email-jani@nikula.org> (raw)
Let each view have "sort" key with possible values "oldest-first",
"newest-first", and "unsorted", and sort the results
accordingly. Oldest first remains the default.
---
devel/nmbug/nmbug-status | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 19dc48abf557..e1abf4db15ba 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -156,11 +156,19 @@ class Page (object):
stream.write(self.footer)
def _write_view(self, database, view, stream):
+ sort = {
+ 'oldest-first': notmuch.Query.SORT.OLDEST_FIRST,
+ 'newest-first': notmuch.Query.SORT.NEWEST_FIRST,
+ 'unsorted': notmuch.Query.SORT.UNSORTED
+ }
if 'query-string' not in view:
query = view['query']
view['query-string'] = ' and '.join(query)
q = notmuch.Query(database, view['query-string'])
- q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
+ if 'sort' in view and view['sort'] in sort:
+ q.set_sort(sort[view['sort']])
+ else:
+ q.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
threads = self._get_threads(messages=q.search_messages())
self._write_view_header(view=view, stream=stream)
self._write_threads(threads=threads, stream=stream)
--
2.1.4
next reply other threads:[~2015-04-03 21:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 7:57 Jani Nikula [this message]
2015-04-06 11:43 ` [PATCH] nmbug-status: add support for specifying sort order for each view Tomi Ollila
2015-04-06 15:56 ` W. Trevor King
2015-04-06 16:48 ` Tomi Ollila
2015-09-26 11:37 ` [PATCH v2] " Jani Nikula
2015-09-26 18:47 ` W. Trevor King
2015-09-29 11:27 ` David Bremner
2015-09-29 18:58 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428047832-14922-1-git-send-email-jani@nikula.org \
--to=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).