From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fontifying unterminated strings [was: CC Mode and electric-pair "problem".] Date: Thu, 28 Jun 2018 19:56:36 -0400 Message-ID: References: <20180531123747.GA24752@ACM> <20180617201351.GA4580@ACM> <20180618103654.GA9771@ACM> <20180618154227.GB3973@ACM> <20180618180846.GC3973@ACM> <20180626160850.GA4464@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1530230087 4363 195.159.176.226 (28 Jun 2018 23:54:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 28 Jun 2018 23:54:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: =?windows-1252?Q?Cl=E9ment?= Pit-Claudel , =?windows-1252?B?Sm/jbyBU4XZvcmE=?= , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 29 01:54:42 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 1fYgkM-00011g-Eb for ged-emacs-devel@m.gmane.org; Fri, 29 Jun 2018 01:54:42 +0200 Original-Received: from localhost ([::1]:39190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYgmT-0000gh-BI for ged-emacs-devel@m.gmane.org; Thu, 28 Jun 2018 19:56:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYgmK-0000gW-JE for emacs-devel@gnu.org; Thu, 28 Jun 2018 19:56:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYgmH-0002ER-ET for emacs-devel@gnu.org; Thu, 28 Jun 2018 19:56:44 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:60904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYgmH-0002BY-7n for emacs-devel@gnu.org; Thu, 28 Jun 2018 19:56:41 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w5SNvBuY000318; Thu, 28 Jun 2018 19:57:12 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 3F8D66611F; Thu, 28 Jun 2018 19:56:36 -0400 (EDT) In-Reply-To: <20180626160850.GA4464@ACM> (Alan Mackenzie's message of "Tue, 26 Jun 2018 16:08:50 +0000") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6318=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6318> : inlines <6728> : streams <1791039> : uri <2665625> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 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:226826 Archived-At: >> I think the better option here is to focus on the following: >> 1- Make sure the programmer is aware there's a problem in its code. >> I.e. highlight the opening quote or the non-escaped end-of-line or >> something in bright red or something like that. >> 2- Don't try to guess what the user intended to do. >> Instead keep our code as simple as possible: the C code we're handed >> is broken, so there's no real clear "right behavior" anyway. > > How about the following suggestion - instead of having permanent > string-fence syntax-table text properties to define the ends of > unterminated strings: My suggestion has no "string-fence syntax-table" or any such thing, so I'm not sure what you're saying here. Before suggesting something else, could you clarify the downside you see with my proposal? > (ii) we amend font-{lock,core}.el to apply the desired fontification, to > be like the new fontification in CC Mode? This problem is not specific to C but it's not common to all programming languages either, so I think that modifying font-(lock|core).el for that would be a gross hack. We could do it somewhat cleanly by having font-lock.el provide some "standard" function that major modes could opt to use in their font-lock-* settings, of course, but I'm having a hard time imagining a solution with a nice semantics on that side: if we do it only by tweaking faces, then we get inconsistent behavior between highlighting and C-M-f, and if we do it by tweaking syntax-tables, then we get weird differences between the case where font-lock is used and where it's not used (e.g. between not-yet-displayed code and already displayed code, or between the case where font-lock-mode is enabled or not). `syntax-table` properties should be applied via syntax-propertize-function in order to be reliably available. Stefan