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

Strange or interesting zcompile behavior, for in-loop func defs



Hello,
I've added debugging message in execfuncdef():

        if (state->prog->dump || !names) {
            if (!names) {
                ...
            } else {
                fprintf( stderr, "Have dump for: %s, file: %s\n", s, state->prog->dump->filename);
                fflush( stderr );
                prog->flags = EF_MAP;
                incrdumpcount(state->prog->dump);

It outputs:

Have dump for: _zsh_highlight_widget_zle-isearch-update, file: /Users/sgniazdowski/.zplugin/lexicon.zwc

The point is: this function is declared in a loop:

         if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
           _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }

I do zcompile lexicon.zwc ~/.zplugin/lexicon/*, the directory contains function with the loop. Zcompile apparently picks up above function definition. But from where it gets ${cur_widget}? This is a dynamic data, established at runtime.

The loop:

https://github.com/zdharma/fast-syntax-highlighting/blob/07a76cd38123cac2e76aca35c0258d62b18ab490/fast-syntax-highlighting.plugin.zsh#L203-L240

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org



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