Skip to content

Commit

Permalink
compose: define useful vars in the editor's env
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
jasonccox authored and rjarry committed Nov 22, 2023
1 parent 0be34bb commit cb48d5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions doc/aerc-config.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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* = _<header|layout,list...>_
Expand Down

0 comments on commit cb48d5b

Please sign in to comment.