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

Re: trying to understand how the zsh completer works



On Feb 28,  9:56pm, Bart Schaefer wrote:
}
} In retrospect it might have been useful to split the context analysis
} from the generation of matches, rather than having a single function
} responsible for doing both parts for each command name.
} 
} The only workaround for this is to do your own context analysis and
} embed that in the style value via "zstyle -e".

... I had a mildy crazy idea that it should be possible to modify the
algorithm from _complete_help to create a function that could be called
from zstyle -e for the completer style.  This function would intuit the
contexts that would be used later when the completers themselves were
the callers, thereby allowing the list of completers to be modified for
the contexts they hadn't "really" created yet.

After working out some fairly convoluted recursion issues -- because
the completer style is being looked up in _main_complete, and then the
style evaluation wants to call _main_complete again to simulate what
the surrounding call in progess is going to do later -- I came up with
an example that generates all the deep contexts and successfully looks
up the value for the completer style in each of them.

Unfortunately, it still doesn't work, because to find the single most
specific context out of all the possible matching zstyle patterns is
equivalent to the zstyle internal algorithm for ordering patterns by
increasing specificity.  The simple ${(ok)...} used by _complete_help
is the wrong order nearly all the time.

If the preceding paragraph made sense to you, and you feel inclined
to implement order-by-context-specificity in _complete_help to replace
${(@ok)help_sfuncs} at around line 58, let me know what you come up
with.  Otherwise I may eventually get there.



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