From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#50538: [PATCH] 28.0.50; electric-pair-mode fails to pair double quotes in some cases in CC mode Date: Fri, 17 Sep 2021 17:08:33 +0000 Message-ID: References: <021853bf-0169-c158-ab3d-296b6c144e08@gmail.com> <83r1dufgxu.fsf@gnu.org> <94c7b4ec-813b-515f-d947-116c294dd74b@gmail.com> <456ed31d-77dc-cc2d-2fe9-8fcd379e04c6@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40231"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50538@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 17 19:09:30 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRHMf-000ADC-9R for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Sep 2021 19:09:29 +0200 Original-Received: from localhost ([::1]:58750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRHMe-0006uK-5l for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Sep 2021 13:09:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRHME-0006t8-R5 for bug-gnu-emacs@gnu.org; Fri, 17 Sep 2021 13:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRHME-0000A8-Ja for bug-gnu-emacs@gnu.org; Fri, 17 Sep 2021 13:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRHME-0005Yk-Ep for bug-gnu-emacs@gnu.org; Fri, 17 Sep 2021 13:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Sep 2021 17:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50538 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50538-submit@debbugs.gnu.org id=B50538.163189852621338 (code B ref 50538); Fri, 17 Sep 2021 17:09:02 +0000 Original-Received: (at 50538) by debbugs.gnu.org; 17 Sep 2021 17:08:46 +0000 Original-Received: from localhost ([127.0.0.1]:32907 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRHLx-0005Y6-L5 for submit@debbugs.gnu.org; Fri, 17 Sep 2021 13:08:45 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:55456 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1mRHLt-0005Xp-3s for 50538@debbugs.gnu.org; Fri, 17 Sep 2021 13:08:43 -0400 Original-Received: (qmail 32555 invoked by uid 3782); 17 Sep 2021 17:08:34 -0000 Original-Received: from acm.muc.de (p4fe159e7.dip0.t-ipconnect.de [79.225.89.231]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 17 Sep 2021 19:08:34 +0200 Original-Received: (qmail 7811 invoked by uid 1000); 17 Sep 2021 17:08:33 -0000 Content-Disposition: inline In-Reply-To: <456ed31d-77dc-cc2d-2fe9-8fcd379e04c6@gmail.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214571 Archived-At: Hello, Jim. On Thu, Sep 16, 2021 at 14:36:06 -0700, Jim Porter wrote: > On 9/16/2021 1:49 PM, Alan Mackenzie wrote: > > There were two or three minor problems with the patch: > > 1-/. CC Mode doesn't use syntax-ppss at all. This was because way back > > when, syntax-ppss was buggy, and even now doesn't do the right thing for > > CC Mode in some edge cases (e.g. with the buffer narrowed and point-min > > inside a string or comment). Instead it uses its own internal syntactic > > cacheing, largely centred around the function c-semi-pp-to-literal. > > 2/- Rather than using get-text-property and friends directly, CC Mode > > uses the macros c-get-char-property, etc. This is (?was) to maintain > > compatibility with XEmacs. > > 3/- (A bit more serious) The patch looks for the last " in the current > > line without taking account of any escaped new lines. There is already > > a CC Mode macro which does all the work here, c-point, which can be given > > the argument 'eoll for "end of logical line". > Thanks, I've incorporated all these changes into the attached patch. The > only difference between my patch and the version you provided was to > keep the `(search-backward "\"")' portion from my patch, since the code > needs to find the last double-quote, not the end of line. Duh! Sorry about that, I clean forgot about it. I did say that I hadn't tested it, though. ;-) > As an aside, it's probably worth explaining why my patch searches for > the last double-quote in the first place. As far as I understand CC > Mode, when there's an unterminated double-quote on a line, both the > quote and the newline have a string fence property applied to them. Yes. > This means we could check the newline for that property, *but* there's > no guarantee a newline actually exists: `(c-point 'eoll)' could > actually point to the end of the buffer. To get around that, we search > backwards for the last double-quote of the (logical) line, since > that's guaranteed to exist. Yes. This is a very important case, the one that occurs when somebody's typing a new file, or at the end of an existing one. > If we wanted to, we could avoid searching backwards for the last > double-quote when a newline exists, but I'm not sure the gain in > performance (likely very small) is worth the extra code complexity. I'm fairly sure it wouldn't be. [ Patch snipped but read. ] -- Alan Mackenzie (Nuremberg, Germany).