mirror of
https://git.sr.ht/~rjarry/aerc
synced 2025-02-22 14:53:57 +01:00

When the composer window opens, an user might want to start writing the email body before adding a subject and recipients. Setting the focus-body option to true achieves that by setting the focus to the editor. Signed-off-by: Markus Unkel <markus@unkel.io> Acked-by: Robin Jarry <robin@jarry.cc>
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
"git.sr.ht/~rjarry/aerc/lib/log"
|
|
"github.com/go-ini/ini"
|
|
)
|
|
|
|
type ComposeConfig struct {
|
|
Editor string `ini:"editor"`
|
|
HeaderLayout [][]string `ini:"header-layout" parse:"ParseLayout" default:"To|From,Subject"`
|
|
AddressBookCmd string `ini:"address-book-cmd"`
|
|
ReplyToSelf bool `ini:"reply-to-self" default:"true"`
|
|
NoAttachmentWarning *regexp.Regexp `ini:"no-attachment-warning" parse:"ParseNoAttachmentWarning"`
|
|
EmptySubjectWarning bool `ini:"empty-subject-warning"`
|
|
FilePickerCmd string `ini:"file-picker-cmd"`
|
|
FormatFlowed bool `ini:"format-flowed"`
|
|
EditHeaders bool `ini:"edit-headers"`
|
|
FocusBody bool `ini:"focus-body"`
|
|
LFEditor bool `ini:"lf-editor"`
|
|
}
|
|
|
|
var Compose = new(ComposeConfig)
|
|
|
|
func parseCompose(file *ini.File) error {
|
|
if err := MapToStruct(file.Section("compose"), Compose, true); err != nil {
|
|
return err
|
|
}
|
|
log.Debugf("aerc.conf: [compose] %#v", Compose)
|
|
return nil
|
|
}
|
|
|
|
func (c *ComposeConfig) ParseLayout(sec *ini.Section, key *ini.Key) ([][]string, error) {
|
|
layout := parseLayout(key.String())
|
|
return layout, nil
|
|
}
|
|
|
|
func (c *ComposeConfig) ParseNoAttachmentWarning(sec *ini.Section, key *ini.Key) (*regexp.Regexp, error) {
|
|
if key.String() == "" {
|
|
return nil, nil
|
|
}
|
|
return regexp.Compile(`(?im)` + key.String())
|
|
}
|