From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 16915@debbugs.gnu.org, Bozhidar Batsov <bozhidar@batsov.com>
Subject: bug#16915: 24.3.50; [ruby-mode] Comments in regexps using the extended syntax are not font-locked properly
Date: Mon, 10 Mar 2014 10:40:12 -0400 [thread overview]
Message-ID: <jwv8usib04s.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <531D67DE.4030200@yandex.ru> (Dmitry Gutov's message of "Mon, 10 Mar 2014 09:21:02 +0200")
>> My preference would be to think about it as a "multi-mode" case, and
>> hence make it possible to specify a different syntax-table to use within
>> the regexp.
> I remember this idea, but have a hard time viewing it in the context of our
> latest discussion on the subject of multi-modes.
> First, why only syntax-table?
It was not meant as excluding other data.
> For this specific case, a syntax table change is not required, we only
> need to be able to view the text between /'s as a separate context
Not necessarily required in all cases, but in order to handle the
various existing cases in various languages, we need some way to
indicate, for instance:
- Do double quotes introduce strings when used within this new context?
- Do comment chars introduce comments when used within this new context?
- Does \ still escape chars in this new context?
We usually use syntax-tables for that. They do provide more flexibility
than needed (so far), such as making it possible to allow different
commenting conventions within the new context. But it seems like
a "simple" way to handle the problem, so the extra generality is a bonus.
> (but - and this is a change from certain other multi-mode uses - still
> fontify uncommented text inside them with the regexp face). But in the
> general case, we would at least want to be able to change
> font-lock-keywords, too.
`font-lock-keywords' can use `syntax-ppss' to decide which rules to use
(since syntax-ppss would have to include the "context state" somewhere
in its output). It's not terribly convenient to do currently, so we may
want to provide a new replacement for font-lock-keywords which makes it
easier (and avoids relying on "eval" while we're at it).
>> I think of it along the lines of a new syntax-class, applied to the "/"
>> char, which would change the syntax-table for the subsequent text.
> How would this interact with a new hook that would `syntax-ppss' would run
> on the cached entries?
The way I imagine it, it would work at the parse-partial-sexp level
(extending the returned PPSS with a new field indicating the current
syntax-table or something similar). So syntax.el would stay
basically unchanged.
How that would interact with a new hook? Haven't thought about it yet.
> Would its default value look for the chars bearing the new syntax class?
I don't really understand the question. But I'd guess that I don't know
the answer.
Stefan
next prev parent reply other threads:[~2014-03-10 14:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 13:31 bug#16915: 24.3.50; [ruby-mode] Comments in regexps using the extended syntax are not font-locked properly Bozhidar Batsov
2014-03-01 22:19 ` Dmitry Gutov
2014-03-02 11:03 ` Bozhidar Batsov
2014-03-02 15:03 ` Dmitry Gutov
2014-03-04 10:02 ` Bozhidar Batsov
2014-03-07 21:04 ` Stefan Monnier
2014-03-10 7:21 ` Dmitry Gutov
2014-03-10 14:40 ` Stefan Monnier [this message]
2014-03-12 7:48 ` Dmitry Gutov
2014-03-12 14:25 ` 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=jwv8usib04s.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=16915@debbugs.gnu.org \
--cc=bozhidar@batsov.com \
--cc=dgutov@yandex.ru \
/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).