aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-17 12:34:23 -0500
committerRobin Jarry <robin@jarry.cc>2024-02-26 09:30:35 +0100
commitf3a61a341c81d70b51d91a71e1b0909acdcdb8f4 (patch)
tree58a3156dc63500fd4e0cd0034a59e86cdbb6a3cb /app
parentd8d5fc8d31f358c6425dfa18a9f8d2767bc6df40 (diff)
downloadaerc-f3a61a341c81d70b51d91a71e1b0909acdcdb8f4.tar.gz
aerc-f3a61a341c81d70b51d91a71e1b0909acdcdb8f4.zip
commands: add :query to create named notmuch dirs
The current :cf command can be used to create folders for arbitrary notmuch queries. These folders use the query as their namee. In some cases, though, it's useful to give a more human-readable name. Create a new :query command to allow doing so. The :query command accepts an optional -n flag to specify a name. The remaining arguments are interpreted verbatim as a notmuch query. If no name is specified, the query itself is used as the name. For example, to create a new folder with the full thread of the current message, named by its subject, run the following command: :query -n "{{.SubjectBase}}" thread:"{mid:{{.MessageId}}}" :query could have been implemented as an additional flag to :cf. Giving a name to the created folder would make the smantics of :cf strange, though. For example, to create a named query folder, one would use :cf -n <name> <query>. This syntax feels odd; the name of the folder seems like it ought to be the positional argument of the change folder command. Alternatively, the usage could be :cf -q <query> <name>, but this feels wrong as well: the query, which is provided as a positional parameter when no name is specified, becomes a flag parameter when a name is specified. What's more, both of these potential usages add a notmuch-specific flag to an otherwise general command. Creating a new command feels cleaner. Perhaps the current query functionality of the :cf command could eventually be deprecated to remove the duplicate functionality and keep :cf limited to changing to existing folders. Changelog-added: Create notmuch named queries with the `:query` command. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app')
-rw-r--r--app/dirlist.go7
-rw-r--r--app/dirtree.go6
2 files changed, 7 insertions, 6 deletions
diff --git a/app/dirlist.go b/app/dirlist.go
index 898b8130..1fc2dd63 100644
--- a/app/dirlist.go
+++ b/app/dirlist.go
@@ -24,7 +24,7 @@ type DirectoryLister interface {
Selected() string
Select(string)
- Open(string, time.Duration, func(types.WorkerMessage))
+ Open(string, string, time.Duration, func(types.WorkerMessage))
Update(types.WorkerMessage)
List() []string
@@ -175,10 +175,10 @@ func (dirlist *DirectoryList) ExpandFolder() {
}
func (dirlist *DirectoryList) Select(name string) {
- dirlist.Open(name, dirlist.UiConfig(name).DirListDelay, nil)
+ dirlist.Open(name, "", dirlist.UiConfig(name).DirListDelay, nil)
}
-func (dirlist *DirectoryList) Open(name string, delay time.Duration,
+func (dirlist *DirectoryList) Open(name string, query string, delay time.Duration,
cb func(types.WorkerMessage),
) {
dirlist.selecting = name
@@ -193,6 +193,7 @@ func (dirlist *DirectoryList) Open(name string, delay time.Duration,
dirlist.worker.PostAction(&types.OpenDirectory{
Context: ctx,
Directory: name,
+ Query: query,
},
func(msg types.WorkerMessage) {
switch msg := msg.(type) {
diff --git a/app/dirtree.go b/app/dirtree.go
index 53ab4aad..b735dacd 100644
--- a/app/dirtree.go
+++ b/app/dirtree.go
@@ -239,10 +239,10 @@ func (dt *DirectoryTree) Select(name string) {
if name == "" {
return
}
- dt.Open(name, dt.UiConfig(name).DirListDelay, nil)
+ dt.Open(name, "", dt.UiConfig(name).DirListDelay, nil)
}
-func (dt *DirectoryTree) Open(name string, delay time.Duration, cb func(types.WorkerMessage)) {
+func (dt *DirectoryTree) Open(name string, query string, delay time.Duration, cb func(types.WorkerMessage)) {
if name == "" {
return
}
@@ -252,7 +252,7 @@ func (dt *DirectoryTree) Open(name string, delay time.Duration, cb func(types.Wo
} else {
dt.reindex(name)
}
- dt.DirectoryList.Open(name, delay, func(msg types.WorkerMessage) {
+ dt.DirectoryList.Open(name, query, delay, func(msg types.WorkerMessage) {
if cb != nil {
cb(msg)
}