On Mon, 04 Sep 2017, William Casarin <j...@jb55.com> wrote: > * add {from,subject}-{ascending,descending} sort options
The implementation seems simple enough, but what's the use case, really? When thinking about the usefulness of the feature, you have to think about what gets indexed for from: and subject: prefixes, and how they would get sorted. (See lib/index.cc for details.) From: J. Random Hacker <hac...@example.com> From: "Hacker, Random J." <hac...@example.com> From: hac...@example.com Subject: [notmuch] [PATCH 1/3] sorting Subject: [PATCH 1/3] sorting Subject: Re: [PATCH 1/3] sorting Subject: Vast: [PATCH 1/3] sorting With those in mind, does it still seem useful to sort by from or subject? If yes, consider thread sorting with some search terms, and all of the above present in a thread. The placement of a thread in the result list depends on which messages in the thread match the query. Even if the matching messages are supposedly the same. I'm not convinced. BR, Jani. > --- > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch