emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cc-mode: Make all parameters introduced in Emacs 26 optional


From: Alan Mackenzie
Subject: Re: cc-mode: Make all parameters introduced in Emacs 26 optional
Date: Sat, 30 Mar 2019 13:51:48 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello again, Matthew.

Excuse the top post, but it seems the easiest way to reply given how long
ago the previous post was (apologies for this).

I've just committed a fix to CC Mode (both CC Mode standalone version at
SourceForge and the Emacs master branch on savannah), to allow 's to be
used as string delimiters in modes derived from CC Mode.

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'.

The two function in (ii) and (iii) are what fontify single character
literals in C, C++, etc.

(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.)

The two functions in (iv) are the ones which actually analyse strings for
fontification.

(vi) Ensure `c-multiline-string-start-char' (which allows strings to
continue over line ends without \) is set correctly for the mode.

Please feel free to test this "new" part of CC Mode, and to report any
bugs you find.  Since I lack a proper mode to test this with, my testing
of it hasn't been all that thorough.

Thanks again for the bug report!

-- 
Alan Mackenzie (Nuremberg, Germany).


On Sat, Feb 03, 2018 at 11:44:51 +0000, Alan Mackenzie wrote:
> On Sat, Feb 03, 2018 at 01:13:57 -0500, Matthew Carter wrote:
> > Matthew Carter <address@hidden> writes:

> > > Somewhat on this subject - recent versions of Emacs have seemed to
> > > have changed single quotes with text between the quotes with a
> > > length greater than 1 to use a warn font face on the quotes,
> > > instead of the font string face (likely because in C the single
> > > quote denotes a char, ....

> That's indeed what's been changed.

> > > .... but in many of the derived modes that cc-mode mentions in it's
> > > own comment set (php-mode, dart-mode etc.), a single quoted string
> > > and double quoted string are used interchangeably).

> Ah.  This is indeed a CC Mode bug.

> > > Does cc-mode have a setting to correct this and restore the old behavior?

> It doesn't, but it will soon get one.  This will be a "lang variable", to
> be set by each derived mode appropriately, as part of the language
> definition.

> > I hate to respond to my own post, but I have tracked this down to
> > #'c-parse-quotes-after-change (defined in cc-mode.el).  

> I don't hate it at all - it saves me work.  :-)

> Thanks indeed for taking the trouble to report this bug.

> > -- 
> > Matthew Carter (address@hidden)
> > http://ahungry.com

> -- 
> Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]