Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH Completion for _yum (contains FIXMEs)
- X-seq: zsh-workers 39735
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Paul Seyfert <pseyfert@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: PATCH Completion for _yum (contains FIXMEs)
- Date: Thu, 27 Oct 2016 01:30:54 +0000
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=FpVyxwCeuZJw0yTKwo9ptf7nsm8=; b=k3NVC0LZz9Cx762QUTEEo hzKvIXzCZU/IfnGznvbmmFXg6lgjznO5XG74ycjJQ5H7uWzq91qSJjZYmvRRPW2T lrCoIe+0n/lBVgGvVzfg720dlFdzIWrMhjNCHHiJvo/rMWfaLSa9wyuFajMBV0Vx 8cKuOg/ISg6TSAVb80ijJg=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=FpVyxwCeuZJw0yTKwo9ptf7nsm8=; b=FpBj4TMT9hJ9ZYKcSAkj PvJauW3/LFTiAoZuZTLiU9QzE5g9qxCSn3tPP2PA76bu+Nx5R08INay3aPyra29E AAyd6sG5HV5wNgQ6VqOGd+t1hJOmOVNaHSzG1wkO5L2rANOuxb5IFp9HDfbKAbDV bswoV1EfULt2yjzRAWBuGJg=
- In-reply-to: <61b3fb7c-4de6-d8da-29b4-b3802d98b162@mathphys.fsk.uni-heidelberg.de>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <61b3fb7c-4de6-d8da-29b4-b3802d98b162@mathphys.fsk.uni-heidelberg.de>
I've taken a look at the FIXMEs — answers below — but haven't done
a full review.
Paul Seyfert wrote on Wed, Oct 26, 2016 at 19:37:21 +0200:
> There are two fixmes for which I'd need suggestions. Some of the yum
> history commands take IDs of past transactions. Single IDs or ID ranges,
> e.g.
>
> yum history list 3..16
>
> where IDs range from 1 to
> `yum history stats | grep Transactions | sed "s/.*: //"`
>
> At the moment, there are just '1' '2' '3' '1..2' '1..3' '2..3' hard
> coded as place holders. I don't know what's a sensible way to provide
> a completion for these.
Something like this:
.
_id_ranges() { if compset -P '*..'; then _ids; else _ids -S ..; fi }
.
where _ids() is a function that adds "1" "2" "3" as completions.
There should be examples of this in the revision ranges handling in
_git/_hg/_subversion.
> + if [[ -n "${ID_commands[(r)$words[2]]}" ]]; then
> + description+="IDs"
> + # FIXME: hard coded IDs just a draft
> + suggests+=('last' 'all' 1 2 3)
> + fi
> + if [[ -n "${ID_range_commands[(r)$words[2]]}" ]]; then
> + if [[ -n $description ]] ; then description+=", "; fi
> + description+="ID ranges"
> + # FIXME: hard coded IDs just a draft
> + suggests+=('1..2' '2..3' '1..3')
> + fi
> + if [[ -n "${package_commands[(r)$words[2]]}" ]]; then
> + if [[ -n $description ]] ; then description+=", "; fi
> + description+="packages"
> + _yum_installed_pkgs
> + suggests+=($_installed_pkgs)
> + fi
> + if [[ ! -n $description ]] ; then
> + _message "unknown expansion for: yum history $words[2]"
> + else
> + _describe $description suggests
> + fi
> + fi
This looks like it would be better written with _alternative:
alts=()
[[ -n "${ID_range_commands[(r)$words[2]]}" ]] && alts+=( 'id-ranges:id ranges:_id-ranges' )
[[ -n "${package_commands[(r)$words[2]]}" ]] && alts+=( 'packages:packages:...' )
⋮
(( ${+alts[1]} )) && _alternative "$alts[@]"
To see the difference, set the «group-name» style to «''» (and
optionally the «format» style to something with «%d» in it). You can
see this in «ssh <TAB>» too (compare with/without those two styles).
Let's see what the other devs have to say about the rest of the patch.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author