[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing syntax-propertize-function for strings in code in strings, etc

From: Dmitry Gutov
Subject: Writing syntax-propertize-function for strings in code in strings, etc
Date: Sat, 08 Sep 2012 07:23:37 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (windows-nt)

Hi all,

I've been looking into this bug: http://bugs.ruby-lang.org/issues/6090

To elaborate, Ruby allows arbitrary code between string interpolation
braces, and even unlimited nesting of those.

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?

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.


A quick and dirty way is to limit the support to double-quoted strings,
no change in highlighting, and no nesting, but that would be the last


reply via email to

[Prev in Thread] Current Thread [Next in Thread]