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

Re: Hooks

On 11/7/06, Peter Stephenson <pws@xxxxxxx> wrote:
Stephane Chazelas <Stephane_Chazelas@xxxxxxxx> wrote:
> functions[preexec]+='
>   get_saved_dirstack'
> functions[chpwd]+='
>   save_dirstack'

This is even further away from the original subject, but I've often felt
that functions like preexec and chpwd are getting a bit overloaded and
are unnecessarily hard to maintain automatically.  It would be easy to
add an array which could contain names of functions to be executed,
similar to Emacs hooks.  Of course you can implement such an array
within the existing functions, but the advantage of having a fixed
mechanism is that it's easy to add to and be sure it's working without
getting in anyone else's way.  You still have namespace problems, of
course, but if you have functions called get_saved_dirstack and
save_dirstack that clash your real problem is almost certainly more
basic than naming.

However, I'm not sure if it's really needed.

Yes, please do add.  It's a real, em...lady of the night, to try to
chain all these functions properly (i.e., checking if preexec is
defined and then try to get its definition or however I did it when I
did it last time (I did this for a prompt that was depended on the
value of $WIDTH, so I read it on each preexec, but I also had another
function running at preexec, so I had to get that other functions body
and eval it from the prompt preexec instead.).



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