From dc4c36adbfbffd34319ddc007bad437ef802ee72 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Sun, 21 Jul 2019 21:01:51 +0100 Subject: Add new-email trigger This patch sets up the trigger config section of aerc.conf. Each trigger has its own function which is called from the place where it is triggered. Currently only the new-email trigger is implemented. The triggers make use of format strings. For instance, in the new-email trigger this allows the user to select the trigger command and also the information extracted from the command and placed into their command. To actually execute the trigger commands the keypresses are simulated. Further triggers can be implemented in the future. Formatting of the command is moved to a new package. --- widgets/account.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'widgets/account.go') diff --git a/widgets/account.go b/widgets/account.go index f070df14..92e7a560 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -203,7 +203,11 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { if store, ok := acct.msgStores[msg.Info.Name]; ok { store.Update(msg) } else { - store = lib.NewMessageStore(acct.worker, msg.Info) + store = lib.NewMessageStore(acct.worker, msg.Info, + func(msg *models.MessageInfo) { + acct.conf.Triggers.ExecNewEmail(acct.acct, + acct.conf, msg) + }) acct.msgStores[msg.Info.Name] = store store.OnUpdate(func(_ *lib.MessageStore) { store.OnUpdate(nil) -- cgit