From 54ba3cdb4f92cbc066675fe9d75d7ebb65ca1d98 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sat, 21 Jun 2025 03:04:37 +0200 Subject: [PATCH] Make PluginCB() a variadic function So that we can pass extra arguments to bufpane callbacks easily, by passing them directly to PluginCB(). --- internal/action/bufpane.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index f748b085..9cb54861 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -321,9 +321,16 @@ func (h *BufPane) ResizePane(size int) { } // PluginCB calls all plugin callbacks with a certain name and displays an -// error if there is one and returns the aggregate boolean response -func (h *BufPane) PluginCB(cb string) bool { - b, err := config.RunPluginFnBool(h.Buf.Settings, cb, luar.New(ulua.L, h)) +// error if there is one and returns the aggregate boolean response. +// The bufpane is passed as the first argument to the callbacks, +// optional args are passed as the next arguments. +func (h *BufPane) PluginCB(cb string, args ...interface{}) bool { + largs := []lua.LValue{luar.New(ulua.L, h)} + for _, a := range args { + largs = append(largs, luar.New(ulua.L, a)) + } + + b, err := config.RunPluginFnBool(h.Buf.Settings, cb, largs...) if err != nil { screen.TermMessage(err) }