From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id B9D086DE0C97 for ; Mon, 25 Sep 2017 22:36:45 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.012 X-Spam-Level: X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5 tests=[AWL=0.097, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FSL_HELO_NON_FQDN_1=0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BEBp1D8wPe6z for ; Mon, 25 Sep 2017 22:36:45 -0700 (PDT) Received: from charon (jb55.com [45.79.91.128]) by arlo.cworth.org (Postfix) with ESMTPS id 856F16DE0C6B; Mon, 25 Sep 2017 22:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d= jb55.com; h=from:to:subject:date:message-id; s=default; bh=bjHcPjCTA/QDCDHTAzUGuUTfu49HTOy7VSNbtejXYl8=; b=gZ/pHLFcurk3KcvWrW7s62T+99HIjVGoJiPYBTVXNJKcmEW/utjciz5/Grw2quri+wPk7ohMIc0xNlYRxpO3YzJLnq1U8oRRP2ms+F9hBov0QxYU2Nj7LosxVm5/go0nOUG3H68q32ks6MVIkdTIablobNxlT94IeT0LXTRtTcCMi3qLyP9PVFEKOT8SGdUZnHLKbfjBn7+xFDxtvRHQPR2iUFPIl5BG7uU0IVfLLb3W09dilxj430ymJyoTdbqkM7xyErQnYKQUkD1cRibWxgWL1GmXvj/wYk+/+fEzfO5vId8Q1yDHF0kiWm90rLHoptsm/wBrDoqT9AbjqSP7Fg== Received: from jb55.com (70-36-49-138.dyn.novuscom.net [70.36.49.138]) by jb55.com (OpenSMTPD) with ESMTPSA id 6003a0ee TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Tue, 26 Sep 2017 05:36:42 +0000 (UTC) From: William Casarin To: notmuch@notmuchmail.org Subject: [PATCH 1/6] sorting: add the ability to sort by from and subject Date: Mon, 25 Sep 2017 22:35:42 -0700 Message-Id: <20170926053547.18564-2-jb55@jb55.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170926053547.18564-1-jb55@jb55.com> References: <20170926053547.18564-1-jb55@jb55.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2017 05:36:45 -0000 * add {from,subject}-{ascending,descending} sort options --- 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 f26565f3..071bfe4d 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -765,6 +765,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