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

Re: Hooking up to function definition via module

On Apr 18, 10:23am, Sebastian Gniazdowski wrote:
} So in theory I can analyze setopt arguments in bin_setopt2(), record
} which option is being set, even if it is already set to requested
} state, then call original bin_setopt().

Yes, but -- options can also be changed as a consequence of "emulate",
even long after the the emulate command has come and gone, because of
"sticky emulation" (emulate zsh -c 'myfunc() ...'); and there is a
moderate list of options that either can't be changed by setopt, or
that can't be unwound by localoptions.

} I think I cannot do something similar with function
} redefinition/definition, because there isn't a builtin dedicated to
} this, so I cannot wrap that builtin. But maybe I'm wrong?

You are correct -- function definitions are handled entirely by the
parser, there is no table-driven lookup that you can subvert.

Depending upon exactly what your goal is -- I'm guessing it's to make
a module for your plugin manager -- you might be able to do a lot of
the work with a function call wrapper.  See zprof.c for an example.

This is getting into zsh-workers territory rather than -users.

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