unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: William Casarin <jb55@jb55.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/3] sorting: add the ability to sort by from and subject
Date: Mon,  4 Sep 2017 09:00:38 -0700	[thread overview]
Message-ID: <20170904160040.23642-1-jb55@jb55.com> (raw)

* 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

             reply	other threads:[~2017-09-04 16:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04 16:00 William Casarin [this message]
2017-09-04 16:00 ` [PATCH 2/3] sorting: update ruby bindings for from and subject 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

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=20170904160040.23642-1-jb55@jb55.com \
    --to=jb55@jb55.com \
    --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).