Skip to content

nix-mode: set syntax and font properties for multiline strings - #870

Merged
edolstra merged 1 commit into
NixOS:masterfrom
ttuegel:nix-mode
May 2, 2016
Merged

edolstra merged 1 commit into
NixOS:masterfrom
ttuegel:nix-mode

Conversation

@ttuegel

@ttuegel ttuegel commented Apr 1, 2016

Copy link
Copy Markdown
Member

This fixes the long-standing bug in nix-mode.el where '' /* '' would be treated as an opening string delimiter followed by a comment, rather than /* encased between string delimiters.

@Ericson2314

Copy link
Copy Markdown
Member

Should fix #253 #632 #803

@ttuegel

ttuegel commented Apr 3, 2016

Copy link
Copy Markdown
Member Author

This patch still isn't quite right; it doesn't correctly handle the following:

'' ${foo ''bar''} ''

I didn't want to deal with antiquotation yet because it's significantly more difficult, but it appears I have no choice.

@ttuegel ttuegel changed the title nix-mode: handle multiline strings correctly nix-mode: set syntax and font properties for multiline strings May 1, 2016
@ttuegel

ttuegel commented May 1, 2016

Copy link
Copy Markdown
Member Author

This is ready to merge now. Syntax is set correctly for multiline strings. Antiquotation is detected and syntax highlighting works correctly inside.

@domenkozar

Copy link
Copy Markdown
Member

cc @edolstra

@domenkozar

Copy link
Copy Markdown
Member

cc @peti

@edolstra
edolstra merged commit 33dc8c5 into NixOS:master May 2, 2016
@Ericson2314

Copy link
Copy Markdown
Member

Antiquotation doesn't seem to work quite right in non-multiline strings. Try "${"asdf"}"

@ttuegel

ttuegel commented Jun 6, 2016

Copy link
Copy Markdown
Member Author

Antiquotation doesn't seem to work quite right in non-multiline strings. Try "${"asdf"}"

Yes, I realized this shortly after this PR was merged!There doesn't seem to be a way in Emacs to pair " with ${ because the former is currently classified as a paired string delimiter. I think the simplest way to deal with this is to classify "-quotes as a generic string delimiter rather than a paired string delimiter; then we just have to check if each " is within another string. This is the same logic that I used for ''-quotes.

@Ericson2314

Copy link
Copy Markdown
Member

Sounds like a good plan to me!

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.

4 participants