aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-07-05 23:10:39 +0200
committerRobin Jarry <robin@jarry.cc>2023-07-17 10:24:17 +0200
commit4c514ce4d15fd14cad528cf426bc3f853efe7f64 (patch)
treefa52247b470a6af233a6e242962ed20e4831a555
parent11e5390fa0acbcc609ca177777548dd2d725afbc (diff)
downloadaerc-4c514ce4d15fd14cad528cf426bc3f853efe7f64.tar.gz
aerc-4c514ce4d15fd14cad528cf426bc3f853efe7f64.zip
compose: allow changing edit-headers on the fly
Add -e|-E flags to all compose commands to allow switching between edit-headers = true/false without restarting aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
-rw-r--r--CHANGELOG.md3
-rw-r--r--commands/account/compose.go19
-rw-r--r--commands/account/recover.go15
-rw-r--r--commands/compose/edit.go25
-rw-r--r--commands/msg/forward.go13
-rw-r--r--commands/msg/invite.go21
-rw-r--r--commands/msg/recall.go16
-rw-r--r--commands/msg/reply.go13
-rw-r--r--commands/msg/unsubscribe.go24
-rw-r--r--doc/aerc.1.scd54
-rw-r--r--widgets/aerc.go3
-rw-r--r--widgets/compose.go28
12 files changed, 180 insertions, 54 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b254b69..2d5f4ed9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Folder name mapping with `folder-map` in `accounts.conf`.
- Add option `-d` to `:open` to automatically delete temporary files.
- Edit email headers directly in the text editor with `[compose].edit-headers`
- in `aerc.conf`.
+ in `aerc.conf` or with the `-e` flag for all compose related commands (e.g.
+ `:compose`, `:forward`, `:recall`, etc.).
### Fixed
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 3c603f34..5da0f163 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -30,7 +30,7 @@ func (Compose) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
- body, template, err := buildBody(args)
+ body, template, editHeaders, err := buildBody(args)
if err != nil {
return err
}
@@ -51,7 +51,7 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
headers := mail.HeaderFromMap(msg.Header)
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(),
+ acct.AccountConfig(), acct.Worker(), editHeaders,
template, &headers, nil, msg.Body)
if err != nil {
return err
@@ -60,11 +60,12 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
-func buildBody(args []string) (string, string, error) {
+func buildBody(args []string) (string, string, bool, error) {
var body, template, headers string
- opts, optind, err := getopt.Getopts(args, "H:T:")
+ editHeaders := config.Compose.EditHeaders
+ opts, optind, err := getopt.Getopts(args, "H:T:eE")
if err != nil {
- return "", "", err
+ return "", "", false, err
}
for _, opt := range opts {
switch opt.Option {
@@ -78,11 +79,15 @@ func buildBody(args []string) (string, string, error) {
}
case 'T':
template = opt.Value
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
}
}
posargs := args[optind:]
if len(posargs) > 1 {
- return "", template, errors.New("Usage: compose [-H header] [-T template] [body]")
+ return "", "", false, errors.New("Usage: compose [-H header] [-T template] [-e|-E] [body]")
}
if len(posargs) == 1 {
body = posargs[0]
@@ -94,5 +99,5 @@ func buildBody(args []string) (string, string, error) {
body = headers + "\n\n"
}
}
- return body, template, nil
+ return body, template, editHeaders, nil
}
diff --git a/commands/account/recover.go b/commands/account/recover.go
index 3e4e9136..9fdaa3e9 100644
--- a/commands/account/recover.go
+++ b/commands/account/recover.go
@@ -8,6 +8,7 @@ import (
"path/filepath"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
)
@@ -23,7 +24,7 @@ func (Recover) Aliases() []string {
}
func (Recover) Options() string {
- return "f"
+ return "feE"
}
func (r Recover) Complete(aerc *widgets.Aerc, args []string) []string {
@@ -45,19 +46,25 @@ func (r Recover) Execute(aerc *widgets.Aerc, args []string) error {
}
force := false
+ editHeaders := config.Compose.EditHeaders
opts, optind, err := getopt.Getopts(args, r.Options())
if err != nil {
return err
}
for _, opt := range opts {
- if opt.Option == 'f' {
+ switch opt.Option {
+ case 'f':
force = true
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
}
}
if len(args) <= optind {
- return errors.New("Usage: recover [-f] <file>")
+ return errors.New("Usage: recover [-f] [-E|-e] <file>")
}
acct := aerc.SelectedAccount()
@@ -83,7 +90,7 @@ func (r Recover) Execute(aerc *widgets.Aerc, args []string) error {
}
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(),
+ acct.AccountConfig(), acct.Worker(), editHeaders,
"", nil, nil, bytes.NewReader(data))
if err != nil {
return err
diff --git a/commands/compose/edit.go b/commands/compose/edit.go
index 6f877346..1e8e0672 100644
--- a/commands/compose/edit.go
+++ b/commands/compose/edit.go
@@ -3,7 +3,9 @@ package compose
import (
"errors"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~sircmpwn/getopt"
)
type Edit struct{}
@@ -21,14 +23,29 @@ func (Edit) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (Edit) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) != 1 {
- return errors.New("Usage: edit")
- }
composer, ok := aerc.SelectedTabContent().(*widgets.Composer)
if !ok {
return errors.New("only valid while composing")
}
- err := composer.ShowTerminal()
+
+ editHeaders := config.Compose.EditHeaders
+ opts, optind, err := getopt.Getopts(args, "eE")
+ if err != nil {
+ return err
+ }
+ if len(args) != optind {
+ return errors.New("Usage: edit [-e|-E]")
+ }
+ for _, opt := range opts {
+ switch opt.Option {
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
+ }
+ }
+
+ err = composer.ShowTerminal(editHeaders)
if err != nil {
return err
}
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index ed0043fe..86c52059 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -39,13 +39,17 @@ func (forward) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (forward) Execute(aerc *widgets.Aerc, args []string) error {
- opts, optind, err := getopt.Getopts(args, "AFT:")
+ opts, optind, err := getopt.Getopts(args, "AFT:eE")
if err != nil {
return err
}
+ if len(args) != optind {
+ return errors.New("Usage: forward [-A|-F] [-T <template>] [-e|-E]")
+ }
attachAll := false
attachFull := false
template := ""
+ editHeaders := config.Compose.EditHeaders
for _, opt := range opts {
switch opt.Option {
case 'A':
@@ -54,6 +58,10 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
attachFull = true
case 'T':
template = opt.Value
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
}
}
@@ -100,7 +108,8 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
addTab := func() (*widgets.Composer, error) {
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(), template, h, &original, nil)
+ acct.AccountConfig(), acct.Worker(), editHeaders,
+ template, h, &original, nil)
if err != nil {
aerc.PushError("Error: " + err.Error())
return nil, err
diff --git a/commands/msg/invite.go b/commands/msg/invite.go
index 6273d520..309fe643 100644
--- a/commands/msg/invite.go
+++ b/commands/msg/invite.go
@@ -12,6 +12,7 @@ import (
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~sircmpwn/getopt"
"github.com/emersion/go-message/mail"
)
@@ -48,6 +49,23 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
return fmt.Errorf("no invitation found (missing text/calendar)")
}
+ editHeaders := config.Compose.EditHeaders
+ opts, optind, err := getopt.Getopts(args, "eE")
+ if err != nil {
+ return err
+ }
+ if len(args) != optind {
+ return errors.New("Usage: accept|accept-tentative|decline [-e|-E]")
+ }
+ for _, opt := range opts {
+ switch opt.Option {
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
+ }
+ }
+
subject := trimLocalizedRe(msg.Envelope.Subject, acct.AccountConfig().LocalizedRe)
switch args[0] {
case "accept":
@@ -138,7 +156,8 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
addTab := func(cr *calendar.Reply) error {
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(), "", h, &original, cr.PlainText)
+ acct.AccountConfig(), acct.Worker(), editHeaders,
+ "", h, &original, cr.PlainText)
if err != nil {
aerc.PushError("Error: " + err.Error())
return err
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index 71f8b8a5..c095caf1 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -10,6 +10,7 @@ import (
_ "github.com/emersion/go-message/charset"
"github.com/pkg/errors"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -33,19 +34,24 @@ func (Recall) Complete(aerc *widgets.Aerc, args []string) []string {
func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
force := false
+ editHeaders := config.Compose.EditHeaders
- opts, optind, err := getopt.Getopts(args, "f")
+ opts, optind, err := getopt.Getopts(args, "feE")
if err != nil {
return err
}
for _, opt := range opts {
- if opt.Option == 'f' {
+ switch opt.Option {
+ case 'f':
force = true
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
}
}
-
if len(args) != optind {
- return errors.New("Usage: recall [-f]")
+ return errors.New("Usage: recall [-f] [-e|-E]")
}
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
@@ -130,7 +136,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
msg.FetchBodyPart(path, func(reader io.Reader) {
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(),
+ acct.AccountConfig(), acct.Worker(), editHeaders,
"", msgInfo.RFC822Headers, nil, reader)
if err != nil {
aerc.PushError(err.Error())
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 8cdb50d4..b2a61a80 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -38,12 +38,12 @@ func (reply) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (reply) Execute(aerc *widgets.Aerc, args []string) error {
- opts, optind, err := getopt.Getopts(args, "acqT:")
+ opts, optind, err := getopt.Getopts(args, "acqT:eE")
if err != nil {
return err
}
if optind != len(args) {
- return errors.New("Usage: reply [-acq -T <template>]")
+ return errors.New("Usage: reply [-acq -T <template>] [-e|-E]")
}
var (
quote bool
@@ -51,6 +51,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
closeOnReply bool
template string
)
+ editHeaders := config.Compose.EditHeaders
for _, opt := range opts {
switch opt.Option {
case 'a':
@@ -61,6 +62,10 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
quote = true
case 'T':
template = opt.Value
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
}
}
@@ -175,8 +180,8 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
addTab := func() error {
composer, err := widgets.NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(), template, h,
- &original, nil)
+ acct.AccountConfig(), acct.Worker(), editHeaders,
+ template, h, &original, nil)
if err != nil {
aerc.PushError("Error: " + err.Error())
return err
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index cefa69cb..505392d4 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -8,9 +8,11 @@ import (
"strings"
"time"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~sircmpwn/getopt"
"github.com/emersion/go-message/mail"
)
@@ -34,8 +36,21 @@ func (Unsubscribe) Complete(aerc *widgets.Aerc, args []string) []string {
// Execute runs the Unsubscribe command
func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) != 1 {
- return errors.New("Usage: unsubscribe")
+ editHeaders := config.Compose.EditHeaders
+ opts, optind, err := getopt.Getopts(args, "eE")
+ if err != nil {
+ return err
+ }
+ if len(args) != optind {
+ return errors.New("Usage: unsubscribe [-e|-E]")
+ }
+ for _, opt := range opts {
+ switch opt.Option {
+ case 'e':
+ editHeaders = true
+ case 'E':
+ editHeaders = false
+ }
}
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
msg, err := widget.SelectedMessage()
@@ -61,7 +76,7 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
var err error
switch strings.ToLower(method.Scheme) {
case "mailto":
- err = unsubscribeMailto(aerc, method)
+ err = unsubscribeMailto(aerc, method, editHeaders)
case "http", "https":
err = unsubscribeHTTP(aerc, method)
default:
@@ -133,7 +148,7 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) {
}
}
-func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
+func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL, editHeaders bool) error {
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
acct := widget.SelectedAccount()
if acct == nil {
@@ -151,6 +166,7 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
acct,
acct.AccountConfig(),
acct.Worker(),
+ editHeaders,
"",
h,
nil,
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 5a7c9fc4..ab1333f8 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -159,19 +159,31 @@ message list, the message in the message viewer, etc).
_month_: Messages are stored in folders per year and subfolders per month
-*:accept*
+*:accept* [*-e*|*-E*]
Accepts an iCalendar meeting invitation.
-*:accept-tentative*
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
+*:accept-tentative* [*-e*|*-E*]
Accepts an iCalendar meeting invitation tentatively.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
*:copy* _<target>_++
*:cp* _<target>_
Copies the selected message to the target folder.
-*:decline*
+*:decline* [*-e*|*-E*]
Declines an iCalendar meeting invitation.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
*:delete*++
*:delete-message*
Deletes the selected message.
@@ -185,7 +197,7 @@ message list, the message in the message viewer, etc).
User-defined format specifier requiring two _%s_ for the key and
value strings. Default format: _%-20.20s: %s_
-*:recall* [*-f*]
+*:recall* [*-f*] [*-e*|*-E*]
Opens the selected message for re-editing. Messages can only be
recalled from the postpone directory. The original message is deleted.
@@ -193,7 +205,11 @@ message list, the message in the message viewer, etc).
directory. The original message will be deleted only if it is in the
postpone directory.
-*:forward* [*-A*|*-F*] [*-T* _<template-file>_] [_<address>_...]
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
+*:forward* [*-A*|*-F*] [*-T* _<template-file>_] [*-e*|*-E*] [_<address>_...]
Opens the composer to forward the selected message to another recipient.
*-A*: Forward the message and all attachments.
@@ -206,6 +222,10 @@ message list, the message in the message viewer, etc).
is set as *forwards* in the *[templates]* section of
_aerc.conf_.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
*:move* _<target>_++
*:mv* _<target>_
Moves the selected message to the target folder.
@@ -233,7 +253,7 @@ message list, the message in the message viewer, etc).
_[PATCH X/Y]_), all marked messages will be sorted by subject to ensure
that the patches are applied in order.
-*:reply* [*-acq*] [*-T* _<template-file>_]
+*:reply* [*-acq*] [*-T* _<template-file>_] [*-e*|*-E*]
Opens the composer to reply to the selected message.
*-a*: Reply all
@@ -248,6 +268,10 @@ message list, the message in the message viewer, etc).
message body. If *-q* is specified, defaults to what is set as
*quoted-reply* in the *[templates]* section of _aerc.conf_.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
*:read* [*-t*]
Marks the marked or selected messages as read.
@@ -288,12 +312,16 @@ message list, the message in the message viewer, etc).
*:modify-labels* _+inbox_ _-spam_ _unread_
-*:unsubscribe*
+*:unsubscribe* [*-e*|*-E*]
Attempt to automatically unsubscribe the user from the mailing list through
use of the List-Unsubscribe header. If supported, aerc may open a compose
window pre-filled with the unsubscribe information or open the unsubscribe
URL in a web browser.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
## MESSAGE LIST COMMANDS
*:clear* [*-s*]
@@ -312,7 +340,7 @@ message list, the message in the message viewer, etc).
check-mail-cmd to be set in order for aerc to initiate a check for new mail.
Issuing a manual *:check-mail* command will reset the timer for automatic checking.
-*:compose* [*-H* _"<header>: <value>"_] [*-T* _<template-file>_] [_<body>_]
+*:compose* [*-H* _"<header>: <value>"_] [*-T* _<template-file>_] [*-e*|*-E*] [_<body>_]
Open the compose window to send a new email. The new email will be sent with
the current account's outgoing transport configuration. For details on
configuring outgoing mail delivery consult *aerc-accounts*(5).
@@ -326,6 +354,10 @@ message list, the message in the message viewer, etc).
Use the specified template file for creating the initial
message body.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
_<body>_: The initial message body.
*:filter* [_<options>_] _<terms>_...
@@ -558,9 +590,13 @@ message list, the message in the message viewer, etc).
Sets the Cc or Bcc header to the given addresses. If an editor for the header
is not currently visible in the compose window, a new one will be added.
-*:edit*
+*:edit* [*-e*|*-E*]
(Re-)opens your text editor to edit the message in progress.
+ *-e*: Forces *[compose].edit-headers* = _true_ for this message only.
+
+ *-E*: Forces *[compose].edit-headers* = _false_ for this message only.
+
*:multipart* [*-d*] _<mime/type>_
Makes the message to multipart/alternative and add the specified
_<mime/type>_ part. Only the MIME types that are configured in the
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 8f744b4c..faec403e 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -734,7 +734,8 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
defer ui.Invalidate()
composer, err := NewComposer(aerc, acct,
- acct.AccountConfig(), acct.Worker(), template, h, nil,
+ acct.AccountConfig(), acct.Worker(),
+ config.Compose.EditHeaders, template, h, nil,
strings.NewReader(body))
if err != nil {
return err
diff --git a/widgets/compose.go b/widgets/compose.go
index 9a54b632..2b8cbb12 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -54,6 +54,7 @@ type Composer struct {
sign bool
encrypt bool
attachKey bool
+ editHeaders bool
layout HeaderLayout
focusable []ui.MouseableDrawableInteractive
@@ -71,7 +72,7 @@ type Composer struct {
func NewComposer(
aerc *Aerc, acct *AccountView, acctConfig *config.AccountConfig,
- worker *types.Worker, template string,
+ worker *types.Worker, editHeaders bool, template string,
h *mail.Header, orig *models.OriginalMail, body io.Reader,
) (*Composer, error) {
if h == nil {
@@ -95,6 +96,8 @@ func NewComposer(
// You have to backtab to get to "From", since you usually don't edit it
focused: 1,
completer: nil,
+
+ editHeaders: editHeaders,
}
data := state.NewDataSetter()
@@ -110,7 +113,7 @@ func NewComposer(
return nil, err
}
- if err := c.ShowTerminal(); err != nil {
+ if err := c.ShowTerminal(editHeaders); err != nil {
return nil, err
}
@@ -460,7 +463,7 @@ func (c *Composer) setContents(reader io.Reader) error {
if err != nil {
return err
}
- if config.Compose.EditHeaders {
+ if c.editHeaders {
for _, h := range c.headerOrder() {
var value string
switch h {
@@ -660,7 +663,7 @@ func (c *Composer) GetBody() (*bytes.Buffer, error) {
return nil, err
}
scanner := bufio.NewScanner(c.email)
- if config.Compose.EditHeaders {
+ if c.editHeaders {
// skip headers
for scanner.Scan() {
if scanner.Text() == "" {
@@ -1142,7 +1145,7 @@ func (c *Composer) termClosed(err error) {
return
}
- if config.Compose.EditHeaders {
+ if c.editHeaders {
// parse embedded header when editor is closed
embedHeader, err := c.parseEmbeddedHeader()
if err != nil {
@@ -1172,7 +1175,7 @@ func (c *Composer) termClosed(err error) {
c.updateGrid()
}
-func (c *Composer) ShowTerminal() error {
+func (c *Composer) ShowTerminal(editHeaders bool) error {
c.Lock()
defer c.Unlock()
if c.editor != nil {
@@ -1182,6 +1185,7 @@ func (c *Composer) ShowTerminal() error {
if err != nil {
return err
}
+ c.editHeaders = editHeaders
err = c.setContents(body)
if err != nil {
return err
@@ -1213,7 +1217,7 @@ func (c *Composer) showTerminal() error {
c.focusable = append(c.focusable, c.editor)
c.review = nil
c.updateGrid()
- if config.Compose.EditHeaders {
+ if c.editHeaders {
c.focusTerminalPriv()
}
return nil
@@ -1222,7 +1226,7 @@ func (c *Composer) showTerminal() error {
func (c *Composer) PrevField() {
c.Lock()
defer c.Unlock()
- if config.Compose.EditHeaders && c.editor != nil {
+ if c.editHeaders && c.editor != nil {
return
}
c.focusable[c.focused].Focus(false)
@@ -1236,7 +1240,7 @@ func (c *Composer) PrevField() {
func (c *Composer) NextField() {
c.Lock()
defer c.Unlock()
- if config.Compose.EditHeaders && c.editor != nil {
+ if c.editHeaders && c.editor != nil {
return
}
c.focusable[c.focused].Focus(false)
@@ -1247,7 +1251,7 @@ func (c *Composer) NextField() {
func (c *Composer) FocusEditor(editor string) {
c.Lock()
defer c.Unlock()
- if config.Compose.EditHeaders && c.editor != nil {
+ if c.editHeaders && c.editor != nil {
return
}
c.focusEditor(editor)
@@ -1270,7 +1274,7 @@ func (c *Composer) focusEditor(editor string) {
func (c *Composer) AddEditor(header string, value string, appendHeader bool) error {
c.Lock()
defer c.Unlock()
- if config.Compose.EditHeaders && c.editor != nil {
+ if c.editHeaders && c.editor != nil {
return errors.New("header should be added directly in the text editor")
}
value = c.addEditor(header, value, appendHeader)
@@ -1364,7 +1368,7 @@ func (c *Composer) updateGrid() {
{Strategy: ui.SIZE_WEIGHT, Size: ui.Const(1)},
})
- if config.Compose.EditHeaders && c.review == nil {
+ if c.editHeaders && c.review == nil {
grid.Rows([]ui.GridSpec{
// 0: editor
{Strategy: ui.SIZE_WEIGHT, Size: ui.Const(1)},