From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: cc-mode: Make all parameters introduced in Emacs 26 optional Date: Sat, 30 Mar 2019 13:51:48 +0000 Message-ID: <20190330135148.GA6312@ACM> References: <1516608561.1943450.1243462056.1A47A60F@webmail.messagingengine.com> <20180122203254.GA4888@ACM> <87k1vuwr3p.fsf@ahungry.com> <87fu6iwqfu.fsf@ahungry.com> <20180203114451.GA4806@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="118991"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: jostein@kjonigsen.net, emacs-devel@gnu.org To: Matthew Carter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 30 14:53:40 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAEQU-000UoL-Q8 for ged-emacs-devel@m.gmane.org; Sat, 30 Mar 2019 14:53:38 +0100 Original-Received: from localhost ([127.0.0.1]:37464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAEQT-00011D-Sd for ged-emacs-devel@m.gmane.org; Sat, 30 Mar 2019 09:53:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAEPq-00010w-IZ for emacs-devel@gnu.org; Sat, 30 Mar 2019 09:52:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hAEPk-00078X-Sh for emacs-devel@gnu.org; Sat, 30 Mar 2019 09:52:56 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:27351 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1hAEPW-0006Rw-JR for emacs-devel@gnu.org; Sat, 30 Mar 2019 09:52:39 -0400 Original-Received: (qmail 34094 invoked by uid 3782); 30 Mar 2019 13:51:50 -0000 Original-Received: from acm.muc.de (p2E5D5F4A.dip0.t-ipconnect.de [46.93.95.74]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 30 Mar 2019 14:51:48 +0100 Original-Received: (qmail 6346 invoked by uid 1000); 30 Mar 2019 13:51:48 -0000 Content-Disposition: inline In-Reply-To: <20180203114451.GA4806@ACM> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234820 Archived-At: 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 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).