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

Re: _multi_parts and -q

On Fri, 17 Jun 2011 14:50:08 -0700
Danek Duvall <duvall@xxxxxxxxxxxxxx> wrote:
> I was hoping that this
>     _wanted dataset expl "$expl_type" _multi_parts "$@" -q / datasetlist
> would add slashes as auto-removable suffixes, but it doesn't appear to.
> That is, if I type a slash immediately after a slash, it gets swallowed,
> but the slash doesn't disappear after hitting space or return.  Is this an
> issue with _multi_parts, or something I'm doing wrong?  I tried putting in
> -S/ explicitly, but that didn't seem to make a difference.

_multi_parts is completely impenetrable, with no fewer than *18* calls
to compadd, but there is some evidence it is handling the -q and -S
options (the zparseopts at the start) and using the resulting $sopts in
some places, which is what the documentation says it does, although
reading the documentation didn't entirely fill me with confidence that I
understood everything that was going on. 

Anyway I think the following is working as I expect:

  _wanted dataset expl "$expl_type" _multi_parts -S/ -q / datasetlist;  

in that:

- if I complete something ambiguous I don't get the suffix
- if I complete something unambiguous I do
- the suffix is removable with the usual features:
-- it's highlighted if you're using Mikael's autoremove highlighting
-- if I type a "/" it replaces the autoremovable "/"
-- if I type a " " the "/" goes and the " " stays
-- if I type a letter the "/" stays and the letter appears immediately

That's pretty much all I'm expecting.

Note that I use menu completion, which shouldn't make a difference at
this level but might do.

I was testing with this entirely spurious function:

_tst() {
  local expl_type="stuff"
  local -a datasetlist
  datasetlist=(foo bar rod stuff)
  local pref
  [[ $PREFIX = */* ]] && pref=${PREFIX%/*} 
  [[ -n $pref ]] && datasetlist=($pref/${^datasetlist})
  _wanted dataset expl "$expl_type" _multi_parts -S/ -q / datasetlist;

simply to get strings to compile.  I don't think that should matter.

Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

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