about summary refs log tree commit diff stats
path: root/aerc.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-21 21:01:51 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-26 14:00:24 -0400
commitdc4c36adbfbffd34319ddc007bad437ef802ee72 (patch)
tree1742b507d27a9564c3f51623c01266cca8f9a267 /aerc.go
parent0950e39f538610172858a5e3b7582a7f5cb1fd64 (diff)
downloadaerc-dc4c36adbfbffd34319ddc007bad437ef802ee72.tar.gz
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.
Diffstat (limited to 'aerc.go')
-rw-r--r--aerc.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/aerc.go b/aerc.go
index ca131e6..2420b44 100644
--- a/aerc.go
+++ b/aerc.go
@@ -52,7 +52,7 @@ func getCommands(selected libui.Drawable) []*commands.Commands {
 	}
 }
 
-func execCommand(aerc *widgets.Aerc, ui *libui.UI, cmd string) error {
+func execCommand(aerc *widgets.Aerc, ui *libui.UI, cmd []string) error {
 	cmds := getCommands((*aerc).SelectedTab())
 	for i, set := range cmds {
 		err := set.ExecuteCommand(aerc, cmd)
@@ -144,11 +144,11 @@ func main() {
 		ui   *libui.UI
 	)
 
-	aerc = widgets.NewAerc(conf, logger, func(cmd string) error {
-			return execCommand(aerc, ui, cmd)
-		}, func(cmd string) []string {
-			return getCompletions(aerc, cmd)
-		})
+	aerc = widgets.NewAerc(conf, logger, func(cmd []string) error {
+		return execCommand(aerc, ui, cmd)
+	}, func(cmd string) []string {
+		return getCompletions(aerc, cmd)
+	})
 
 	ui, err = libui.Initialize(conf, aerc)
 	if err != nil {