Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: context for globbing qualifiers based on command
- X-seq: zsh-users 16819
- 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:33:57 +0100
- Authentication-results: mr.google.com; spf=pass (google.com: domain of mikachu@xxxxxxxxx designates 10.224.173.72 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=vJXTmGfzLr2V6/L0fpmeQ4JecM5y+aathqaauJQQU9c=; b=q98XQztm1U7vIQ8pET3hhNsQFM71FfS7+Ody14bkTogOO8Niqq0UqyEdFsf0oF9DqV d8TupYDI3rO/KxoN6nFpYMMAIupn8KGA3vy/tDCFHHTYUTTmaHzvW+uDoFFdt5Rmi0q5 15Vb2ASqqWcijbBpOVEJXcG3nU/tky1/z6yik=
- In-reply-to: <CAHYJk3QOtFEeqRQeM3nGGt6OR1i9ynio_ZtGh5pv6aGhJ=O99g@mail.gmail.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> <CAHYJk3QOtFEeqRQeM3nGGt6OR1i9ynio_ZtGh5pv6aGhJ=O99g@mail.gmail.com>
On 29 February 2012 19:32, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> 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
Ignore that :).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author