unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] sorting: add the ability to sort by from and subject
@ 2017-09-04 16:00 William Casarin
  2017-09-04 16:00 ` [PATCH 2/3] sorting: update ruby bindings for " William Casarin
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: William Casarin @ 2017-09-04 16:00 UTC (permalink / raw)
  To: notmuch

* add {from,subject}-{ascending,descending} sort options
---
I'm not sure if we want to eventually refactor ascending and descending
into a separate option, but I decided to keep it this way for now.

 lib/notmuch.h    | 16 ++++++++++++++++
 lib/query.cc     | 12 ++++++++++++
 notmuch-search.c |  4 ++++
 3 files changed, 32 insertions(+)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index 66ecb5fc..f5764683 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -764,6 +764,22 @@ typedef enum {
      */
     NOTMUCH_SORT_NEWEST_FIRST,
     /**
+     * Sort by from: in ascending order
+     */
+    NOTMUCH_SORT_FROM_ASC,
+    /**
+     * Sort by from: in descending order
+     */
+    NOTMUCH_SORT_FROM_DESC,
+    /**
+     * Sort by subject: in ascending order
+     */
+    NOTMUCH_SORT_SUBJECT_ASC,
+    /**
+     * Sort by subject: in descending order
+     */
+    NOTMUCH_SORT_SUBJECT_DESC,
+    /**
      * Sort by message-id.
      */
     NOTMUCH_SORT_MESSAGE_ID,
diff --git a/lib/query.cc b/lib/query.cc
index 9c6ecc8d..106814a8 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -327,6 +327,18 @@ _notmuch_query_search_documents (notmuch_query_t *query,
 	case NOTMUCH_SORT_NEWEST_FIRST:
 	    enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, TRUE);
 	    break;
+	case NOTMUCH_SORT_FROM_ASC:
+	    enquire.set_sort_by_value (NOTMUCH_VALUE_FROM, FALSE);
+	    break;
+	case NOTMUCH_SORT_FROM_DESC:
+	    enquire.set_sort_by_value (NOTMUCH_VALUE_FROM, TRUE);
+	    break;
+	case NOTMUCH_SORT_SUBJECT_ASC:
+	    enquire.set_sort_by_value (NOTMUCH_VALUE_SUBJECT, FALSE);
+	    break;
+	case NOTMUCH_SORT_SUBJECT_DESC:
+	    enquire.set_sort_by_value (NOTMUCH_VALUE_SUBJECT, TRUE);
+	    break;
 	case NOTMUCH_SORT_MESSAGE_ID:
 	    enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE);
 	    break;
diff --git a/notmuch-search.c b/notmuch-search.c
index 380e9d8f..b80647e9 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -789,6 +789,10 @@ static const notmuch_opt_desc_t common_options[] = {
     { NOTMUCH_OPT_KEYWORD, &search_context.sort, "sort", 's',
       (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
 			      { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+			      { "from-ascending", NOTMUCH_SORT_FROM_ASC },
+			      { "from-descending", NOTMUCH_SORT_FROM_DESC },
+			      { "subject-ascending", NOTMUCH_SORT_SUBJECT_ASC },
+			      { "subject-descending", NOTMUCH_SORT_SUBJECT_DESC },
 			      { 0, 0 } } },
     { NOTMUCH_OPT_KEYWORD, &search_context.format_sel, "format", 'f',
       (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
-- 
2.13.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-09-10  1:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-04 16:00 [PATCH 1/3] sorting: add the ability to sort by from and subject William Casarin
2017-09-04 16:00 ` [PATCH 2/3] sorting: update ruby bindings for " William Casarin
2017-09-04 16:00 ` [PATCH 3/3] sorting: update man page William Casarin
2017-09-04 19:04 ` [PATCH 1/3] sorting: add the ability to sort by from and subject Jani Nikula
     [not found]   ` <87wp5ew7v6.fsf@jb55.com>
2017-09-04 20:33     ` William Casarin
2017-09-04 22:02       ` David Bremner
2017-09-07 19:42         ` William Casarin
2017-09-10  0:17           ` [PATCH] emacs: replace oldest-first with sort-order William Casarin
2017-09-10  0:35             ` [PATCH v2] " William Casarin
2017-09-10  1:21               ` William Casarin

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).