From dfc048fe285939d9de3b5753f723c935d042cc2b Mon Sep 17 00:00:00 2001 From: Daniel Bridges Date: Mon, 15 Jul 2019 11:56:44 -0700 Subject: Display user specified headers in viewer if present --- config/aerc.conf.in | 8 ++++++++ config/config.go | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/aerc.conf.in b/config/aerc.conf.in index 41f4ce6..d490831 100644 --- a/config/aerc.conf.in +++ b/config/aerc.conf.in @@ -61,6 +61,14 @@ alternatives=text/plain,text/html # Default: false show-headers=false +# +# Layout of headers when viewing a message. To display multiple headers in the +# same row, separate them with a pipe, e.g. "From|To". Rows will be hidden if +# none of their specified headers are present in the message. +# +# Default: From|To,Cc|Bcc,Date,Subject +header-layout=From|To,Cc|Bcc,Date,Subject + [compose] # # Specifies the command to run the editor with. It will be shown in an embedded diff --git a/config/config.go b/config/config.go index aab3905..9e081fd 100644 --- a/config/config.go +++ b/config/config.go @@ -79,7 +79,8 @@ type FilterConfig struct { type ViewerConfig struct { Pager string Alternatives []string - ShowHeaders bool `ini:"show-headers"` + ShowHeaders bool `ini:"show-headers"` + HeaderLayout [][]string `ini:"-"` } type AercConfig struct { @@ -261,6 +262,8 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { switch key { case "alternatives": config.Viewer.Alternatives = strings.Split(val, ",") + case "header-layout": + config.Viewer.HeaderLayout = parseLayout(val) } } } @@ -323,6 +326,18 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) { EmptyDirlist: "(no folders)", MouseEnabled: false, }, + + Viewer: ViewerConfig{ + Pager: "less -R", + Alternatives: []string{"text/plain", "text/html"}, + ShowHeaders: false, + HeaderLayout: [][]string{ + {"From", "To"}, + {"Cc", "Bcc"}, + {"Date"}, + {"Subject"}, + }, + }, } // These bindings are not configurable config.Bindings.AccountWizard.ExKey = KeyStroke{ @@ -431,3 +446,12 @@ func checkConfigPerms(filename string) error { } return nil } + +func parseLayout(layout string) [][]string { + rows := strings.Split(layout, ",") + l := make([][]string, len(rows)) + for i, r := range rows { + l[i] = strings.Split(r, "|") + } + return l +} -- cgit v1.2.3