diff --git a/complete.go b/complete.go index 5c621971..35c8ed10 100644 --- a/complete.go +++ b/complete.go @@ -22,6 +22,7 @@ var ( "cmd", "addcustominfo", "bottom", + "builtin", "calcdirsize", "cd", "clear", @@ -473,6 +474,10 @@ func completeCmd(acc []rune) (matches []compMatch, result string) { if len(f) == 2 { matches, result = matchCmdFile(f[1], false) } + case "builtin": + if len(f) == 2 { + matches, result = matchCmd(f[1]) + } case "toggle": matches, result = matchCmdFile(f[len(f)-1], false) default: diff --git a/eval.go b/eval.go index b89def17..4a29b538 100644 --- a/eval.go +++ b/eval.go @@ -958,6 +958,27 @@ func exitCompMenu(app *app) { func (e *callExpr) eval(app *app, _ []string) { os.Setenv("lf_count", strconv.Itoa(e.count)) + noOverride := []string{ + "open", + "paste", + "delete", + "rename", + } + + if e.name == "builtin" { + if len(e.args) == 0 { + app.ui.echoerr("builtin: requires at least 1 argument") + return + } else if e.args[0] == "builtin" { + app.ui.echoerr("builtin: recursive call") + return + } + e.name, e.args = e.args[0], e.args[1:] + } else if cmd, ok := gOpts.cmds[e.name]; ok && !slices.Contains(noOverride, e.name) { + cmd.eval(app, e.args) + return + } + silentCmds := []string{ "addcustominfo", "clearmaps", @@ -2260,12 +2281,7 @@ func (e *callExpr) eval(app *app, _ []string) { case "on-init": onInit(app) default: - cmd, ok := gOpts.cmds[e.name] - if !ok { - app.ui.echoerrf("command not found: %s", e.name) - return - } - cmd.eval(app, e.args) + app.ui.echoerrf("command not found: %s", e.name) } }