From d2f92473b3d8e68aad8a7f3d3b3c6c194446713c Mon Sep 17 00:00:00 2001 From: Vitaly Ovchinnikov Date: Fri, 22 Sep 2023 20:59:29 +0000 Subject: sort: new `flagged` sorting criteria Add new `flagged` criteria to `:sort` command (and apparently to the `sort` config option). Good for moving important stuff up. Signed-off-by: Vitaly Ovchinnikov Reviewed-by: Koni Marti Acked-by: Robin Jarry --- CHANGELOG.md | 4 ++++ commands/account/sort.go | 1 + doc/aerc.1.scd | 2 ++ lib/sort/sort.go | 2 ++ worker/lib/sort.go | 2 ++ worker/types/sort.go | 1 + 6 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f97738c..df55324e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased](https://git.sr.ht/~rjarry/aerc/log/master) +### Added + +- New `flagged` criteria for `:sort` + ### Fixed - `colorize` styles can include wildcards `?` and `*` diff --git a/commands/account/sort.go b/commands/account/sort.go index a7edd552..d9eaf16a 100644 --- a/commands/account/sort.go +++ b/commands/account/sort.go @@ -31,6 +31,7 @@ func (Sort) Complete(args []string) []string { "size", "subject", "to", + "flagged", } if len(args) == 0 { return supportedCriteria diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index 40cda9a1..e51ae8d1 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -491,6 +491,8 @@ message list, the message in the message viewer, etc). :- Addresses in the From field | _read_ :- Presence of the read flag +| _flagged_ +:- Presence of the flagged flag | _size_ :- Size of the message | _subject_ diff --git a/lib/sort/sort.go b/lib/sort/sort.go index 287f986c..082ba48b 100644 --- a/lib/sort/sort.go +++ b/lib/sort/sort.go @@ -51,6 +51,8 @@ func parseSortField(arg string) (types.SortField, error) { return types.SortSubject, nil case "to": return types.SortTo, nil + case "flagged": + return types.SortFlagged, nil default: return types.SortArrival, fmt.Errorf("%v is not a valid sort criterion", arg) } diff --git a/worker/lib/sort.go b/worker/lib/sort.go index 2828999c..7af2c6fa 100644 --- a/worker/lib/sort.go +++ b/worker/lib/sort.go @@ -36,6 +36,8 @@ func Sort(messageInfos []*models.MessageInfo, }) case types.SortRead: sortFlags(messageInfos, criterion, models.SeenFlag) + case types.SortFlagged: + sortFlags(messageInfos, criterion, models.FlaggedFlag) case types.SortSize: sortSlice(criterion, messageInfos, func(i, j int) bool { return messageInfos[i].Size < messageInfos[j].Size diff --git a/worker/types/sort.go b/worker/types/sort.go index ffbcf463..39f99abb 100644 --- a/worker/types/sort.go +++ b/worker/types/sort.go @@ -11,6 +11,7 @@ const ( SortSize SortSubject SortTo + SortFlagged ) type SortCriterion struct { -- cgit v1.2.3-54-g00ecf