zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: coloring substitution seems to eat next line.
Date: Thu, 10 Nov 2022 11:28:04 -0800	[thread overview]
Message-ID: <0a7dbe0d-1554-269a-f420-bfe320c7c838@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7a5hsJ3N1T3iQJMnNLttB3wFrZVTqPtg5Sjh5TTY0Fi_A@mail.gmail.com>


On 2022-11-10 10:54, Bart Schaefer wrote:
>
>>    cc[42]="foo bar"
>>    cc[42]=(foo bar)
> The first one resets cc[42].  The second one both updates cc[42] and
> inserts a new cc[43] after it.

Now there's a surprise.  Nuts, that explains the weird output and the 
seemingly empty next element.  It bleeding creates a new empty next 
element!!  I'll leave it to more adept people to understand why that's 
ever wanted.

Anyway, I stopped slicing (or did I start slicing? ...) anyway:

cc[$aa]=( ${cc[$aa]/(#b)((#i)$filter)/$'\e['$color;1m${match[1]}$'\e[0m'} )

... is the now slightly understandable strange output and ...

cc[$aa]=${cc[$aa]/(#b)((#i)$filter)/$'\e['$color;1m${match[1]}$'\e[0m'}

...  works just fine :-)  I've gotten into the habit of always using the 
parentheses just because.


> There is also the form
>
> cc[42,44]=(foo bar)
>
> which removes three elements (42,43,44) and replaces them with two new
> ones (42 and 43).  Hence a "slice".

Sheesh.  So it looks like I stopped slicing.  But that just above is 
sorta understandable.

BTW I'm not using Roman's '(#M)' syntax because it seems to want to 
print all sorts of values to the terminal.  Like '$MATCH' is some 
internal variable that always prints itself or something.

One last issue, tinkering with the code even as I compose this:


cc[$aa]=${cc[$aa]/(#b)(${zsh_case}${filter})/$'\e['$color;1m${match[1]}$'\e[0m'}

... the one thing left is to insert '$zsh_case' in there, which so far 
is not working.  But Roman has the answer:

cc[$aa]=${cc[$aa]/(#b)($~zsh_case${filter})/$'\e['$color;1m${match[1]}$'\e[0m'}

... I have not idea what '$~' means, but it works.

BTW, to my surprise, using native code gives the same performance as 
using grep, 40 seconds on a stress test here.  sed wanted 43 seconds.





  reply	other threads:[~2022-11-10 19:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10  0:43 Ray Andrews
2022-11-10  8:02 ` Roman Perepelitsa
2022-11-10 18:25   ` Ray Andrews
2022-11-10 18:36     ` Roman Perepelitsa
2022-11-10 18:45       ` Ray Andrews
2022-11-10 18:54       ` Bart Schaefer
2022-11-10 19:28         ` Ray Andrews [this message]
2022-11-10 20:22           ` Bart Schaefer
2022-11-10 21:42             ` Ray Andrews
2022-11-10 21:51               ` Roman Perepelitsa
2022-11-11 17:24                 ` Ray Andrews
2022-11-10 22:47               ` Bart Schaefer
2022-11-10 23:07                 ` Ray Andrews
2022-11-10 23:27                   ` Bart Schaefer
2022-11-11 15:00                     ` Ray Andrews
2022-11-11 18:15                       ` Bart Schaefer
2022-11-11 18:50                         ` Ray Andrews
2022-11-11 19:25                           ` Bart Schaefer
2022-11-11 21:26                             ` Ray Andrews
2022-11-12  4:24                               ` Bart Schaefer
2022-11-12 14:03                                 ` Ray Andrews
2022-11-13 15:09                                   ` Ray Andrews
2022-11-14 14:12                                     ` Roman Perepelitsa
2022-11-14 17:08                                     ` Ray Andrews
2022-11-14 17:12                                       ` Roman Perepelitsa
2022-11-14 18:58                                         ` Ray Andrews
2022-11-14 20:00                                           ` Bart Schaefer
2022-11-14 23:25                                             ` Ray Andrews
2022-11-15 14:17                                               ` Belaboring substitution syntax Ray Andrews
2022-11-16  1:49                                                 ` Bart Schaefer
2022-11-16  2:54                                                   ` Ray Andrews
2022-11-16  6:26                                                     ` Bart Schaefer
2022-11-16 14:08                                                       ` Ray Andrews
2022-11-16 14:13                                                         ` Roman Perepelitsa
2022-11-17  2:31                                                           ` Bart Schaefer
2022-11-17  8:59                                                             ` Roman Perepelitsa
2022-11-17 16:02                                                               ` Ray Andrews
2022-11-16 20:46                                                       ` Ray Andrews
2022-11-16 10:32                                                   ` Roman Perepelitsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a7dbe0d-1554-269a-f420-bfe320c7c838@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).