Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Feature request: (z)-like flags needed for syntax-highlighting
- X-seq: zsh-workers 42914
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Feature request: (z)-like flags needed for syntax-highlighting
- Date: Fri, 1 Jun 2018 17:03:04 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=nDls2kfKezCZTEkdxpJRyRNxGkTqb0qiiC0vNZ4RaYU=; b=Cgjf2j17DC2ld6yAovnlJszEuep7ModfpdSqwCIMLZ++CrgeFHRR0kpQWz1p9kAIwN uncswh1T7yKFbJ1lZ/SVASDcKkYFL1AQerq3ygpAAzT7h5CHRosxzX3Ctyx7+HXWVE2q qMxxwkpsbkdouCboscv78iyySgzCyxGNVOb0MHAhMbg8UxB/ICIOh8SNqd+zRFI0upb4 ZYw7Otv/KNUaGG0GBm2UcZcKQ4fzL0ti5xRGBMrALHwW6i8yKPvHHRPB0lL4WgQ0c+68 SgomsM1t43S25ppuYxcsImaBOxfdMrzftrjM/iQS/KM08fdxtsvbRFT08u5LXygU3uFu z3Yw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author