From 20747fcf104aa05bdc4d7d2b12a2488940bcae2f Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Wed, 10 May 2023 23:56:24 +0200 Subject: commands: expand and complete template code Expand and complete template code. The exline does understand template code and can evaluate it. With this patch, the completion systems supports writing the templates by showing the available template data fields and template functions. Pressing after }} will show the evaluated template in the completion menu. Complex template code, such as if-else statements work as well. Examples: :filter -f {{ will show the possible template data fields and functions :filter -f {{index (.To|email) 0}} will show the value of the template expression in the completion list Pressing twice after a completed template expression will substitute the expression with its value. :{{if match .Folder "INBOX"}}check-mail{{else}}cf INBOX{{end}} Signed-off-by: Koni Marti Acked-by: Robin Jarry --- main.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 9dd166fe..a403c751 100644 --- a/main.go +++ b/main.go @@ -89,6 +89,9 @@ func execCommand( } func getCompletions(aerc *widgets.Aerc, cmd string) ([]string, string) { + if options, prefix, ok := commands.GetTemplateCompletion(aerc, cmd); ok { + return options, prefix + } var completions []string var prefix string for _, set := range getCommands(aerc.SelectedTabContent()) { -- cgit