diff options
author | Bence Ferdinandy <bence@ferdinandy.com> | 2024-06-21 21:55:33 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-06-23 22:13:30 +0200 |
commit | e2a9cd0881593c3b3a24863ceb535367c5570888 (patch) | |
tree | 1b8310bb83f0c9f8f6f1504e9d9e17674ac57b55 /commands | |
parent | a37ae231061e027233dc159900846f75c32a6d18 (diff) | |
download | aerc-e2a9cd0881593c3b3a24863ceb535367c5570888.tar.gz |
query: allow forcing overwrite of existing folder
Currently, when using :query the user is forced to create a new folder
for every query, since aerc doesn't allow overwriting an existing
folder. Actually, "overwriting" an existing folder with a query is
a non-destructive operation in the sense, that the underlying maildir is
not touched, the only thing lost is the state in aerc. The current
behaviour doesn't allow for a simple `:query -n query ` type of binding.
Allow overwriting an existing folder with the -f flag.
Changelog-added: Allow using existing directory name with `:query -f`.
Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/account/cf.go | 4 | ||||
-rw-r--r-- | commands/account/mkdir.go | 2 | ||||
-rw-r--r-- | commands/account/query.go | 3 | ||||
-rw-r--r-- | commands/account/rmdir.go | 4 |
4 files changed, 7 insertions, 6 deletions
diff --git a/commands/account/cf.go b/commands/account/cf.go index 8762f97f..199664fa 100644 --- a/commands/account/cf.go +++ b/commands/account/cf.go @@ -117,12 +117,12 @@ func (c ChangeFolder) Execute([]string) error { if target == "-" { if dir, ok := history[acct.Name()]; ok { - acct.Directories().Open(dir, "", 0*time.Second, finalize) + acct.Directories().Open(dir, "", 0*time.Second, finalize, false) } else { return errors.New("No previous folder to return to") } } else { - acct.Directories().Open(target, "", 0*time.Second, finalize) + acct.Directories().Open(target, "", 0*time.Second, finalize, false) } return nil diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index dae407cd..5ce7bbf4 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -53,7 +53,7 @@ func (m MakeDir) Execute(args []string) error { case *types.Done: app.PushStatus("Directory created.", 10*time.Second) history[acct.Name()] = previous - acct.Directories().Open(m.Folder, "", 0, nil) + acct.Directories().Open(m.Folder, "", 0, nil, false) case *types.Error: app.PushError(msg.Error.Error()) } diff --git a/commands/account/query.go b/commands/account/query.go index b82d0697..65b5e063 100644 --- a/commands/account/query.go +++ b/commands/account/query.go @@ -13,6 +13,7 @@ import ( type Query struct { Account string `opt:"-a" complete:"CompleteAccount"` Name string `opt:"-n"` + Force bool `opt:"-f"` Query string `opt:"..." complete:"CompleteNotmuch"` } @@ -60,7 +61,7 @@ func (q Query) Execute([]string) error { if name == "" { name = q.Query } - acct.Directories().Open(name, q.Query, 0*time.Second, finalize) + acct.Directories().Open(name, q.Query, 0*time.Second, finalize, q.Force) return nil } diff --git a/commands/account/rmdir.go b/commands/account/rmdir.go index 22e78a69..b08a2a1e 100644 --- a/commands/account/rmdir.go +++ b/commands/account/rmdir.go @@ -89,7 +89,7 @@ func (r RemoveDir) Execute(args []string) error { return errors.New("No directory to move to afterwards!") } - reopenCurrentDir := func() { acct.Directories().Open(curDir, "", 0, nil) } + reopenCurrentDir := func() { acct.Directories().Open(curDir, "", 0, nil, false) } acct.Directories().Open(newDir, "", 0, func(msg types.WorkerMessage) { switch msg.(type) { @@ -117,7 +117,7 @@ func (r RemoveDir) Execute(args []string) error { reopenCurrentDir() } }) - }) + }, false) return nil } |