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

Redefining an array of widgets



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: 

user% widgets_to_be_overloaded=(delete-char backward-delete-char)

and then perform some pseudo code like: 

user% for i in {1..$#widgets_to_be_overloaded}; do 
for>    function $widgets_to_be_overloaded[i]() {
for function>           region_highlight=()
for function>           zle .$widgets_to_be_overloaded[i]
for function>   }
for> zle -N $widgets_to_be_overloaded[i] 
for> done 

As I actually had expected, this pseudo code does not work. It reports, instead: 

zsh: no matches found: widgets_to_be_overloaded[i]

Could someone explain to me what I should change to make it yield the intended results. 

Thanks in advance! 

Guido van Steen 




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