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: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode Date: Thu, 4 Jul 2019 15:24:51 +0000 Message-ID: <20190704152451.GD5564@ACM> References: <20190702131632.GA30597@ACM> <20190702160410.GB30597@ACM> <20190702182811.GC30597@ACM> <20190703105804.GA11238@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="105702"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 04 17:28:36 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hj3f2-000RMp-K9 for ged-emacs-devel@m.gmane.org; Thu, 04 Jul 2019 17:28:36 +0200 Original-Received: from localhost ([::1]:46924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj3bb-0007Dg-TX for ged-emacs-devel@m.gmane.org; Thu, 04 Jul 2019 11:25:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38227) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj3bX-0007DY-FZ for emacs-devel@gnu.org; Thu, 04 Jul 2019 11:25:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hj3bW-0006Ht-FY for emacs-devel@gnu.org; Thu, 04 Jul 2019 11:24:59 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:24825 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1hj3bW-0006FF-2b for emacs-devel@gnu.org; Thu, 04 Jul 2019 11:24:58 -0400 Original-Received: (qmail 48970 invoked by uid 3782); 4 Jul 2019 15:24:52 -0000 Original-Received: from acm.muc.de (p4FE15EDB.dip0.t-ipconnect.de [79.225.94.219]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 04 Jul 2019 17:24:51 +0200 Original-Received: (qmail 15707 invoked by uid 1000); 4 Jul 2019 15:24:51 -0000 Content-Disposition: inline In-Reply-To: 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.23 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:238353 Archived-At: Hello, Stefan. On Wed, Jul 03, 2019 at 12:58:32 -0400, Stefan Monnier wrote: > > evasive and answer the point: can you suggest some other mechanism by > > which CC Mode can create the required font-locking? > Should be pretty easy: add a rule to font-lock-keywords (i.e. no change > in syntax-tables) matching a double quote and which then checks with > syntax-ppss if it's an opening or closing quote and whether the matching > matching quote is on the same line or not (and applies a warning face > accordingly). Thanks. That's part of the problem. Another part is that syntax fontification will have wrongly fontified the bits beyond the end of the invalid string with font-lock-string-face. I've had another idea - set these syntax-table properties as is done currently, but only for the duration of font-lock-fontify-region. That way, the fontification should come out right, and Joćo will be able to do the things he wants to do with invalid strings. I would do this in CC Mode by setting some text property instead of syntax-table (let's call it c-fl-syn-tab), and just before font locking happens, copying the value of these properties to the syntax-table property. And, of course, the reverse process after the font locking. Or something like that. > Stefan -- Alan Mackenzie (Nuremberg, Germany).