aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@postbox.nz>2023-08-12 10:22:46 +0300
committerRobin Jarry <robin@jarry.cc>2023-08-25 14:08:09 +0200
commitb919c0451c03e785c31eeea3a3b18b76492b6504 (patch)
treeef16feffbdf1e9d289c97a1e395de14bef78f7d5
parent91a8535a190137b4b6451658274acfefa6660847 (diff)
downloadaerc-b919c0451c03e785c31eeea3a3b18b76492b6504.tar.gz
aerc-b919c0451c03e785c31eeea3a3b18b76492b6504.zip
export-mbox: better path suggestion and name completion
Change the `:export-mbox` path completion algorithm, so it works the same as `:import-mbox`: the user can select folders with auto-complete, the ~ symbol works as home folder and so on. Move the automatic mbox-file naming into the export function and only use it if the user-supplied path is an existing folder. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/account/export-mbox.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go
index 1f4c5a42..8981261b 100644
--- a/commands/account/export-mbox.go
+++ b/commands/account/export-mbox.go
@@ -8,6 +8,7 @@ import (
"sync"
"time"
+ "git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
mboxer "git.sr.ht/~rjarry/aerc/worker/mbox"
@@ -25,14 +26,7 @@ func (ExportMbox) Aliases() []string {
}
func (ExportMbox) Complete(aerc *widgets.Aerc, args []string) []string {
- if acct := aerc.SelectedAccount(); acct != nil {
- if path := acct.SelectedDirectory(); path != "" {
- if f := filepath.Base(path); f != "" {
- return []string{f + ".mbox"}
- }
- }
- }
- return nil
+ return commands.CompletePath(filepath.Join(args...))
}
func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error {
@@ -50,6 +44,15 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("No message store selected")
}
+ fi, err := os.Stat(filename)
+ if err == nil && fi.IsDir() {
+ if path := acct.SelectedDirectory(); path != "" {
+ if f := filepath.Base(path); f != "" {
+ filename += f + ".mbox"
+ }
+ }
+ }
+
aerc.PushStatus("Exporting to "+filename, 10*time.Second)
// uids of messages to export