cmds command to list all custom commands (aka cmd mappings) (#1265)

This is a natural complement to the recently introduces `maps` and `cmaps`.

I considered using a different output format, since `cmd` definitions can be
long, but I decided against it for now. `lf` already abbreviates commands that
take up several lines, and we can change the output format later if needed.
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2023-06-04 16:05:13 +03:00
1 parent a9d90bc560
commit b57d76bf97
6 files changed
+30 -2

No files matched your search

+10 -2
View File
@@ -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)