config: allow per-account address-book-cmd

When using multiple accounts, the contacts may be different. Allow using
specific address book commands per account.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Robin Jarry 2022-07-11 11:11:37 +02:00
parent f2dac06029
commit db00accb57
4 changed files with 12 additions and 1 deletions

View file

@ -263,6 +263,8 @@ header-layout=To|From,Subject
# the first field. Only the email address field is required. The second field, # the first field. Only the email address field is required. The second field,
# if present, will be treated as the contact name. Additional fields are # if present, will be treated as the contact name. Additional fields are
# ignored. # ignored.
#
# This parameter can also be set per account in accounts.conf.
address-book-cmd= address-book-cmd=
# #

View file

@ -112,6 +112,7 @@ type AccountConfig struct {
SignatureCmd string SignatureCmd string
EnableFoldersSort bool `ini:"enable-folders-sort"` EnableFoldersSort bool `ini:"enable-folders-sort"`
FoldersSort []string `ini:"folders-sort" delim:","` FoldersSort []string `ini:"folders-sort" delim:","`
AddressBookCmd string `ini:"address-book-cmd"`
// CheckMail // CheckMail
CheckMail time.Duration `ini:"check-mail"` CheckMail time.Duration `ini:"check-mail"`
@ -279,6 +280,8 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
account.PgpAutoSign, _ = strconv.ParseBool(val) account.PgpAutoSign, _ = strconv.ParseBool(val)
} else if key == "pgp-opportunistic-encrypt" { } else if key == "pgp-opportunistic-encrypt" {
account.PgpOpportunisticEncrypt, _ = strconv.ParseBool(val) account.PgpOpportunisticEncrypt, _ = strconv.ParseBool(val)
} else if key == "address-book-cmd" {
account.AddressBookCmd = val
} else if key != "name" { } else if key != "name" {
account.Params[key] = val account.Params[key] = val
} }

View file

@ -467,6 +467,8 @@ These options are configured in the *[compose]* section of aerc.conf.
if present, will be treated as the contact name. Additional fields are if present, will be treated as the contact name. Additional fields are
ignored. ignored.
This parameter can also be set per account in accounts.conf.
Example: Example:
khard email --remove-first-line --parsable '%s' khard email --remove-first-line --parsable '%s'

View file

@ -82,7 +82,11 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
} }
templateData := templates.ParseTemplateData(h, orig) templateData := templates.ParseTemplateData(h, orig)
cmpl := completer.New(conf.Compose.AddressBookCmd, func(err error) { cmd := acctConfig.AddressBookCmd
if cmd == "" {
cmd = conf.Compose.AddressBookCmd
}
cmpl := completer.New(cmd, func(err error) {
aerc.PushError( aerc.PushError(
fmt.Sprintf("could not complete header: %v", err)) fmt.Sprintf("could not complete header: %v", err))
worker.Logger.Printf("could not complete header: %v", err) worker.Logger.Printf("could not complete header: %v", err)