* Re: completion: highlight matching part [not found] ` <080803103117.ZM26039@torch.brasslantern.com> @ 2008-08-04 0:33 ` Bart Schaefer 2008-08-04 19:44 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2008-08-04 0:33 UTC (permalink / raw) To: zsh-workers [> workers] On Aug 3, 10:31am, Bart Schaefer wrote: } Subject: Re: completion: highlight matching part } } The complist module installs some defaults if $LS_COLORS is empty. The } problem is that the form beginning with an equal or a star is supposed } to take precedence over those defaults, but it does not. Instead (if } I'm reading the code correctly) it takes precedence only over explicit } settings of all the possible $LS_COLORS colorings. I've tracked this (by a much more roundabout route than necessary) to PWS's patch 25006, in which he asserts (for compatibility with GNU ls) that "File type tests from stat should come before extension tests." The documentation still says that extension tests win and file type tests come last, so this should have been changed at the same time that complist.c was modified. But clearly in this instance we want pattern tests to take precedence over file type tests. I don't think there's any equivalent in GNU ls to this particular zsh-ism, so we have several choices: (1) Change complist.c:putfilecol() so that pattern tests come first, then mode tests, and finally extension tests. (2) Do something convoluted where we check for an extension match, but if we find one, try the mode tests before returning the extension color. We end up with a sort of rock-paper-scissors behavior, where modes beat extensions beat patterns beat modes. (3) Simply update the doc and make it impossible to do what Tomasz originally asked for, except in old versions of the shell that are not GNU ls compatible. (4) Revert to the pre-25006 behavior. Obviously the doc needs updating no matter what (in case 4, to point out that we're not compatible with ls). I have the impression that prior to this discussion the backref-using patterns for completion coloring were not particularly widespread, so it probably won't cause any major upheaval whichever way we go. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-04 0:33 ` completion: highlight matching part Bart Schaefer @ 2008-08-04 19:44 ` Peter Stephenson 2008-08-04 23:54 ` Bart Schaefer 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2008-08-04 19:44 UTC (permalink / raw) To: zsh-workers On Sun, 03 Aug 2008 17:33:21 -0700 Bart Schaefer <schaefer@brasslantern.com> wrote: > (1) Change complist.c:putfilecol() so that pattern tests come first, > then mode tests, and finally extension tests. I should think this is the right thing to do, isn't it? -- Peter Stephenson <p.w.stephenson@ntlworld.com> Web page now at http://homepage.ntlworld.com/p.w.stephenson/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-04 19:44 ` Peter Stephenson @ 2008-08-04 23:54 ` Bart Schaefer 2008-08-05 0:16 ` Bart Schaefer 0 siblings, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2008-08-04 23:54 UTC (permalink / raw) To: zsh-workers On Aug 4, 8:44pm, Peter Stephenson wrote: } Subject: Re: completion: highlight matching part } } On Sun, 03 Aug 2008 17:33:21 -0700 } Bart Schaefer <schaefer@brasslantern.com> wrote: } > (1) Change complist.c:putfilecol() so that pattern tests come first, } > then mode tests, and finally extension tests. } } I should think this is the right thing to do, isn't it? I agree, but wanted to mention the other options because this is arguably the most distant from what zsh used to do (before workers/25006). ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-04 23:54 ` Bart Schaefer @ 2008-08-05 0:16 ` Bart Schaefer 2008-08-05 8:13 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2008-08-05 0:16 UTC (permalink / raw) To: zsh-workers On Aug 4, 4:54pm, Bart Schaefer wrote: } Subject: Re: completion: highlight matching part } } On Aug 4, 8:44pm, Peter Stephenson wrote: } } Subject: Re: completion: highlight matching part } } } } On Sun, 03 Aug 2008 17:33:21 -0700 } } Bart Schaefer <schaefer@brasslantern.com> wrote: } } > (1) Change complist.c:putfilecol() so that pattern tests come first, } } > then mode tests, and finally extension tests. } } } } I should think this is the right thing to do, isn't it? } } I agree Here's the patch, mostly so you can proof my doc change. Index: Doc/Zsh/mod_complist.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_complist.yo,v retrieving revision 1.24 diff -u -r1.24 mod_complist.yo --- Doc/Zsh/mod_complist.yo 5 Jul 2008 19:55:29 -0000 1.24 +++ Doc/Zsh/mod_complist.yo 5 Aug 2008 00:15:00 -0000 @@ -103,9 +103,9 @@ pattern; the tt(EXTENDED_GLOB) option will be turned on for evaluation of the pattern. The var(value) given for this pattern will be used for all matches (not just filenames) whose display string are matched by -the pattern. Definitions for both of these take precedence over the -values defined for file types and the form with the leading asterisk -takes precedence over the form with the leading equal sign. +the pattern. Definitions for the form with the leading equal sign take +precedence over the values defined for file types, which in turn take +precedence over the form with the leading asterisk (file extensions). The last form also allows different parts of the displayed strings to be colored differently. For this, the pattern has to use the Index: Src/Zle/complist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v retrieving revision 1.117 diff -u -r1.117 complist.c --- Src/Zle/complist.c 5 Jul 2008 19:55:29 -0000 1.117 +++ Src/Zle/complist.c 5 Aug 2008 00:15:00 -0000 @@ -878,6 +878,21 @@ Extcol ec; Patcol pc; + nrefs = MAX_POS - 1; + + for (pc = mcolors.pats; pc; pc = pc->next) + if ((!pc->prog || !group || pattry(pc->prog, group)) && + pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) { + if (pc->cols[1]) { + patcols = pc->cols; + + return 1; + } + zlrputs(pc->cols[0]); + + return 0; + } + if (special != -1) { colour = special; } else if (S_ISDIR(m)) { @@ -920,21 +935,6 @@ return 0; } - nrefs = MAX_POS - 1; - - for (pc = mcolors.pats; pc; pc = pc->next) - if ((!pc->prog || !group || pattry(pc->prog, group)) && - pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) { - if (pc->cols[1]) { - patcols = pc->cols; - - return 1; - } - zlrputs(pc->cols[0]); - - return 0; - } - zcputs(group, COL_FI); return 0; ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-05 0:16 ` Bart Schaefer @ 2008-08-05 8:13 ` Peter Stephenson 2008-08-05 10:30 ` Rocky Bernstein 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2008-08-05 8:13 UTC (permalink / raw) To: zsh-workers Bart Schaefer wrote: > On Aug 4, 4:54pm, Bart Schaefer wrote: > } Subject: Re: completion: highlight matching part > } > } On Aug 4, 8:44pm, Peter Stephenson wrote: > } } Subject: Re: completion: highlight matching part > } } > } } On Sun, 03 Aug 2008 17:33:21 -0700 > } } Bart Schaefer <schaefer@brasslantern.com> wrote: > } } > (1) Change complist.c:putfilecol() so that pattern tests come first, > } } > then mode tests, and finally extension tests. > } } > } } I should think this is the right thing to do, isn't it? > } > } I agree > > Here's the patch, mostly so you can proof my doc change. I can't see any problem. I think it's one of those things (like DEBUG_BEFORE_CMD) where nobody knew it wasn't the best way of doing it until they tried it. -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-05 8:13 ` Peter Stephenson @ 2008-08-05 10:30 ` Rocky Bernstein 2008-08-05 10:49 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Rocky Bernstein @ 2008-08-05 10:30 UTC (permalink / raw) To: zsh-workers On Tue, Aug 5, 2008 at 4:13 AM, Peter Stephenson <pws@csr.com> wrote: > Bart Schaefer wrote: >> On Aug 4, 4:54pm, Bart Schaefer wrote: >> } Subject: Re: completion: highlight matching part >> } >> } On Aug 4, 8:44pm, Peter Stephenson wrote: >> } } Subject: Re: completion: highlight matching part >> } } >> } } On Sun, 03 Aug 2008 17:33:21 -0700 >> } } Bart Schaefer <schaefer@brasslantern.com> wrote: >> } } > (1) Change complist.c:putfilecol() so that pattern tests come first, >> } } > then mode tests, and finally extension tests. >> } } >> } } I should think this is the right thing to do, isn't it? >> } >> } I agree >> >> Here's the patch, mostly so you can proof my doc change. > > I can't see any problem. I think it's one of those things (like > DEBUG_BEFORE_CMD) where nobody knew it wasn't the best way of doing it > until they tried it. Interesting. You mean there isn't going to be an option to keep compatibility with prior versions of zsh? ;-) > > -- > Peter Stephenson <pws@csr.com> Software Engineer > CSR PLC, Churchill House, Cambridge Business Park, Cowley Road > Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: completion: highlight matching part 2008-08-05 10:30 ` Rocky Bernstein @ 2008-08-05 10:49 ` Peter Stephenson 0 siblings, 0 replies; 7+ messages in thread From: Peter Stephenson @ 2008-08-05 10:49 UTC (permalink / raw) To: zsh-workers "Rocky Bernstein" wrote: > Interesting. You mean there isn't going to be an option to keep > compatibility with prior versions of zsh? ;-) This is buried right down in the details of completion where teams of scientists have worked for years to determine what's actually going on and where no one else dares to change anything. It's hard enough keeping it compatible with itself. I certainly don't put this in the same class as features directly visible to the normal shell programmer. -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-08-05 10:49 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20080801163301.GA3589@pepin.polanet.pl> [not found] ` <080802143558.ZM815@torch.brasslantern.com> [not found] ` <20080803111423.GA11247@pepin.polanet.pl> [not found] ` <080803103117.ZM26039@torch.brasslantern.com> 2008-08-04 0:33 ` completion: highlight matching part Bart Schaefer 2008-08-04 19:44 ` Peter Stephenson 2008-08-04 23:54 ` Bart Schaefer 2008-08-05 0:16 ` Bart Schaefer 2008-08-05 8:13 ` Peter Stephenson 2008-08-05 10:30 ` Rocky Bernstein 2008-08-05 10:49 ` Peter Stephenson
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).