Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight parameter expansions : $foo #739

Closed
mirsella opened this issue May 25, 2020 · 5 comments
Closed

Highlight parameter expansions : $foo #739

mirsella opened this issue May 25, 2020 · 5 comments

Comments

@mirsella
Copy link

mirsella commented May 25, 2020

Environnement variable are not highlighted, example echo $foo $bar $foo and $bar are white.
i think a line in tweak main would be appropriated.
example :
ZSH_HIGHLIGHT_STYLES[variable] if the variable exist et is not empty.
ZSH_HIGHLIGHT_STYLES[variable-empty] if the variable is not set or is empty.

i have posted this comment on another thread, tell me if it's better if i delete it to clean the thread.

thanks

@danielshahaf
Copy link
Member

Copying your previous comment for context:

sorry if it's the wrong place to ask. my variable $foo $bar are not highlighted, and i see no option to enable/change it in the tweak section.
i mean a option :
if the variable exist ZSH_HIGHLIGHT_STYLES[variable] for example and ZSH_HIGHLIGHT_STYLES[variable-unset] if the variable doesn't exist.
there those in the tweak page :

comment - comments, when setopt INTERACTIVE_COMMENTS is in effect (echo # foo)
comment - elided parameters in command position ($x ls when $x is unset or empty)

but both referenced by using "comment". is it a typo or i misunderstood ? seems like the second one is what i was looking for.
it's preferable that i create a new issue ? i didn't find one related. thanks

tell me if you prefer that I delete this message to clean up the thread. I'll do the issue tomorrow as it's already late where I live


i have posted this comment on another thread, tell me if it's better if i delete it to clean the thread.

Thanks, but I'll do that myself since I need to delete my own comment too.

@danielshahaf
Copy link
Member

In echo $foo, the parameter expansion «$foo» can result in one of three different behaviours:

  1. Variable will be expanded. (when $foo is set and not empty)
  2. Variable will be elided. (when $foo is either set to empty, or unset and the UNSET option is at its default value)
  3. A runtime error will be reported. (when $foo is unset and the UNSET option is unset [i.e., set -u is in effect])

If I understand correctly, @mirsella, you are asking for the $foo in cases (1) and (2) to be highlighted (differently in each case). Is that correct?

I think there are existing issues for all of these: #509 [which I have just retitled] for (1), #718 for (2), #450 for (3), and #484 and #485 for some extra functionality. Accordingly, I'm inclined to close these issue as a duplicate of those other ones — unless there's some request here that's not covered by those other issues? If so, what is it?

@danielshahaf danielshahaf changed the title [ Feature Request ] Support environnement variable highlighting : $foo Highlight parameter expansions : $foo May 26, 2020
@danielshahaf
Copy link
Member

(I've retitled the issue since it's not specifically about environment variables but about parameter expansions in general.)

@mirsella
Copy link
Author

thanks for the complete answer. sorry for my english

If I understand correctly, @mirsella, you are asking for the $foo in cases (1) and (2) to be highlighted (differently in each case). Is that correct?

that precisely it.
i didn't found all of the issue you linked when i searched, it would have prevented this useless issue.
you can close this issue if you want since all of those issue you linked are separated part of my issue.

@danielshahaf
Copy link
Member

Thanks, closing. (You can subscribe to the other issues, of course.) In this case, finding other issues would have been not as straightforward as usual, because these are commonly known as "variables" but the zsh syntax documentation terms them "parameters" instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants