From cb48d5b547e53125857af154b3b0bb921030ba88 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 28 Oct 2023 22:08:56 -0400 Subject: [PATCH] compose: define useful vars in the editor's env Add AERC_ACCOUNT and AERC_ADDRESS_BOOK_CMD to the editor's environment when composing a message. These variables allow for per-account configuration of the editor and facilitate address completion when edit-headers = true. Changelog-added: `AERC_ACCOUNT` and `AERC_ADDRESS_BOOK_CMD` are now defined in the editor's environment when composing a message. Signed-off-by: Jason Cox Acked-by: Robin Jarry --- app/compose.go | 5 +++++ doc/aerc-config.5.scd | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/app/compose.go b/app/compose.go index bf1d32cb..75f90f12 100644 --- a/app/compose.go +++ b/app/compose.go @@ -1331,6 +1331,11 @@ func (c *Composer) showTerminal() error { c.acct.PushError(fmt.Errorf("could not start editor: %w", err)) } editor := exec.Command("/bin/sh", "-c", editorName+" "+c.email.Name()) + env := os.Environ() + env = append(env, fmt.Sprintf("AERC_ACCOUNT=%s", c.Account().Name())) + env = append(env, fmt.Sprintf("AERC_ADDRESS_BOOK_CMD=%s", c.Account().AccountConfig().AddressBookCmd)) + editor.Env = env + c.editor, err = NewTerminal(editor) if err != nil { return err diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index ef35fd12..45c12bd9 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -588,6 +588,14 @@ These options are configured in the *[compose]* section of _aerc.conf_. embedded terminal, though it may also launch a graphical window if the environment supports it. + The following variables are defined in the editor's environment: + + *AERC_ACCOUNT* + the name of the current account + *AERC_ADDRESS_BOOK_CMD* + the _address-book-cmd_ specified for the current account in + _accounts.conf_ + Defaults to *$EDITOR*, or *vi*(1). *header-layout* = __