all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: Writing syntax-propertize-function for strings in code in strings, etc
Date: Sat, 08 Sep 2012 15:31:15 -0400	[thread overview]
Message-ID: <jwv4nn8mi8a.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87a9x1jiyu.fsf@yandex.ru> (Dmitry Gutov's message of "Sat, 08 Sep 2012 07:23:37 +0400")

> 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?

Currently, it's pretty difficult for Emacs to handle it like in the
picture above.

> 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?

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?


        Stefan



  reply	other threads:[~2012-09-08 19:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv4nn8mi8a.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.