compose: add default template for new messages

Allow defining a default template to use when composing new messages.
Add an example to be used for new users.

Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2022-01-19 21:28:06 +01:00
parent 92bf89c338
commit 877a94f5d9
6 changed files with 17 additions and 0 deletions

View file

@ -99,6 +99,7 @@ install: all
install -m755 filters/hldiff $(DESTDIR)$(SHAREDIR)/filters/hldiff install -m755 filters/hldiff $(DESTDIR)$(SHAREDIR)/filters/hldiff
install -m755 filters/html $(DESTDIR)$(SHAREDIR)/filters/html install -m755 filters/html $(DESTDIR)$(SHAREDIR)/filters/html
install -m755 filters/plaintext $(DESTDIR)$(SHAREDIR)/filters/plaintext install -m755 filters/plaintext $(DESTDIR)$(SHAREDIR)/filters/plaintext
install -m644 templates/new_message $(DESTDIR)$(SHAREDIR)/templates/new_message
install -m644 templates/quoted_reply $(DESTDIR)$(SHAREDIR)/templates/quoted_reply install -m644 templates/quoted_reply $(DESTDIR)$(SHAREDIR)/templates/quoted_reply
install -m644 templates/forward_as_body $(DESTDIR)$(SHAREDIR)/templates/forward_as_body install -m644 templates/forward_as_body $(DESTDIR)$(SHAREDIR)/templates/forward_as_body
install -m644 config/default_styleset $(DESTDIR)$(SHAREDIR)/stylesets/default install -m644 config/default_styleset $(DESTDIR)$(SHAREDIR)/stylesets/default

View file

@ -30,6 +30,9 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
return err return err
} }
acct := aerc.SelectedAccount() acct := aerc.SelectedAccount()
if template == "" {
template = aerc.Config().Templates.NewMessage
}
composer, err := widgets.NewComposer(aerc, acct, composer, err := widgets.NewComposer(aerc, acct,
aerc.Config(), acct.AccountConfig(), acct.Worker(), aerc.Config(), acct.AccountConfig(), acct.Worker(),

View file

@ -224,6 +224,11 @@ new-email=
# default: @SHAREDIR@/templates/ # default: @SHAREDIR@/templates/
template-dirs=@SHAREDIR@/templates/ template-dirs=@SHAREDIR@/templates/
# The default template to be used for new messages.
#
# default: new_message
new-message=new_message
# The default template to be used for quoted replies. # The default template to be used for quoted replies.
# #
# default: quoted_reply # default: quoted_reply

View file

@ -146,6 +146,7 @@ type TriggersConfig struct {
type TemplateConfig struct { type TemplateConfig struct {
TemplateDirs []string `ini:"template-dirs", delim:":"` TemplateDirs []string `ini:"template-dirs", delim:":"`
NewMessage string `ini:"new-message"`
QuotedReply string `ini:"quoted-reply"` QuotedReply string `ini:"quoted-reply"`
Forwards string `ini:"forwards"` Forwards string `ini:"forwards"`
} }
@ -595,6 +596,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
Templates: TemplateConfig{ Templates: TemplateConfig{
TemplateDirs: []string{path.Join(sharedir, "templates")}, TemplateDirs: []string{path.Join(sharedir, "templates")},
NewMessage: "new_message",
QuotedReply: "quoted_reply", QuotedReply: "quoted_reply",
Forwards: "forward_as_body", Forwards: "forward_as_body",
}, },

View file

@ -382,6 +382,11 @@ These options are configured in the *[templates]* section of aerc.conf.
Default: "/usr/share/aerc/templates" Default: "/usr/share/aerc/templates"
*new-message*
The default template to be used for new messages.
Default: "new_message"
*quoted-reply* *quoted-reply*
The default template to be used for quoted replies. The default template to be used for quoted replies.

1
templates/new_message Normal file
View file

@ -0,0 +1 @@
X-Mailer: aerc {{version}}