* Redefining an array of widgets
@ 2011-06-12 21:34 Guido van Steen
2011-06-12 22:02 ` Mikael Magnusson
0 siblings, 1 reply; 2+ messages in thread
From: Guido van Steen @ 2011-06-12 21:34 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Redefining an array of widgets
2011-06-12 21:34 Redefining an array of widgets Guido van Steen
@ 2011-06-12 22:02 ` Mikael Magnusson
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Magnusson @ 2011-06-12 22:02 UTC (permalink / raw)
To: Guido van Steen; +Cc: zsh-users
On 12 June 2011 23:34, Guido van Steen <gvsteen@yahoo.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-12 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-12 21:34 Redefining an array of widgets Guido van Steen
2011-06-12 22:02 ` Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).