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

Re: Redefining an array of widgets



On 12 June 2011 23:34, Guido van Steen <gvsteen@xxxxxxxxx> wrote:
> Dear List
>
> I would like to "overload/redefine" some widgets. What I have in mind is this:
>
> Each time the widgets are called, some additional task should be performed first. After that the actual widget should be called.
>
> It seems easy to do this for one or two widgets, e.g. "delete-char", and "backward-delete-char":
>
> user% function delete-char() {
> function>       zle do_some_stuff
> function>       zle .delete-char
> function>  }
> user% zle -N delete-char
> user% function backward-delete-char() {
> function>       zle do_some_stuff
> function>       zle .backward-delete-char
> function>  }
> user% zle -N backward-delete-char
>
> However, things would be a lot more flexible if I could define a list of widgets, such as:

The easiest way to do this is something like this
function do-some-stuff-and-widget() {
  zle do_some_stuff
  zle .$WIDGET
}
zle -N backward-delete-char do-some-stuff-and-widget
zle -N ...
for every widget you want to override. You can use a for loop to call
zle multiple times.

-- 
Mikael Magnusson



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