notmuch-vim icon indicating copy to clipboard operation
notmuch-vim copied to clipboard

Configurable sort order when displaying search results

Open rseichter opened this issue 2 years ago • 4 comments

search_render() currently uses the hardcoded Notmuch::SORT_NEWEST_FIRST. I think it would be nice to make the sort order configurable for the end user, ideally on a per-search-basis. This would for example allow sorting messages tagged "inbox" oldest first, an those tagged "someothertag" newest first.

rseichter avatar Apr 19 '23 06:04 rseichter

We could create some kind of meta-search-term like sort:oldest-first, but then we would need to make sure it's parsed correctly everywhere and removed before sending it to libnotmuch.

Does that sound like a reasonable solution?

felipec avatar Apr 24 '23 19:04 felipec

Thanks for considering my suggestion. To make sure I understand your approach: Where would these meta-search-terms be specified by the end user, and how would they be mapped to particular searches?

rseichter avatar Apr 25 '23 01:04 rseichter

For example something like this:

let g:notmuch_folders = [
	\ [ 'lkml', 'tag:inbox and folder:lkml/ sort:newest-first' ],
	\ [ 'to-do', 'tag:to-do sort:oldest-first' ],
	\ ]

felipec avatar May 02 '23 20:05 felipec

Looks reasonable to me. Additionally, I suggest adding a configuration option for the default sorting order, for convenience.

rseichter avatar May 03 '23 04:05 rseichter