Debian Codegraph @

commands/compose/edit.go

raw
1 package compose
2
3 import (
4 "errors"
5
6 "git.sr.ht/~rjarry/aerc/app"
7 "git.sr.ht/~rjarry/aerc/commands"
8 "git.sr.ht/~rjarry/aerc/config"
9 )
10
11 type Edit struct {
12 Edit bool `opt:"-e" desc:"Force [compose].edit-headers = true."`
13 NoEdit bool `opt:"-E" desc:"Force [compose].edit-headers = false."`
14 }
15
16 func init() {
17 commands.Register(Edit{})
18 }
19
20 func (Edit) Description() string {
21 return "(Re-)open text editor to edit the message in progress."
22 }
23
24 func (Edit) Context() commands.CommandContext {
25 return commands.COMPOSE_REVIEW
26 }
27
28 func (Edit) Aliases() []string {
29 return []string{"edit"}
30 }
31
32 func (e Edit) Execute(args []string) error {
33 composer, ok := app.SelectedTabContent().(*app.Composer)
34 if !ok {
35 return errors.New("only valid while composing")
36 }
37
38 editHeaders := (config.Compose().EditHeaders || e.Edit) && !e.NoEdit
39
40 err := composer.ShowTerminal(editHeaders)
41 if err != nil {
42 return err
43 }
44 composer.FocusTerminal()
45 return nil
46 }