diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-04-17 17:15:49 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:50:37 +0200 |
commit | c7f5f2cf4c2a043ce36ec486fe0d9203020c8744 (patch) | |
tree | 983011ce247c75c61d7f1a8e3dbe6e14903989ef | |
parent | 96d5b4e149dccfdb75d41785e6525b647925f8ce (diff) | |
download | aerc-c7f5f2cf4c2a043ce36ec486fe0d9203020c8744.tar.gz |
mailto: add template parameter
Add template parameter to the mailto query and set the
config.Template.NewMessage template file as default.
Fixes: https://todo.sr.ht/~rjarry/aerc/145
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry<robin@jarry.cc>
-rw-r--r-- | doc/aerc.1.scd | 2 | ||||
-rw-r--r-- | widgets/aerc.go | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index 674535a9..cf6f7caa 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -42,6 +42,8 @@ from your terminal. : In-reply-to header will be set to the message id | _account=<accountname>_ : Specify the account (must be in _accounts.conf_; default is the selected account) +| _template=<template-file>_ +: Template sets the template file for creating the message Note that reserved characters in the queries must be percent encoded. diff --git a/widgets/aerc.go b/widgets/aerc.go index 352bcadd..f4812dd4 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -676,6 +676,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { return fmt.Errorf("Could not parse to: %w", err) } h.SetAddressList("to", to) + template := config.Templates.NewMessage for key, vals := range addr.Query() { switch strings.ToLower(key) { case "account": @@ -705,6 +706,9 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { case "subject": subject = strings.Join(vals, ",") h.SetText("Subject", subject) + case "template": + template = strings.Join(vals, "") + log.Tracef("template set to %s", template) case "attach": for _, path := range vals { // remove a potential file:// prefix. @@ -731,9 +735,9 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { defer ui.QueueRedraw() composer, err := NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", h, nil) + acct.AccountConfig(), acct.Worker(), template, h, nil) if err != nil { - return nil + return err } composer.SetContents(strings.NewReader(body)) composer.FocusEditor("subject") |