diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | commands/account/export-mbox.go | 26 | ||||
-rw-r--r-- | doc/aerc.1.scd | 4 |
3 files changed, 28 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e84982e..29fba540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). **prepended** to the default system `PATH` to avoid conflicts with installed distro binaries which have the same name as aerc builtin filters (e.g. `/usr/bin/colorize`). +- `:export-mbox` only exports marked messages, if any. Otherwise it exports + everything, as usual. ## [0.15.2](https://git.sr.ht/~rjarry/aerc/refs/0.15.2) - 2023-05-11 diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go index 5051906c..1f4c5a42 100644 --- a/commands/account/export-mbox.go +++ b/commands/account/export-mbox.go @@ -52,6 +52,21 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushStatus("Exporting to "+filename, 10*time.Second) + // uids of messages to export + var uids []uint32 + + // check if something is marked - we export that then + msgProvider, ok := aerc.SelectedTabContent().(widgets.ProvidesMessages) + if !ok { + msgProvider = aerc.SelectedAccount() + } + if msgProvider != nil { + marked, err := msgProvider.MarkedMessages() + if err == nil && len(marked) > 0 { + uids = marked + } + } + go func() { defer log.PanicHandler() file, err := os.Create(filename) @@ -67,9 +82,14 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { var retries int done := make(chan bool) - uids := make([]uint32, len(store.Uids())) - copy(uids, store.Uids()) + + // if no messages were marked, we export everything + if len(uids) == 0 { + uids = make([]uint32, len(store.Uids())) + copy(uids, store.Uids()) + } t := time.Now() + total := len(uids) for len(uids) > 0 { if retries > 0 { @@ -116,7 +136,7 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { } retries++ } - statusInfo := fmt.Sprintf("Exported %d of %d messages to %s.", ctr, len(store.Uids()), filename) + statusInfo := fmt.Sprintf("Exported %d of %d messages to %s.", ctr, total, filename) aerc.PushStatus(statusInfo, 10*time.Second) log.Debugf(statusInfo) }() diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index 36b2f6bd..a4892b03 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -405,7 +405,9 @@ message list, the message in the message viewer, etc). enabled. *:export-mbox* _<file>_ - Exports all messages in the current folder to an mbox file. + Exports messages in the current folder to an mbox file. If there are marked + messages in the folder, only the marked ones are exported. Otherwise the + whole folder is exported. *:import-mbox* _<file>_ Imports all messages from an mbox file to the current folder. |