[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing syntax-propertize-function for strings in code in strings, e
Re: Writing syntax-propertize-function for strings in code in strings, etc
Sat, 08 Sep 2012 15:31:15 -0400
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)
> Sublime Text handles these aspects rather excellently, and even
> highlights the code inside as code, not string contents:
> Is there a proper way to do so in Emacs?
Currently, it's pretty difficult for Emacs to handle it like in the
> My first idea was, when propertizing interpolation, to see what kind of
> string we're inside, and apply the appropriate syntax to the enclosing
> braces, thus splitting the literal in two. But (a) string quotes class
> doesn't work that way (text characters on both ends of a literal must
> be the same), (b) if we're inside a percent literal (syntax class:
> generic string), and the literal spans several lines, we need to be able
> to jump to its real beginning position from its end, but with this
> approach (nth 8 (syntax-ppss)) will just return the beginning of the
> last piece. Saving buffer positions to text properties looks not very
> reliable, since the respective text may be deleted and re-inserted.
I think the better approach is to extend syntax.c with such a notion of
"syntax within strings". This could hopefully be used for:
- Strings within strings (e.g. Postscript nested strings).
- Comments within strings (I think some regexps allow comments).
- Code within strings (as here and in shell scripts).
I'm not sure what that would look like concretely. Maybe a new string
quote syntax which specifies a syntax-table to use within the string?