aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@postbox.nz>2023-09-22 20:59:29 +0000
committerRobin Jarry <robin@jarry.cc>2023-10-13 00:40:53 +0200
commitd2f92473b3d8e68aad8a7f3d3b3c6c194446713c (patch)
tree1781dbf8b1af0b45e8c074ffde19b5c09f838d1a
parent00ded54adde070723c665a1c5a589c3ee080b001 (diff)
downloadaerc-d2f92473b3d8e68aad8a7f3d3b3c6c194446713c.tar.gz
aerc-d2f92473b3d8e68aad8a7f3d3b3c6c194446713c.zip
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 <v@postbox.nz> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--CHANGELOG.md4
-rw-r--r--commands/account/sort.go1
-rw-r--r--doc/aerc.1.scd2
-rw-r--r--lib/sort/sort.go2
-rw-r--r--worker/lib/sort.go2
-rw-r--r--worker/types/sort.go1
6 files changed, 12 insertions, 0 deletions
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 {