Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: context for globbing qualifiers based on command
- X-seq: zsh-users 16818
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: context for globbing qualifiers based on command
- Date: Wed, 29 Feb 2012 19:32:23 +0100
- Authentication-results: mr.google.com; spf=pass (google.com: domain of mikachu@xxxxxxxxx designates 10.224.173.66 as permitted sender) smtp.mail=mikachu@xxxxxxxxx; dkim=pass header.i=mikachu@xxxxxxxxx
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qVYYfij3YdctDRksGUDL7yhFpn85f8c43/+9G/RDzNw=; b=pB2v8QmGv9nONFCWJ8flQejODATWBrF2HiCbdWMY+ohPA+jrj+O+H2euYws8boipuE E9Tj0MG2oUC60/UDDZKPeCF76H2qJHcwLIXxArjgkmwsME9lRdiz+2dhbJw7hkUC14CN WD2rmNITxfw2wg4EFSDqzNlt9INytbZ615T9w=
- In-reply-to: <120229102216.ZM27937@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4F4B58FE.3070008@googlemail.com> <120229102216.ZM27937@torch.brasslantern.com>
On 29 February 2012 19:22, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> (It wasn't necessary to send this inquiry twice. It sometimes takes a
> little while for a response.)
>
> On Feb 27, 11:20am, Martin Richter wrote:
>>
>> Is it possible to tweak the completion such that shell functions are
>> grouped at the top when pressing TAB when using (:e...) on a given command?
>> print -l *(e:TAB --> gives a lot of possible functions etc
>> but
>> special_command *(e:TAB
>> gives only shell function matching some regexp or gives only the single
>> function 'foo' or members of an array of functions?
>
> Unfortunately, no. The zstyle context after *(e: is identical to the
> context in any other command position.
>
> However, the $words array hasn't been altered, so you could write a
> function to be installed in your "completer" style that examines the
> values of $words[1] and $words[CURRENT], something like this:
>
> _special_command_glob_completer() {
> if [[ CURRENT -gt 1 &&
> "$words[1]" = 'special_command' &&
> "$words[CURRENT]" = *\(*e:* ]]
> then
> compset -p ${#words[CURRENT]}
> compadd -J special-globbers sum_equals product_equals
> return 0
> else
> return 1
> fi
> }
>
> zstyle ':completion:*' completer _expand \
> _special_command_glob_completer \
> _complete _match _ignored _approximate _prefix
>
> (the rest of that completer style is just for example, but you probably
> want at least _complete in there after your special one).
>
> It might also be possible to do this more generically with a "matcher"
> zstyle in the context :completion::complete:-command-::* but I'll leave
> that for someone else to work out. (It'd have to use "zstyle -e" and
> some kind of test similar to the "if" above.)
You can probably do this a bit less fragilely with $zsh_eval_context:
% print -l $(echo .(e:'reply=($zsh_eval_context)':))
cmdsubst
globqual
toplevel
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author