From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: scratch/fontify-open-string. [Was: CC Mode and electric-pair "problem".] Date: Sun, 1 Jul 2018 16:38:25 +0000 Message-ID: <20180701163825.GC4697@ACM> References: <20180618154227.GB3973@ACM> <20180619050244.GA3946@ACM> <20180627182717.GA4625@ACM> <20180630190327.GC6816@ACM> <83tvpkkr93.fsf@gnu.org> <20180630201447.GE6816@ACM> <83o9frkmk7.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1530463548 9129 195.159.176.226 (1 Jul 2018 16:45:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Jul 2018 16:45:48 +0000 (UTC) User-Agent: Mutt/1.9.4 (2018-02-28) Cc: joaotavora@gmail.com, cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, monnier@IRO.UMontreal.CA, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 01 18:45:43 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZfTq-0002Gr-C1 for ged-emacs-devel@m.gmane.org; Sun, 01 Jul 2018 18:45:42 +0200 Original-Received: from localhost ([::1]:54990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZfVx-0003b3-Fd for ged-emacs-devel@m.gmane.org; Sun, 01 Jul 2018 12:47:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZfVq-0003ay-UN for emacs-devel@gnu.org; Sun, 01 Jul 2018 12:47:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZfVn-0000kF-R3 for emacs-devel@gnu.org; Sun, 01 Jul 2018 12:47:46 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34649 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1fZfVn-0000jH-F1 for emacs-devel@gnu.org; Sun, 01 Jul 2018 12:47:43 -0400 Original-Received: (qmail 51417 invoked by uid 3782); 1 Jul 2018 16:47:42 -0000 Original-Received: from acm.muc.de (p5B147BF6.dip0.t-ipconnect.de [91.20.123.246]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 01 Jul 2018 18:47:40 +0200 Original-Received: (qmail 6652 invoked by uid 1000); 1 Jul 2018 16:38:25 -0000 Content-Disposition: inline In-Reply-To: <83o9frkmk7.fsf@gnu.org> 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:226876 Archived-At: Hello, Eli. On Sun, Jul 01, 2018 at 18:22:48 +0300, Eli Zaretskii wrote: > > Date: Sat, 30 Jun 2018 20:14:47 +0000 > > Cc: cpitclaudel@gmail.com, emacs-devel@gnu.org, > > stephen_leake@stephe-leake.org, monnier@IRO.UMontreal.CA, > > joaotavora@gmail.com > > From: Alan Mackenzie [ .... ] > > The initial problem I tried to solve was for CC Mode source files with > > things like: > > char foo[] = "foo > > char bar[] = "bar"; > > Historically, the missing " on "foo has caused subsequent lines to have > > their string quoting reversed. This is not good. > But not really a catastrophe, IMO. Perhaps not, but it is nevertheless bad. That it is so difficult to do anything about is also bad. > > What I'm now proposing, and implementing as a trial, is to enhance the > > syntax table facilities to support unterminated strings. There will be > > an extra syntax flag `s' on newlines meaning "terminate any open string". > > This is straightforward for forward scanning, but somewhat complicated > > for backward scanning. However, it does enable unterminated strings to > > be easily fontified to EOL in any language, with minimal effort. > > It should allow the desired fontification without causing problems for > > electric-pair-mode. > > Stefan is concerned that the extra functionality may not justify the > > increase in complexity in syntax.c. > So am I. I'm also concerned that introducing this will slow down > various syntax-related features, only to cater to what I consider a > minor improvement at best. > Of course, if the extra functionality turns out to be not as complex > as Stefan fears and won't cause any significant slowdown that concerns > me, then perhaps we should have it. But is that a reasonable > assumption? It's no longer a matter of assumption. Earlier on this afternoon, I committed a preliminary working version of this change to the branch scratch/fontify-open-string. The most complicated part of the change is the new function back_maybe_string in syntax.c. This is a mere 137 lines long. Even if perhaps not fully fleshed out, it's not far off. By contrast, back_comment (which is also called at every newline when there're line comments) is 289 lines long. I have amended shell-script-mode to use this new strategy. This required changing just one line in sh-script.el. To font-lock.el I have added an optional feature to put warning-face on the opening ". I think it is notable just how easy this new feature is to use. Essentially any mode[*] can use it with a one line change (to the syntax table code for \n). [*] Except, currently, CC Mode. ;-( > Thanks. -- Alan Mackenzie (Nuremberg, Germany).