unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Writing syntax-propertize-function for strings in code in strings, etc
@ 2012-09-08  3:23 Dmitry Gutov
  2012-09-08 19:31 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2012-09-08  3:23 UTC (permalink / raw)
  To: emacs-devel

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:
http://i.imgur.com/NH1Ye.png

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.

Suggestions?

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
resort.

--Dmitry




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-11-15  1:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-08  3:23 Writing syntax-propertize-function for strings in code in strings, etc Dmitry Gutov
2012-09-08 19:31 ` Stefan Monnier
2012-09-09  0:13   ` Dmitry Gutov
     [not found]   ` <504FE870.7070002@yandex.ru>
     [not found]     ` <jwvlietxls1.fsf-monnier+emacs@gnu.org>
2012-10-26 19:18       ` Dmitry Gutov
2012-10-26 20:41         ` Stefan Monnier
2012-10-26 21:52           ` Dmitry Gutov
2012-10-28 15:46             ` Stefan Monnier
2012-11-02  4:54               ` Dmitry Gutov
2012-11-15  1:40                 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).