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

Use simpler string syntax table in Emacs #1587

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seldridge
Copy link
Member

This minimally fixes a bug at the cost of slightly worse syntax highlighting for strings. The bug is that, as written, any of ", ', {, or } are treated as the | (generic string delimiter) syntax class. This means that these act like "string toggles". This has the benefit of allowing things like string interpolation to work:

"foo{bar}"
^   ^   ^^
|   |   ||
|   |   |End string
|   |   Start string
|   End string
Start string

However, this creates problems if the strings are ever unbalanced. E.g., the following is mis-highlighted without this patch:

"foo'bar"
^   ^   ^
|   |   |
|   |   |
|   |   Start string
|   End string
Start string

Avoid all this by just forcing ' and " to make everything inside them strings. This loses the syntax highlighting for string interpolation. However, this seems like a win overall as some internal Wake files run into this bug and I'm seeing the entire file show up as a string.

This minimally fixes a bug at the cost of slightly worse syntax
highlighting for strings.  The bug is that, as written, any of `"`, `'`,
`{`, or `}` are treated as the `|` (generic string delimiter) syntax
class.  This means that these act like "string toggles".  This has the
benefit of allowing things like string interpolation to work:

    "foo{bar}"
    ^   ^   ^^
    |   |   ||
    |   |   |End string
    |   |   Start string
    |   End string
    Start string

However, this creates problems if the strings are ever unbalanced.  E.g.,
the following is mis-highlighted without this patch:

    "foo'bar"
    ^   ^   ^
    |   |   |
    |   |   |
    |   |   Start string
    |   End string
    Start string

Avoid all this by just forcing `'` and `"` to make everything inside them
strings.  This loses the syntax highlighting for string interpolation.
However, this seems like a win overall as some internal Wake files run
into this bug and I'm seeing the entire file show up as a string.

Signed-off-by: Schuyler Eldridge <[email protected]>
@seldridge
Copy link
Member Author

I'm tagging @mikeurbach on this as I know he is an Emacs user and I think has higher elisp proficiency than I do.

@seldridge seldridge marked this pull request as draft June 14, 2024 18:02
@seldridge
Copy link
Member Author

Hold off on review/merging this as this has some issues with quote escaping.

Copy link

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the tag. I'm honestly not an elisp expert, but happy to take a look. I've been annoyed by this, and I do agree with the premise of this PR. Sacrificing highlighting of interpolated strings in favor of not highlighting the rest of the file as a string if a ' is used in a string seems like a win.

Copy link
Collaborator

@ag-eitilt ag-eitilt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know absolutely nothing about Emacs highlighting, but that does seem to be a better strategy, if you can get the quote escaping to work.

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

Successfully merging this pull request may close these issues.

3 participants