Skip to content

Commit

Permalink
Merge pull request #43 from reeflective/dev
Browse files Browse the repository at this point in the history
Change parameters to print binds
  • Loading branch information
maxlandon authored Jun 2, 2023
2 parents 60d0cc7 + 41099fd commit 9d58023
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion emacs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ func (rl *Shell) dumpFunctions() {
}()

inputrcFormat := rl.Iterations.IsSet()
rl.Keymap.PrintBinds(inputrcFormat)
rl.Keymap.PrintBinds(string(rl.Keymap.Main()), inputrcFormat)
}

// Print all of the settable variables and their values to
Expand Down
7 changes: 1 addition & 6 deletions internal/keymap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ func printBindsReadable(commands []string, all map[string][]string) {

switch {
case len(commandBinds) == 0:
fmt.Printf("%s is not bound to any keys\n", command)

case len(commandBinds) > 5:
var firstBinds []string

Expand Down Expand Up @@ -143,10 +141,7 @@ func printBindsInputrc(commands []string, all map[string][]string) {
commandBinds := all[command]
sort.Strings(commandBinds)

switch {
case len(commandBinds) == 0:
fmt.Printf("# %s (not bound)\n", command)
default:
if len(commandBinds) > 0 {
for _, bind := range commandBinds {
fmt.Printf("\"%s\": %s\n", bind, command)
}
Expand Down
7 changes: 5 additions & 2 deletions internal/keymap/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (m *Engine) IsEmacs() bool {
// PrintBinds displays a list of currently bound commands (and their sequences)
// to the screen. If inputrcFormat is true, it displays it formatted such that
// the output can be reused in an .inputrc file.
func (m *Engine) PrintBinds(inputrcFormat bool) {
func (m *Engine) PrintBinds(keymap string, inputrcFormat bool) {
var commands []string

for command := range m.commands {
Expand All @@ -138,7 +138,10 @@ func (m *Engine) PrintBinds(inputrcFormat bool) {

sort.Strings(commands)

binds := m.config.Binds[string(m.Main())]
binds := m.config.Binds[keymap]
if binds == nil {
return
}

// Make a list of all sequences bound to each command.
allBinds := make(map[string][]string)
Expand Down

0 comments on commit 9d58023

Please sign in to comment.