Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Multi-level keybinding?



On Dec 21, 12:50am, Richard Hartmann wrote:
}
} > Reading this I'm not sure what output you want from "binding_overview".
} 
} Ideally, I would want the keybinding for ^X to be executed each and
} every time a keybinding starting with ^X is called. But ZLE should
} still listen for another key.

What's the connection between having the same keystroke execute more
than one widget, and having a keystroke that displays an overview of
the bindings?  Do you really want the explanation printed every time
the keystroke executes?

} I.e. both the widget for ^X and ^Xn are executed when I press ^Xn
} a single time.

Well, the way you do that is with a wrapper widget that uses the name
to which it is bound to decide what other function to run.  Something
like this:

  ctrl-x () {
    BUFFER+=" Hi there, I'm ${(V)KEYS}."
  }
  zle -N ctrl-x
  bindkey ^X ctrl-x

  ctrl-x-prefix () {
    zle ctrl-x
    $WIDGET
  }
  do-something () {
    BUFFER+=" Pleased to meet you, I'm $WIDGET."
  }
  zle -N do-something ctrl-x-prefix
  bindkey ^Xn do-something

  do-anything () {
    CURSOR=0
    LBUFFER="Move over for $WIDGET "
  }
  zle -N do-anything ctrl-x-prefix
  bindkey ^Xa do-anything



Messages sorted by: Reverse Date, Date, Thread, Author