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

Re: Sort of PATCH: local completions



On Nov 2,  5:58pm, Peter Stephenson wrote:
> Subject: Sort of PATCH: local completions
> I'm sure this can be done much better.  This modifies the normal way of
> choosing a context-sensitive completion to allow you to have a special form
> in a particular directory. [...]
> 
> There is no way of making styles local.  This would take a certain amount
> of internal hacking.  [...]

Hrm.  I think the way I'd approach this whole "local completions" issue is
to alter the context used by the styles in the first place.

E.g., suppose the file .zcompcontext contains the string "zsh-source":

    chpwd() {
	[[ -f .zcompcontext ]] && curcontext="$(<.zcompcontext)":::
    }
    zstyle+ ':completion:zsh-source:*:make:*:targets' call-command yes
          + '' command _make_for_zsh_source

This is overloading the `function' field of the context, but what the hell.

You could still read the file with `source' instead, I suppose, and thus put
all the zstyle commands right there in the file, but the code would have to
get a whole lot more paranoid to avoid trojan horses.
-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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