[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cc-mode: Make all parameters introduced in Emacs 26 optional
From: |
Stefan Monnier |
Subject: |
Re: cc-mode: Make all parameters introduced in Emacs 26 optional |
Date: |
Sat, 30 Mar 2019 12:39:55 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Hi Alan,
> To set up a CC Mode derived mode to recognise strings 'like this', do the
> following:
> (i) Set the derived mode's value of `c-single-quotes-quote-strings' to t.
> (This is done with `c-lang-defconst' in the derived mode's .el file).
> (ii) Make sure the derived mode's value of
> `c-get-state-before-change-function' does not include
> `c-parse-quotes-before-change'.
> (iii) Similarly ensure `c-before-font-lock-functions' doesn't contain
> `c-parse-quotes-after-change'.
> (iv) Ensure the derived mode's value of
> `c-get-state-before-change-function' contains
> `c-before-change-check-unbalanced-strings' and that of
> `c-before-font-lock-functions' contains
> 'c-after-change-mark-abnormal-strings'.
> (v) Make sure `c-has-quoted-numbers' is nil. (This is a pure C++
> facility for writing numbers as 4'294'967'295.)
> (vi) Ensure `c-multiline-string-start-char' (which allows strings to
> continue over line ends without \) is set correctly for the mode.
In non-CC modes, all it takes is
(modify-syntax-entry ?' "\"" st)
so is there somewhere in CC-mode's code where there's some comment or
something that explains why this simple approach isn't sufficient?
I understand that things aren't always that simple:
- you need to handle the 4'294'967'295 thingies in C++, but that should
only affect C++ and I'd assume that the C++ code handles it by
recognizing something like "[0-9]'" and changing the syntax-class of
those quotes so it shouldn't prevent multichar single-quoted strings.
- you apparently want to help the user catch the erroneous use of
single-quoted strings in those languages where single quotes are used
for chars rather than strings. but again this would seem to only
explain the need for c-single-quotes-quote-strings.
But the above sounds surprisingly complex&scary,
Stefan