zsh-workers
 help / color / mirror / code / Atom feed
* Feature request: (z)-like flags needed for syntax-highlighting
@ 2018-06-01 15:03 Sebastian Gniazdowski
  0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2018-06-01 15:03 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
(z) doesn't parse interiors of $(...) command substitution. Also, it
doesn't separate $() from preceding word, e.g. $var$(echo test) will
be returned as single token.

Fast-syntax-highlighting does highlight $(), however with a faulty
glob. This makes all this very much reality-driven, and it leads to a
conclusion: a flag that will extract $( ) is needed, so that
syntax-highlighting code can call itself recursively on it.

~ buf='echo $(ls -1) str $(ls -a)'
~ local -a inputs=( "${(Z+x+)buf}" )
~ print -rl -- $inputs
8:ls -1
21:ls -a

Above presents how the new flag should work. It should return offset
where $() body begins, and the body. This allows to call
syntax-highlighting recursively like this (FSH code):

for el in $inputs; do
  -fast-process $PREBUFFER  "${el#*:}"  $(( ${el%%:*} - 1 ))
done

This is a nice piece of code, which starts syntax-highlighting from
given place – ${el%%:*} - 1, on a short buffer ${el#*:}, causing to an
overlay of highlighting to be generated for the whole $buf. FSH does
this currently but with faulty glob – no way to properly handle \\\)
and other quoting of closing ")".

The reality-driven aspect is important, it would be hard to come up
with this by doing abstract thinking. I think ZSH should be interested
in making a beautiful, correct syntax highlighting. Check out how it
looks like when $() is colorized with different theme than the rest of
code:

http://psprint.blinkenshell.org/cmdsubst2.png

-- 
Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-01 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 15:03 Feature request: (z)-like flags needed for syntax-highlighting Sebastian Gniazdowski

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