all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Matthew Carter <m@ahungry.com>
Cc: jostein@kjonigsen.net, emacs-devel@gnu.org
Subject: Re: cc-mode: Make all parameters introduced in Emacs 26 optional
Date: Sat, 30 Mar 2019 13:51:48 +0000	[thread overview]
Message-ID: <20190330135148.GA6312@ACM> (raw)
In-Reply-To: <20180203114451.GA4806@ACM>

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 <m@ahungry.com> 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 (m@ahungry.com)
> > http://ahungry.com

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



  reply	other threads:[~2019-03-30 13:51 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 [this message]
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
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

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

  git send-email \
    --in-reply-to=20190330135148.GA6312@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=jostein@kjonigsen.net \
    --cc=m@ahungry.com \
    /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.