From aaaa0c184fb43879cc84551983309cad06d665ee Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Wed, 1 Feb 2023 23:35:42 +0100 Subject: triggers: use templates instead of % mini language Since previous commit, all commands now support expanding text/template markup. Reuse that for the new-email trigger command. Update commands.ExecuteCommand to take optional *AccountConfig and *MessageInfo arguments. If these are nil, fallback to using the currently selected account and message (if any). Pass the proper *AccountConfig and *MessageInfo objects when firing the trigger command so that these are used instead of the currently selected ones. If new-email contains % placeholders, try to convert them to template markup reusing the same conversion added in commit 535300cfdbfc ("config: add columns based index format"). Warn the user that they need to update their configuration file. Signed-off-by: Robin Jarry Reviewed-by: Moritz Poldrack --- doc/aerc-config.5.scd | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 3669d26e..6e20fd71 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -821,17 +821,21 @@ message/rfc822=thunderbird # TRIGGERS -Triggers specify commands to execute when certain events occur. +Triggers specify commands to execute when certain events occur. They are +configured in the *[triggers]* section of _aerc.conf_. -They are configured in the *[triggers]* section of _aerc.conf_. +The commands are not shell commands (i.e. they are not executed with _sh -c_) +and will be split in multiple arguments following basic shell quoting. They need +to use one of the commands described in *aerc*(1) without the leading colon *:* +(e.g. _exec foo bar_ instead of _:exec foo bar_). *new-email* = __ - Executed when a new email arrives in the selected folder. + Executed when a new email arrives in the selected folder. Example: - e.g. new-email=exec notify-send "New email from %n" "%s" + exec notify-send 'New email from {{.From | names | join ", "}}' '{{.Subject}}' - Format specifiers from *index-format* are expanded with respect to the new - message. + Templates specifiers from *aerc-templates*(7) are expanded with respect + to the new message. # TEMPLATES -- cgit