1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-02-22 23:23:57 +01:00
aerc/commands/compose/edit.go
Robin Jarry fa0b99800e compose: differentiate between edit and review commands
Split the compose commands into two categories: edit and review. Some
commands can belong to both categories and be available whether the text
editor or the review screen is visible.

Update man page to reflect that. Remove duplicate (and misplaced) :save
command from the COMPOSE section.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
2025-01-14 15:00:56 +01:00

46 lines
940 B
Go

package compose
import (
"errors"
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/config"
)
type Edit struct {
Edit bool `opt:"-e" desc:"Force [compose].edit-headers = true."`
NoEdit bool `opt:"-E" desc:"Force [compose].edit-headers = false."`
}
func init() {
commands.Register(Edit{})
}
func (Edit) Description() string {
return "(Re-)open text editor to edit the message in progress."
}
func (Edit) Context() commands.CommandContext {
return commands.COMPOSE_REVIEW
}
func (Edit) Aliases() []string {
return []string{"edit"}
}
func (e Edit) Execute(args []string) error {
composer, ok := app.SelectedTabContent().(*app.Composer)
if !ok {
return errors.New("only valid while composing")
}
editHeaders := (config.Compose.EditHeaders || e.Edit) && !e.NoEdit
err := composer.ShowTerminal(editHeaders)
if err != nil {
return err
}
composer.FocusTerminal()
return nil
}