zsh-workers
 help / color / mirror / code / Atom feed
* Module zsh/complist and coloring
@ 2008-08-27 14:02 Julius Plenz
  2008-08-30 11:43 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Julius Plenz @ 2008-08-27 14:02 UTC (permalink / raw)
  To: zsh-workers

Hi folks!

What has bugged me quite a while now is the following: completions
that add file names but don't use _path_files to add them (but simply
compadd) don't get coloring of the matches. I traced this down to the
-f option of compadd that marks the matches as being filenames.

This doesn't seem to help much, though. For example in _remote_files,
if I add the -f argument to the compadd call, *some* files and
directories are colored -- those that exist on the remote *and* the
local system. So compadd seems to look up the file type of each match.

Strangely enough, patterns like *.jpeg=1;32 in LS_COLORS (whose value
is also used for the list-colors style, which also correctly sets
ZLS_COLORS during completion) should work nevertheless, shouldn't
they? My guess is, that, if compadd doesn't find the file, these
patterns aren't tried at all.

Of course this behaviour is intended, so that non-files (i.e., long
option names or simpe values) are not misleadingly colored. But
especially for _remote_files, from the trailing slash you can tell
directories from files apart. Since you cannot download non-files,
it'd make sense to have a possibility to tell compadd or the complist
module that the matches are all valid filenames, no need for checking
that.

What do you think?

Julius


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Module zsh/complist and coloring
  2008-08-27 14:02 Module zsh/complist and coloring Julius Plenz
@ 2008-08-30 11:43 ` Peter Stephenson
  2008-08-30 14:16   ` Julius Plenz
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2008-08-30 11:43 UTC (permalink / raw)
  To: zsh-workers

On Wed, 27 Aug 2008 16:02:21 +0200
Julius Plenz <julius@plenz.com> wrote:
> Since you cannot download non-files,
> it'd make sense to have a possibility to tell compadd or the complist
> module that the matches are all valid filenames, no need for checking
> that.

Sounds plausible, although you'd only get half the full effect unless
you could also supply the file type (most particularly directory or
regular file).

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Module zsh/complist and coloring
  2008-08-30 11:43 ` Peter Stephenson
@ 2008-08-30 14:16   ` Julius Plenz
  0 siblings, 0 replies; 3+ messages in thread
From: Julius Plenz @ 2008-08-30 14:16 UTC (permalink / raw)
  To: zsh-workers

Hi!

* Peter Stephenson <p.w.stephenson@ntlworld.com> [2008-08-30 13:43]:
> Julius Plenz <julius@plenz.com> wrote:
> > Since you cannot download non-files, it'd make sense to have a
> > possibility to tell compadd or the complist module that the
> > matches are all valid filenames, no need for checking that.
> 
> Sounds plausible, although you'd only get half the full effect
> unless you could also supply the file type (most particularly
> directory or regular file).

Well, you can! In that same mail I also wrote:

> But especially for _remote_files, from the trailing slash you can
> tell directories from files apart.

I figured out a way to emulate the coloring, although (because you
don't have access to the file attributes) you can color the matches
only per extension. This snippet displays directories and files in the
colors supplied by $LS_COLORS:

  scp_colors=("=(#b)(*)/=0="${${${(s.:.)LS_COLORS}[(r)di=<->]}/di=/})
  for c (${(s.:.)LS_COLORS})
    [[ $c == \** ]] && scp_colors+=('='$c)
  zstyle ':completion::*:scp:*' list-colors $scp_colors
  unset scp_colors

Actually, you can boil this down to a single zstyle call:

  zstyle ':completion::*:scp:*' list-colors \
    "=(#b)(*)/=0="${${${(s.:.)LS_COLORS}[(r)di=<->]}/di=/} \
    '='${^${(M)${(s.:.)LS_COLORS}:#\**}}

Of course, the coloring for local files is also changed when you want
to upload local files using scp. I don't think there's a way to tell
from the context whether you're completing local or remote files. This
solution is not too bad, though.

Greetings,
Julius


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-30 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 14:02 Module zsh/complist and coloring Julius Plenz
2008-08-30 11:43 ` Peter Stephenson
2008-08-30 14:16   ` Julius Plenz

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).