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

Re: Caching variables during completion



On Wed, 13 Feb 2013 09:39:24 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Crudely:
> 
> _xrcache() {
>   if (( $_xr_HISTNO != $HISTNO ))
>   then
>     _xr_HISTNO=$HISTNO
>     _xr_output=$(xrandr -q)
>   fi
>   return 1 # always "fail" so other completers are tried
> }
> zstyle ':completion:*' completer _xrcache _oldlist _expand _complete # etc.

I don't see why you couldn't put that inside the completion function
that needs the cache, so you don't need anything special with
completers:

_xrandr() {                               # except this is the file _xrandr
   if (( $_xr_HISTNO != $HISTNO ))
   then
     _xr_HISTNO=$HISTNO
     _xr_output=$(xrandr -q)
   fi
 
   # use $_xr_output here
}

pws



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