diff --git a/complete.go b/complete.go index d2e04dcc..125eeaca 100644 --- a/complete.go +++ b/complete.go @@ -16,6 +16,7 @@ var ( "cmap", "cmaps", "cmd", + "cmds", "quit", "up", "half-up", diff --git a/doc.go b/doc.go index 096cf5f1..e7c15e45 100644 --- a/doc.go +++ b/doc.go @@ -81,6 +81,7 @@ The following commands are provided by lf: tag-toggle (default 't') maps cmaps + cmds jumps The following command line commands are provided by lf: @@ -620,6 +621,10 @@ Capitalize/uppercase/lowercase the current word and jump to the next word. List all key mappings in normal mode or command-line editing mode. + cmds + +List all custom commands defined using the `cmd` command + jumps List the contents of the jump list, in order of the most recently visited locations. diff --git a/docstring.go b/docstring.go index f7166701..1c1c5e27 100644 --- a/docstring.go +++ b/docstring.go @@ -84,6 +84,7 @@ The following commands are provided by lf: tag-toggle (default 't') maps cmaps + cmds jumps The following command line commands are provided by lf: @@ -648,6 +649,10 @@ Capitalize/uppercase/lowercase the current word and jump to the next word. List all key mappings in normal mode or command-line editing mode. + cmds + +List all custom commands defined using the 'cmd' command + jumps List the contents of the jump list, in order of the most recently visited diff --git a/eval.go b/eval.go index 0ddf107f..fea83177 100644 --- a/eval.go +++ b/eval.go @@ -2525,6 +2525,8 @@ func (e *callExpr) eval(app *app, args []string) { app.ui.cmdAccLeft = acc update(app) + case "cmds": + app.runPagerOnText(listCmds()) case "maps": app.runPagerOnText(listBinds(gOpts.keys)) case "cmaps": diff --git a/lf.1 b/lf.1 index 6de2b894..e749bfea 100644 --- a/lf.1 +++ b/lf.1 @@ -96,6 +96,7 @@ The following commands are provided by lf: tag-toggle (default 't') maps cmaps + cmds jumps .EE .PP @@ -764,6 +765,12 @@ Capitalize/uppercase/lowercase the current word and jump to the next word. .PP List all key mappings in normal mode or command-line editing mode. .PP +.EX + cmds +.EE +.PP +List all custom commands defined using the `cmd` command +.PP .EX jumps .EE diff --git a/ui.go b/ui.go index 4c013916..aed11534 100644 --- a/ui.go +++ b/ui.go @@ -1052,7 +1052,7 @@ func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok b return } -func listBinds(binds map[string]expr) *bytes.Buffer { +func listExprMap(binds map[string]expr, title string) *bytes.Buffer { t := new(tabwriter.Writer) b := new(bytes.Buffer) @@ -1063,7 +1063,7 @@ func listBinds(binds map[string]expr) *bytes.Buffer { sort.Strings(keys) t.Init(b, 0, gOpts.tabstop, 2, '\t', 0) - fmt.Fprintln(t, "keys\tcommand") + fmt.Fprintf(t, "%s\tcommand\n", title) for _, k := range keys { fmt.Fprintf(t, "%s\t%v\n", k, binds[k]) } @@ -1072,6 +1072,14 @@ func listBinds(binds map[string]expr) *bytes.Buffer { return b } +func listBinds(binds map[string]expr) *bytes.Buffer { + return listExprMap(binds, "keys") +} + +func listCmds() *bytes.Buffer { + return listExprMap(gOpts.cmds, "name") +} + func listJumps(jumps []string, ind int) *bytes.Buffer { t := new(tabwriter.Writer) b := new(bytes.Buffer)