From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Subject: Writing syntax-propertize-function for strings in code in strings, etc
Date: Sat, 08 Sep 2012 07:23:37 +0400 [thread overview]
Message-ID: <87a9x1jiyu.fsf@yandex.ru> (raw)
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
next reply other threads:[~2012-09-08 3:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-08 3:23 Dmitry Gutov [this message]
2012-09-08 19:31 ` Writing syntax-propertize-function for strings in code in strings, etc 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a9x1jiyu.fsf@yandex.ru \
--to=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).