zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Paul Seyfert <pseyfert@mathphys.fsk.uni-heidelberg.de>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH Completion for _yum (contains FIXMEs)
Date: Thu, 27 Oct 2016 01:30:54 +0000	[thread overview]
Message-ID: <20161027013054.GA15799@fujitsu.shahaf.local2> (raw)
In-Reply-To: <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


  reply	other threads:[~2016-10-27  1:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26 17:37 Paul Seyfert
2016-10-27  1:30 ` Daniel Shahaf [this message]
2016-10-31 12:09   ` Paul Seyfert
2016-11-10 10:18     ` Paul Seyfert
2016-11-10 15:49       ` Oliver Kiddle
2016-11-12  0:19         ` PATCH Completion for _yum Paul Seyfert
     [not found]           ` <31607.1478915523@hydra.kiddle.eu>
2016-11-22 19:05             ` caching mechanism and " Oliver Kiddle
2016-12-13 10:10               ` Oliver Kiddle
2016-12-13 16:18                 ` Jun T.
2016-12-13 17:21                   ` Bart Schaefer
2016-12-14 11:38                     ` Oliver Kiddle
2016-12-14 14:23                       ` Jun T.
2016-12-14 15:03                         ` Oliver Kiddle
2016-12-14 15:23                           ` Jun T.
2016-12-14 17:46                             ` Oliver Kiddle
2016-12-14 20:09                               ` Bart Schaefer
2016-12-15  9:38                               ` Peter Stephenson
2016-12-15 17:15                                 ` Before 5.3.1 (was Re: caching mechanism and Re: PATCH Completion for _yum) Bart Schaefer
2016-12-13 16:38                 ` caching mechanism and Re: PATCH Completion for _yum Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161027013054.GA15799@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=pseyfert@mathphys.fsk.uni-heidelberg.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).