From: Ergus <spacibba@aol.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: cc-mode: Make all parameters introduced in Emacs 26 optional
Date: Sat, 30 Mar 2019 22:53:10 +0100 [thread overview]
Message-ID: <20190330215310.7hynks3lhn4m4rbh@Ergus> (raw)
In-Reply-To: <jwvk1ggyvza.fsf-monnier+emacs@gnu.org>
Hi Stefan:
Sorry, maybe my question is a bit orthogonal to this thread, but somehow
I feel it is related.
In CC mode is there a way (when activating a high level for
font-lock-mode) to highlight escape sequences, and numbers as in default
vim?
I am talking about something simple like the packages:
highlight-escape-sequences and highlight-numbers.
But maybe simpler and that doesn't rely on an external package for a
simpler functionality like this?
This is just a question, you can ignore it.
Thanks in advance Ergus
On Sat, Mar 30, 2019 at 04:17:25PM -0400, Stefan Monnier wrote:
>>> (modify-syntax-entry ?' "\"" st)
>>
>> Maybe, but that doesn't give you the facilities that CC Mode offers,
>> namely that the delimiters of invalid constructs (such as unterminated
>> strings, or invalid character constants) get fontified with warning face.
>
>... or quotes-in-numbers, indeed.
>
>> One question which has just occurred to me is why am I doing this in CC
>> Mode rather than the syntax and font-lock functionality handling it
>> directly? Languages where strings don't extend over unescaped newlines
>> aren't exactly a rarity.
>
>I think doing it in the syntax part is not necessary: the design of the
>syntax is made simpler and more efficient by assuming that the behavior
>on invalid code is largely irrelevant. And efficiency is important
>there when we need to parse-partial-sexp a large buffer.
>
>But providing support for highlighting such errors in font-lock
>(e.g. within font-lock-fontify-syntactically-region) would make a lot of
>sense, yes.
>
>Or maybe the simplest would be to provide
>a `font-lock-flag-multiline-strings` function that modes can add to
>font-lock-keywords.
>
>>> But the above sounds surprisingly complex&scary,
>> It only looks like that because I've spelled it out so laboriously. There
>> are two hook variables, each of which needs one function and the lack of
>> another.
>
>After re-reading the description I wonder if it couldn't be made simpler
>by making those hook functions check c-single-quotes-quote-strings
>instead (or have separate code in the cc-mode setup which adds/removes
>those hooks as needed based on c-single-quotes-quote-strings,
>essentially replacing the docstring text with executable code)?
>
>Also I still wonder why c-has-quoted-numbers is incompatible with
>c-single-quotes-quote-strings. I guess c-has-quoted-numbers only
>exists in C++, so in practice no language needs both features, but
>I can't see any reason why the CC-mode code wouldn't work just as
>well when both features are set. While both have to do with ' they seem
>fundamentally orthogonal.
>
>
> Stefan
>
>
next prev parent reply other threads:[~2019-03-30 21:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 8:09 cc-mode: Make all parameters introduced in Emacs 26 optional Jostein Kjønigsen
2018-01-22 20:32 ` Alan Mackenzie
2018-02-03 5:59 ` Matthew Carter
2018-02-03 6:13 ` Matthew Carter
2018-02-03 11:44 ` Alan Mackenzie
2019-03-30 13:51 ` Alan Mackenzie
2019-03-30 16:39 ` Stefan Monnier
2019-03-30 19:42 ` Alan Mackenzie
2019-03-30 20:17 ` Stefan Monnier
2019-03-30 21:53 ` Ergus [this message]
2018-03-12 20:16 ` Jostein Kjønigsen
2018-03-12 22:40 ` Stefan Monnier
2018-03-12 23:29 ` Clément Pit-Claudel
2018-03-13 1:00 ` Stefan Monnier
2018-03-13 20:08 ` Jostein Kjønigsen
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=20190330215310.7hynks3lhn4m4rbh@Ergus \
--to=spacibba@aol.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).