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

Re: Escaping of : in a _describe completion



On Saturday 11 of April 2009 12:15:26 Frank Blendinger wrote:
> Hi.
>
> On Sat 2009-04-11 09:09, Andrey Borzenkov <arvidjaar@xxxxxxxxx>
>
> proclaimed:
> > On Saturday 11 of April 2009 06:03:19 Frank Blendinger wrote:
> > > Hi,
> > >
> > > I am trying to build a small completion for etherwake, which
> > > gives me some MAC addresses together with their hostnames as
> > > descriptions. I came up with something like this:
> > >
> > >     _etherwake() {
> > >         typeset -a etherwake_desc;
> > >
> > > etherwake_desc=("00:0c:6e:74:16:77:host1";"00:1b:63:31:4a:6b:host
> > >2"); _describe etherwake etherwake_desc;
> > >     }
> > >     compdef _etherwake etherwake
> > >
> > > This does not work, however, as the first `:' of each string in
> > > the etherwake_desc array is used to separate the completion from
> > > the description. I tried escaping the `:' characters of the MAC
> > > addresses with `\', which did not help. Neither did putting ' or
> > > \" around the MAC addresses.
> > >
> > > How can I do it right?
> >
> > etherwake_desc=('00\:0c\:6e\:74\:16\:77:host1'
> > '00\:1b\:63\:31\:4a\:6b:host2')
>
> Thanks for your suggestion, but that does not work either.

It does here so you must be doing something differently.

{pts/3}% _etherwake() {
 typeset -a etherwake_desc;
 etherwake_desc=('00\:0c\:6e\:74\:16\:77:host1' 
'00\:1b\:63\:31\:4a\:6b:host2');
 _describe etherwake etherwake_desc;
 }
{pts/3}% compdef _etherwake etherwake
{pts/3}% etherwake 00:0c:6e:74:16:77
Completing etherwake
00:0c:6e:74:16:77  -- host1
00:1b:63:31:4a:6b  -- host2


> It will
> complete the leading ``00:'' part, but then it stops.

You have to "setopt menucomplete" to make it display lists immediately. 
Default it to insert longest common prefix and wait for you to 
disambiguate.

> Pressing <Tab>
> again after that won't bring up the completion menu, as zsh does for
> my other completions, even if I manually enter a `0' or `1' to
> distinguish the both available arguments.

Enter where? Anyway, this is completely different problem. Now 
*completion* is correct but *display* not :)

Could you show you options and styles (setopt; zstyle -L)?

Attachment: signature.asc
Description: This is a digitally signed message part.



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