aboutsummaryrefslogtreecommitdiff
path: root/widgets/aerc.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r--widgets/aerc.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index a73caec..14cf3c4 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -1,7 +1,10 @@
package widgets
import (
+ "errors"
"log"
+ "net/url"
+ "strings"
"time"
"github.com/gdamore/tcell"
@@ -302,3 +305,40 @@ func (aerc *Aerc) BeginExCommand() {
aerc.statusbar.Push(exline)
aerc.focus(exline)
}
+
+func (aerc *Aerc) Mailto(addr *url.URL) error {
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
+ defaults := make(map[string]string)
+ defaults["To"] = addr.Opaque
+ headerMap := map[string]string{
+ "cc": "Cc",
+ "in-reply-to": "In-Reply-To",
+ "subject": "Subject",
+ }
+ for key, vals := range addr.Query() {
+ if header, ok := headerMap[strings.ToLower(key)]; ok {
+ defaults[header] = strings.Join(vals, ",")
+ }
+ }
+ composer := NewComposer(aerc.Config(),
+ acct.AccountConfig(), acct.Worker()).Defaults(defaults)
+ composer.FocusSubject()
+ title := "New email"
+ if subj, ok := defaults["Subject"]; ok {
+ title = subj
+ composer.FocusTerminal()
+ }
+ tab := aerc.NewTab(composer, title)
+ composer.OnSubjectChange(func(subject string) {
+ if subject == "" {
+ tab.Name = "New email"
+ } else {
+ tab.Name = subject
+ }
+ tab.Content.Invalidate()
+ })
+ return nil
+}