summary refs log tree commit diff stats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/aerc.conf.in22
-rw-r--r--config/config.go44
2 files changed, 56 insertions, 10 deletions
diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index ec89ff7..16e3da1 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -108,7 +108,7 @@ editor=
 
 #
 # Default header fields to display when composing a message. To display
-# multiple headers in the same row, separate them with a pipe, e.g. "To|From". 
+# multiple headers in the same row, separate them with a pipe, e.g. "To|From".
 #
 # Default: To|From,Subject
 header-layout=To|From,Subject
@@ -139,3 +139,23 @@ text/*=awk -f @SHAREDIR@/filters/plaintext
 #
 # Executed when a new email arrives in the selected folder
 new-email=
+
+[templates]
+# Templates are used to populate email bodies automatically.
+#
+
+# The directories where the templates are stored. It takes a colon-separated
+# list of directories.
+#
+# default: @SHAREDIR@/templates/
+template-dirs=@SHAREDIR@/templates/
+
+# The template to be used for quoted replies.
+#
+# default: quoted_reply
+quoted-reply=quoted_reply
+
+# The template to be used for forward as body.
+#
+# default: forward_as_body
+forwards=forward_as_body
diff --git a/config/config.go b/config/config.go
index 133a7f4..f46af09 100644
--- a/config/config.go
+++ b/config/config.go
@@ -16,6 +16,8 @@ import (
 	"github.com/gdamore/tcell"
 	"github.com/go-ini/ini"
 	"github.com/kyoh86/xdg"
+
+	"git.sr.ht/~sircmpwn/aerc/lib/templates"
 )
 
 type GeneralConfig struct {
@@ -98,16 +100,23 @@ type TriggersConfig struct {
 	ExecuteCommand func(command []string) error
 }
 
+type TemplateConfig struct {
+	TemplateDirs []string
+	QuotedReply  string `ini:"quoted-reply"`
+	Forwards     string `ini:"forwards"`
+}
+
 type AercConfig struct {
-	Bindings BindingConfig
-	Compose  ComposeConfig
-	Ini      *ini.File       `ini:"-"`
-	Accounts []AccountConfig `ini:"-"`
-	Filters  []FilterConfig  `ini:"-"`
-	Viewer   ViewerConfig    `ini:"-"`
-	Triggers TriggersConfig  `ini:"-"`
-	Ui       UIConfig
-	General  GeneralConfig
+	Bindings  BindingConfig
+	Compose   ComposeConfig
+	Ini       *ini.File       `ini:"-"`
+	Accounts  []AccountConfig `ini:"-"`
+	Filters   []FilterConfig  `ini:"-"`
+	Viewer    ViewerConfig    `ini:"-"`
+	Triggers  TriggersConfig  `ini:"-"`
+	Ui        UIConfig
+	General   GeneralConfig
+	Templates TemplateConfig
 }
 
 // Input: TimestampFormat
@@ -305,6 +314,23 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 			return err
 		}
 	}
+	if templatesSec, err := file.GetSection("templates"); err == nil {
+		if err := templatesSec.MapTo(&config.Templates); err != nil {
+			return err
+		}
+		templateDirs := templatesSec.Key("template-dirs").String()
+		config.Templates.TemplateDirs = strings.Split(templateDirs, ":")
+		for key, val := range templatesSec.KeysHash() {
+			if key == "template-dirs" {
+				continue
+			}
+			_, err := templates.ParseTemplateFromFile(
+				val, config.Templates.TemplateDirs, templates.TestTemplateData())
+			if err != nil {
+				return err
+			}
+		}
+	}
 	return nil
 }