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

Re: wish for a colored completion system



Bart Schaefer wrote:

> On Jun 9,  9:24am, Sven Wischnowsky wrote:
> } Subject: Re: wish for a colored completion system
> }
> } Bart Schaefer wrote:
> } 
> } > I'm not sure why ':completion:*:ssh:*' doesn't work for the combined
> } > listing; perhaps it's a bug.  Sven?
> } 
> } Hm, yes, the description in the docs make it sound as if it should
> } work. The problem is that without separate groups there is no way for
> } the completion code to find out that with
> } 
> }   zstyle ':completion:*:ssh:*:hosts' list-colors '=a*=31'
> }   zstyle ':completion:*:ssh:*:users' list-colors '=b*=32'
> } 
> } hosts starting with `b' should be coloured with `32'. We would need a
> } per-match colouring for that and that's too expensive.
> 
> I think you misunderstood my question.  I didn't ask why
> 
>     zstyle ':completion:*:ssh:*:hosts' list-colors '=a*=31'
> 
> doesn't work.  I asked why
> 
>     zstyle ':completion:*:ssh:*' list-colors '=a*=31'
> 
> doesn't work.  There isn't any group involved there at all; I don't ask
> for the hosts to be colored separately from the users; I just ask for
> anything that happens to be there (and that begins with `a') to work.
> But it doesn't, unless I set group-name ''.

;-) I understood that -- and noticed that the part you quoted doesn't
answer the question. That's why the next paragraph started the way it
did:

> And to come back to the question, the completion code only looks up
> the style with the tag in the context and it can't find out that the
> pattern used in the definition doesn't contain the tag. If we wanted
> to solve that, we would have to make _setup get the name of the group
> (which may be -default-) as an argument (when called from
> _description) and use that name in ZLS_COLORS. But then we would be
> back to what I said above.
> 
> So, we could (quite easily) change it, but that set-for-one-tag-and-
> used-for-others-too made me do it in the way we have it now, I would
> be willing to write the change if people say that they prefer it,
> though (I have group-name == '', so I don't care much about this).

I.e. _setup just uses the tag in ZLS_COLORS, as you've seen. To get
this right, we would shouldn't just make the colors be (almost) always 
used (11847) because that works only for functions using the
argument-* tags. Probably even more confusing.

The problem is really that the code in _setup can't find out what
pattern was used when defining the style. It should use the value for
`...:*:ssh:*' everywhere but it should use the one defined for
`:...:*:ssh:*:hosts' only for names of hosts. But since complist only
distinguishes between groups (and it can only do that), a setting for
the latter pattern would be used for usernames, too, if they are in
the same group and we change the calls to _setup as I suggested (and
then make it use that group name when adding things to ZSL_COLORS, of
course).

Hrm, maybe we should admit this and use the group name instead of the
tag when looking up list-colors.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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