GNU bug report logs - #36006
electric-pair-mode fails to balance in certain cases

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>; Keywords: confirmed; dated Thu, 30 May 2019 15:12:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 36006 <at> debbugs.gnu.org:


Received: (at 36006) by debbugs.gnu.org; 27 Aug 2020 19:30:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 27 15:30:52 2020
Received: from localhost ([127.0.0.1]:44109 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kBNbn-0003ot-UP
	for submit <at> debbugs.gnu.org; Thu, 27 Aug 2020 15:30:52 -0400
Received: from mx.sdf.org ([205.166.94.24]:59835)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ghe@HIDDEN>) id 1kBNbk-0003oi-6a
 for 36006 <at> debbugs.gnu.org; Thu, 27 Aug 2020 15:30:50 -0400
Received: from sdf.org (IDENT:smmsp@HIDDEN [205.166.94.9])
 by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 07RJUkT6029169
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO);
 Thu, 27 Aug 2020 19:30:46 GMT
Received: (from ghe@localhost)
 by sdf.org (8.15.2/8.12.8/Submit) id 07RJ8Ccc026588;
 Thu, 27 Aug 2020 19:08:12 GMT
Date: Thu, 27 Aug 2020 19:08:10 +0000
From: Gregory Heytings <ghe@HIDDEN>
To: 36006 <at> debbugs.gnu.org
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain
 cases
Message-ID: <alpine.NEB.2.22.394.2008272047190453.21601@HIDDEN>
User-Agent: Alpine 2.22 (NEB 394 2020-01-19)
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=US-ASCII
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 36006
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


I don't know if the following information is useful, but on the "<div>" 
example given by the OP, the difference between Emacs 26 and 27 is that, 
in `electric-pair--balance-info', in the expression

(eq (char-after pos) (electric-pair--with-uncached-syntax (table) (matching-paren (char-before (scan-sexps (point) 1)))))

the second argument fails with "Unbalanced parentheses" in Emacs 27, which 
means that the whole expression fails, whereas in Emacs 26 both arguments 
evaluate to 60 and the expression returns t.

Because of that `electric-pair--balance-info' returns ((nil . 60) nil . 
60) in Emacs 27, instead of ((t . 60) t) in Emacs 26.

Because of that `electric-pair-skip-if-helps-balance' and 
`electric-pair-default-skip-self' return nil in Emacs 27, instead of t in 
Emacs 26.

Because of that `electric-pair-post-self-insert-function', called by 
`post-self-insert-hook', does not skip the insertion of the right angle 
bracket character.

The following snippet evaluates to "60" on both Emacs 26 and 27, so I 
don't understand where the "Unbalanced parentheses" error could come from.

----
<div>
(progn
   (electric-pair-mode 1)
   (html-mode)
   (let ((table (syntax-table))) (electric-pair--with-uncached-syntax (table) (matching-paren (char-before (scan-sexps 0 1))))))
----

Gregory




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.
Added indication that bug 36006 blocks43018 Request was from Michael Albinus <michael.albinus@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added indication that bug 36006 blocks39200 Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 36006 <at> debbugs.gnu.org:


Received: (at 36006) by debbugs.gnu.org; 22 Nov 2019 12:29:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 22 07:29:00 2019
Received: from localhost ([127.0.0.1]:53890 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iY83X-0000Ga-QW
	for submit <at> debbugs.gnu.org; Fri, 22 Nov 2019 07:29:00 -0500
Received: from mail-wm1-f45.google.com ([209.85.128.45]:36953)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dario.gjorgjevski@HIDDEN>) id 1iY83U-0000GJ-Cr
 for 36006 <at> debbugs.gnu.org; Fri, 22 Nov 2019 07:28:57 -0500
Received: by mail-wm1-f45.google.com with SMTP id f129so6051277wmf.2
 for <36006 <at> debbugs.gnu.org>; Fri, 22 Nov 2019 04:28:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:mime-version;
 bh=zx0eAYNgu6ES7GbXIu4Y+Y4kHKqs2Hf6w0zW4ygl6cc=;
 b=cyAsZ+PZZfkb8tYQiFdD2Ze86BxeV3w4Jz1HUD8plk3CdnPJx3BWm4G0fyOd08S1CO
 6PJaXlwuXZlg2BEqo6AjDL/+0JxZeb/SQlUpV6gYW7OSNEcq2NtzC5BJkwl7dalLt2E8
 N5zF3I972Y2ujqJHogeV/BgAwVxSYslolEUayp8V5uMYLyXpUM+QgpSmNwZPubAyX3Xr
 6WIq4dhzWsiRA7RaZNVhQJvcdAeeHnbXEEk1udgBKFbHPl4TH8NVgNa+FtdugP0OqXPe
 dWglc5cpklWNklrg5yehY36RUYjJ/hWe4l+JWr1QK29EDk0MwUAlkmcyJzxFnRTGvrci
 pArg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version;
 bh=zx0eAYNgu6ES7GbXIu4Y+Y4kHKqs2Hf6w0zW4ygl6cc=;
 b=VmoShtvduKNMmcweFvAZ4eWbV9giil+i5mxgyFjkA4OPbQM0lVqvPYARgEQDFir1eT
 u68n/01/uFR5qkTkwO5Xhz3xq1p9X6pZtrwN1+56hqC9KFbP7YCReoFTnxDQzOlzxAgA
 2vzRBavMuGZ+4vr/yM6r4ByezyYCftwu89qWzn204NsLG4zvCo66SCenP22h1p5nOmDe
 r65lNd/uhVm2+EjzQhjgqjuCmUrZgG4awStjtvggbv4BN74+XRwXm8pzeA0svfpIDQdj
 Tv/dm7sJCHvD0ZzvhPTLNuPaTRS8C6+5HXzpG/Ie36tAiyeqaZLtHQ9XkwLYfW7PHZFy
 hG3A==
X-Gm-Message-State: APjAAAXeyioAImgYCApQ7/3lOXbeolTBJfKGte2INqdWkZvM2iEZ+I6H
 Ic9peeqnGM7UKj7FbPO943wxb2xx
X-Google-Smtp-Source: APXvYqwj0n2crJMoH2lzWYd8pfL1eme8fhM5+8dcwvPP2HjNH1YamS8r7Agxjux0q8vQqszunhAj2A==
X-Received: by 2002:a7b:c4c8:: with SMTP id g8mr15327263wmk.36.1574425729976; 
 Fri, 22 Nov 2019 04:28:49 -0800 (PST)
Received: from ZALANDO-31298 ([185.85.220.254])
 by smtp.gmail.com with ESMTPSA id r2sm3408822wma.44.2019.11.22.04.28.48
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 22 Nov 2019 04:28:49 -0800 (PST)
From: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>
To: Noam Postavsky <npostavs@HIDDEN>
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain cases
Date: Fri, 22 Nov 2019 13:28:48 +0100
Message-ID: <fv2zojtv6w6qnz.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 36006
Cc: 36006 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

(It=E2=80=99s been so long since I last looked into the bug...)

> It doesn't happen in emacs-26, which has the same
> electric-pair--with-uncached-syntax call, so it's not just that alone.
> I suspect this could be related to the recent changes to mark ">"
> outside of tags with punctuation syntax (technically, <foo>a > b</foo>
> is valid, only "<" needs to be escaped as &lt;).

You=E2=80=99re right.  The problem is that electric-pair--with-uncached-syn=
tax
let-binds syntax-propertize-function to ignore, causing the syntax of
">" to not be updated.

Applying the attached patch fixes the issue.  However, in what cases
would we want syntax-propertize-function to be let-bound to ignore?

Best regards,
Dario


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-Leave-syntax-propertize-function-unchanged.patch
Content-Description: Do not let-bind syntax-propertize-function to ignore in
 electric-pair--with-uncached-syntax

From 6de30e0cdc97475b3aac2a35bec1fcf1ac0af84f Mon Sep 17 00:00:00 2001
From: Dario Gjorgjevski <dario.gjorgjevski+git@HIDDEN>
Date: Fri, 22 Nov 2019 13:19:39 +0100
Subject: [PATCH] Leave syntax-propertize-function unchanged

* lisp/elec-pair.el (electric-pair--with-uncached-syntax): Do not
let-bind syntax-propertize-function.
---
 lisp/elec-pair.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index f3cbee7048..6e528b2dfd 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -246,8 +246,7 @@ electric-pair--with-uncached-syntax
 cache is flushed from position START, defaulting to point."
   (declare (debug ((form &optional form) body)) (indent 1))
   (let ((start-var (make-symbol "start")))
-    `(let ((syntax-propertize-function #'ignore)
-           (,start-var ,(or start '(point))))
+    `(let ((,start-var ,(or start '(point))))
        (unwind-protect
            (with-syntax-table ,table
              ,@body)
-- 
2.17.1


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.
Added tag(s) confirmed. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug Marked as found in versions 27.0.50. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 36006 <at> debbugs.gnu.org:


Received: (at 36006) by debbugs.gnu.org; 6 Jun 2019 23:40:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 06 19:40:06 2019
Received: from localhost ([127.0.0.1]:50808 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hZ1zJ-0004lY-Uf
	for submit <at> debbugs.gnu.org; Thu, 06 Jun 2019 19:40:06 -0400
Received: from mail-io1-f41.google.com ([209.85.166.41]:35981)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>)
 id 1hZ1zI-0004kt-Gz; Thu, 06 Jun 2019 19:40:05 -0400
Received: by mail-io1-f41.google.com with SMTP id h6so29375ioh.3;
 Thu, 06 Jun 2019 16:40:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=F6WKbFnq6ztmnwNmHYbI+gT82gW4kQpTodrm0blts2E=;
 b=V2mZ5IBwmZ5kd40p0/qmiUhWfHevHNofxymsa/HjDM5J5EQtvG8V2RMXsV82bViN0t
 jUl3nRblBVMA50KInjY8YbZMRbuGU27aT3MQhGUaSgTGHD8P75511IarpgkZhZeUOQQ2
 Tme4Np7/dR76FZ9iBDNoXXVNzMklIWy+aOVjOQouweKRKPWSSc6HRWn+6eSYBVGwJgf0
 OdzVUKRqHKKt5IvAbLCaT41GQaovf9Du2lmw7zbrkpTeGiz+XcCCRRmwGq+QWCCL5MhF
 YRU3FiKzwXfk5S5hv0AkPxKIHlxuWcloQssGUPV/cxQ1TZjpfIZ8dKuI4p5slcWcXmae
 ixbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=F6WKbFnq6ztmnwNmHYbI+gT82gW4kQpTodrm0blts2E=;
 b=mxUMlOJh1G0V0DBAS77UwWSebYAwCBRQm2nRAG+LY9u9uEtj8lcMysnaaJaYx/lhhg
 u5C7oiLg6zBsIh1rcKAwW+huLkxilCqwuncTaOXpFTJd57n09TCx0kWgQIF30PNSfpnM
 ljakNsnPToV0okT6+GXyRu1KWlo6Y3rHKXDUcqd7eZOiArWBcZIHsaxtee2B+VOh8DqG
 N/3EzNZEzmrziPhcjQ7gOcEIv5yI2ZTysEe1VchOJU5P4Nq2L7qI6jSJ960wT1u3g7i8
 ybn7w+VVkm9F3gJfgdGxSKpG/Eg+/Sz2xkqy8soTrfxg7gFHjwOq+rG2qpMPL1btBySX
 x0FA==
X-Gm-Message-State: APjAAAVYfvknYxomAuSpKtXJtZN+5nnhg7zelxDxkAySrOUcywGkg/hG
 G0y2kLKoB+sw0P92TJf9aiUBdDp4
X-Google-Smtp-Source: APXvYqxOSk9F0cT9DcDiXKsbiDAunPtxyBV0XVzyHtrBZx6L2BIxd7MdDQ7Al1i2GZAWJAgta6qfbg==
X-Received: by 2002:a6b:6b14:: with SMTP id g20mr29806956ioc.28.1559864398705; 
 Thu, 06 Jun 2019 16:39:58 -0700 (PDT)
Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34])
 by smtp.gmail.com with ESMTPSA id a1sm132864ioo.5.2019.06.06.16.39.58
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 06 Jun 2019 16:39:58 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
To: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain cases
References: <87woi80yfw.fsf@HIDDEN> <85blzjdeu0.fsf@HIDDEN>
 <8736kvd30p.fsf@HIDDEN>
Date: Thu, 06 Jun 2019 19:39:57 -0400
In-Reply-To: <8736kvd30p.fsf@HIDDEN> (Dario Gjorgjevski's message of "Thu, 
 30 May 2019 23:51:50 +0200")
Message-ID: <87d0jq2she.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 36006
Cc: 36006 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

found 36006 27.0.50
tags 36006 + confirmed
quit

Dario Gjorgjevski <dario.gjorgjevski@HIDDEN> writes:

>> I'm having trouble reproducing this; what's the exact sequence of input
>> starting from 'emacs -Q'?
>
> Run 'emacs -Q'; it opens up with the *scratch* buffer.  Now:
>
> 1. M-x electric-pair-mode <RET>
> 2. M-x html-mode <RET>
> 3. <div>

Ah, got it now, I think I was inserting before starting html-mode before.

> From my debugging, the culprit seems to be an unnecessary (or mistaken?)
> use of electric-pair--with-uncached-syntax.  I am not sure *why* exactly
> it happens, and would appreciate further insight.

It doesn't happen in emacs-26, which has the same
electric-pair--with-uncached-syntax call, so it's not just that alone.
I suspect this could be related to the recent changes to mark ">"
outside of tags with punctuation syntax (technically, <foo>a > b</foo>
is valid, only "<" needs to be escaped as &lt;).

This is kind of a pain to debug, when I stepped with edebug, it worked,
I think because stepping gives time for syntax-propertize to run.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.

Message received at 36006 <at> debbugs.gnu.org:


Received: (at 36006) by debbugs.gnu.org; 30 May 2019 21:52:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 30 17:52:00 2019
Received: from localhost ([127.0.0.1]:34190 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hWSxs-0004q5-IR
	for submit <at> debbugs.gnu.org; Thu, 30 May 2019 17:52:00 -0400
Received: from mail-ed1-f43.google.com ([209.85.208.43]:36993)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dario.gjorgjevski@HIDDEN>) id 1hWSxq-0004pp-GE
 for 36006 <at> debbugs.gnu.org; Thu, 30 May 2019 17:51:59 -0400
Received: by mail-ed1-f43.google.com with SMTP id w37so11260314edw.4
 for <36006 <at> debbugs.gnu.org>; Thu, 30 May 2019 14:51:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:in-reply-to:references:user-agent:date
 :message-id:mime-version;
 bh=/HJE8wKs1kKugFCr04t1BPqtZ+ihYhdg90GeB7dyABA=;
 b=ULm0OOLNGYICGnQ6+NjrsR98YJnqbaEaYuK6xIOhrxwLTtpfsdyXqyrkOcDxXdvtwZ
 JC6kDqe2cbxmgVsfD8PifE838DLIrtzGxc6IGFI8YlJVMNnObM1IHr6dD6hWLuK/c+ty
 E6lT6vi6Cpi+8JHDscvFlrw86hkq9HQMinencW7o9dHdKXfV4O+q4fIoUYUfoQpnIA0/
 sPALj10iUedgxG+/4wSHX2yp9zQAjL3KuzmnfdI4CfUFq8VHmc0kGi8rZSjGqARU4oIw
 W9VLUntWsmwnrIGj3Qm9g++eW97OB4QK9zwVQz6DWFjTGRmdNFVY5pwSsUgqCYs12jCe
 ebrg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references
 :user-agent:date:message-id:mime-version;
 bh=/HJE8wKs1kKugFCr04t1BPqtZ+ihYhdg90GeB7dyABA=;
 b=ILPRlRn4rlfRpOldAtCRtuf0GBbk8LNRFsXm2yCZvhP0ECPvYiUl+WKXjyIhKc1RA1
 9aXR22bUfY7SJmE6na4klFGVQLR55S4xRmQBrBY3j7MFVwIKBJ4zqSFXGSILNT17e78A
 i9/InMcy4SrK15SPJMI8KYKGr3yFSethuaB/gOi1nk4O91EYJ/kbF62OgUoc3pF16qOE
 YChIanx0vswYNc1dqvnZUGzzLwu2ailm8FxybxunTQJ+Nvg11CnVwpekBW9+y7Q8+oYS
 g6fm0gbBBkWAp1tRKhCVCRgr4BGcF3tIoDDuRZmzYkelyujm9yhjl15vhYUCJbaKAEm9
 ipoA==
X-Gm-Message-State: APjAAAXFSN2QTmDJ+BIdP0RUqvRDqNVCg+OHPDZlCzGose9T4IEr01A3
 tZNtJOML5DodVyimdSfw+UhS4J1ybJE=
X-Google-Smtp-Source: APXvYqwjUh12d09m2QRmjNjQkhM3empvH3x3U1QoTwNP2XUKZAwxqXF6uJAaNpiiILTl6npDngHclA==
X-Received: by 2002:a50:9203:: with SMTP id i3mr7443436eda.172.1559253112157; 
 Thu, 30 May 2019 14:51:52 -0700 (PDT)
Received: from dario-XPS-13-9370 (cable-158-181-75-198.cust.telecolumbus.net.
 [158.181.75.198])
 by smtp.gmail.com with ESMTPSA id s11sm1041751edx.41.2019.05.30.14.51.51
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 30 May 2019 14:51:51 -0700 (PDT)
From: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>
To: npostavs@HIDDEN
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain cases
In-Reply-To: <85blzjdeu0.fsf@HIDDEN> (npostavs@HIDDEN's message of "Thu, 
 30 May 2019 13:36:39 -0400")
References: <87woi80yfw.fsf@HIDDEN> <85blzjdeu0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Date: Thu, 30 May 2019 23:51:50 +0200
Message-ID: <8736kvd30p.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 36006
Cc: 36006 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> I'm having trouble reproducing this; what's the exact sequence of input
> starting from 'emacs -Q'?

Run 'emacs -Q'; it opens up with the *scratch* buffer.  Now:

1. M-x electric-pair-mode <RET>
2. M-x html-mode <RET>
3. <div>

(The order of 1. and 2. is irrelevant.)  What I expect to see in the
buffer is:

<div>|

What I see instead is:

<div>|>

If I type another '>', I end up with:

<div>>|

> And what version of Emacs is this?

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.8)
 of 2019-05-30 built on dario-XPS-13-9370
Repository revision: cc71a82fc705a73fa3ef6cda3ec6bee1cb654d7e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Ubuntu 19.04

-- 
Dario Gjorgjevski :: <dario.gjorgjevski@HIDDEN>
                  :: 744A 4F0B 4F1C 9371
                  :: +48 1525 8666837




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.

Message received at 36006 <at> debbugs.gnu.org:


Received: (at 36006) by debbugs.gnu.org; 30 May 2019 17:36:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 30 13:36:50 2019
Received: from localhost ([127.0.0.1]:33809 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hWOyw-00040H-7K
	for submit <at> debbugs.gnu.org; Thu, 30 May 2019 13:36:50 -0400
Received: from mail-it1-f178.google.com ([209.85.166.178]:39711)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1hWOyt-000401-DA
 for 36006 <at> debbugs.gnu.org; Thu, 30 May 2019 13:36:48 -0400
Received: by mail-it1-f178.google.com with SMTP id j204so5421109ite.4
 for <36006 <at> debbugs.gnu.org>; Thu, 30 May 2019 10:36:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=ZMlfuLFwvHvG6tNskdCfG5D2HnxAEDXO0H7qTqQErHM=;
 b=VrcSPGkPqfdFNX7JZtLKJARx3feauSPvBlp7gq+urulFfAAUjh+Ifnmpt4DSbMtaep
 NqfHxuDU7HsV0thdp75Gfg3r9DV6kTZ2A10kNQie8+78Yo345henNgp46YVp+FFul4Db
 gh3kJW4+/70iRO4J81YArv+XQFphDOHAcDrSEb/HZbFYX74BfPNVoX69smWMqQfJ5lfO
 VyKH/efbxj9VSjBLHikx0demycjAKTtnTK/tIOzlSS03m79+YOBgh4hatvmOPjiGPFpQ
 ZDeZ+NAuC5qG958TJg+006ijt6veNhB4EfISW3WkTEX/xIa/QNS+he1c+O9xmctbVzkK
 SuzA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=ZMlfuLFwvHvG6tNskdCfG5D2HnxAEDXO0H7qTqQErHM=;
 b=Pbf+HmvAzq9cGLCYOOUjXCnhEibnELkrBSKvMQWJgR+PyFyar8oHBb+TNd4IJhv6On
 IXOFZXq4siKVTG3TV6OkPMz+iWCCOqioTE2AB9Tji89cYyESkt2gmrdxMngiHPtKO+L3
 dNn5DqEYAMEapeGy/dGzkOwXNuVoegAqFORAIZcyp29AXH8mCD0V6kHftBxV18w4ToV0
 oIeBmRG3KamLCqUqSnwvMIETkjmsrAEMBC2Z3xkH9Z9VHEY9bG3Dm7j/7tB138Y8jvJr
 Caj5w3+tvtNOPOC4lYTQ4hXJ9kOf0jKln2tU0SXYHT3a0kV3fqF+YOVVzx9eRDnpnLn2
 aH4Q==
X-Gm-Message-State: APjAAAXU0qtFjAkWM59YvezeGoUasOjZsGvchnQ3Qwphz/Cnl2idUGIK
 gkdZ/Lp8U0dphU762MYcAyKyD6Ua
X-Google-Smtp-Source: APXvYqz03sXmBTl3hPFrzF8MwXgRLtIkwWtXqiv1uiSD2ndJ5kC4YCLuCzaLb4ouj+b6nYYFjEghuQ==
X-Received: by 2002:a24:910b:: with SMTP id i11mr3928387ite.110.1559237801311; 
 Thu, 30 May 2019 10:36:41 -0700 (PDT)
Received: from vhost2
 (CPE001143542e1f-CMf81d0f809fa0.cpe.net.cable.rogers.com. [99.230.51.196])
 by smtp.gmail.com with ESMTPSA id q142sm1337347itb.17.2019.05.30.10.36.40
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 30 May 2019 10:36:40 -0700 (PDT)
From: npostavs@HIDDEN
To: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain cases
References: <87woi80yfw.fsf@HIDDEN>
Date: Thu, 30 May 2019 13:36:39 -0400
In-Reply-To: <87woi80yfw.fsf@HIDDEN> (Dario Gjorgjevski's message of "Thu, 
 30 May 2019 17:11:31 +0200")
Message-ID: <85blzjdeu0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (windows-nt)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 36006
Cc: 36006 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Dario Gjorgjevski <dario.gjorgjevski@HIDDEN> writes:

> Consider the following text in html-mode with electric-pair-mode turned
> on and electric-pair-skip-self set to electric-pair-default-skip-self:
>
>          <|>
>
> (Take | to denote point.)  In this situation, the expected result of
> attempting to insert > is to skip over the one immediately after point,
> i.e., end up with <>|.  However, what we get instead is <>|>.  Only if
> we *now* attempt to insert >, we end up with <>>|, which doesn't make
> any sense.

I'm having trouble reproducing this; what's the exact sequence of input
starting from 'emacs -Q'?  And what version of Emacs is this?





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 30 May 2019 15:11:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 30 11:11:46 2019
Received: from localhost ([127.0.0.1]:33545 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hWMiX-000677-Va
	for submit <at> debbugs.gnu.org; Thu, 30 May 2019 11:11:46 -0400
Received: from eggs.gnu.org ([209.51.188.92]:45795)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dario.gjorgjevski@HIDDEN>) id 1hWMiW-00066q-17
 for submit <at> debbugs.gnu.org; Thu, 30 May 2019 11:11:45 -0400
Received: from lists.gnu.org ([209.51.188.17]:40495)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <dario.gjorgjevski@HIDDEN>)
 id 1hWMiQ-0003Dp-VE
 for submit <at> debbugs.gnu.org; Thu, 30 May 2019 11:11:38 -0400
Received: from eggs.gnu.org ([209.51.188.92]:60177)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dario.gjorgjevski@HIDDEN>) id 1hWMiP-0008Bj-V2
 for bug-gnu-emacs@HIDDEN; Thu, 30 May 2019 11:11:38 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dario.gjorgjevski@HIDDEN>) id 1hWMiP-0003Ch-4Z
 for bug-gnu-emacs@HIDDEN; Thu, 30 May 2019 11:11:37 -0400
Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:38643)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <dario.gjorgjevski@HIDDEN>)
 id 1hWMiO-00036Y-S6
 for bug-gnu-emacs@HIDDEN; Thu, 30 May 2019 11:11:37 -0400
Received: by mail-ed1-x531.google.com with SMTP id g13so9615815edu.5
 for <bug-gnu-emacs@HIDDEN>; Thu, 30 May 2019 08:11:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:mime-version;
 bh=5F7xIqpWrZSizk5eIbc06stmrRAcMgkMrWXfYA/vJ+k=;
 b=EoD2l61kjcVG8Xfyd8AugwFtBEtVS+HjC7V/7qO2VeRiYCNxsi0PBE17G749RAgk4y
 eebIDGIaXPtKcJYj/k39ZZfV+ole37E0cRuArLyKwSxE5sKNaZ7NFpqm50kgUZwe5MAq
 JAohNrJ9nCYPzev3Ie7P21GDAbI1pK8t68V8GME+wJE8nAPBBom9SKZjcGD2kbHTXvlj
 aJ7pKUq/HNl6QhUmWybVKSWtvKzKX1PmvGZ2uq4q1GvUZ0PaI9NQU+8QdNJtPGyuAv6F
 3g2zTk4hDD/GqG3OgOs6xU8Q4gXdgoqAsxnKvgpwv433e/qx9Ra1qH6X4dP0Y63t97UP
 VTAg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version;
 bh=5F7xIqpWrZSizk5eIbc06stmrRAcMgkMrWXfYA/vJ+k=;
 b=EiHWcPNOJLlg8c22clCyWcZ/C/5Q/RePzx2Yp+87oGBUlU+cWIDven/3Gl2isNZHzg
 lRHnaaYu14mPN3RFzhvTE34OET9yTRWjDDFsXXUl8mFgruk9TnEG8NWK1ju0DHjr7FUc
 wkmwFQnE+/anjvd8r8r29xpi6rBlNoGZKxrGlJwLrkQySMnOiFlyyVkJ9epwWlisPNsE
 dfFQAistnsNA/0dyDH75E5Sx6qOmUJWHGeehbqGwl/UDqmgTzdixKl4l9pmC0p7azQb8
 oV7ihxUp9Vh50gszAmdM9fIiW5UK8x35ZWMGuobuR0BfkLZLLf2+Kr+pafiNYArmBytn
 qvsw==
X-Gm-Message-State: APjAAAU/U+h20pWNAopkG2a89JxtIDk1BJitwzNUml4a3hO+2Q7YqB5K
 nguSMGzNBuR1AH4S8C4AutvThNWycJQ=
X-Google-Smtp-Source: APXvYqxVmZuGWnUUrRNpZPhXveaNLCcWPylg6HKZLLgoSO3yC2FD593e+K66f8lxNMoaTsz7vXgvAQ==
X-Received: by 2002:a50:9785:: with SMTP id e5mr5222483edb.94.1559229093201;
 Thu, 30 May 2019 08:11:33 -0700 (PDT)
Received: from dario-XPS-13-9370 (cable-158-181-75-126.cust.telecolumbus.net.
 [158.181.75.126])
 by smtp.gmail.com with ESMTPSA id y5sm804450edd.49.2019.05.30.08.11.32
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 30 May 2019 08:11:32 -0700 (PDT)
From: Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: electric-pair-mode fails to balance in certain cases
Date: Thu, 30 May 2019 17:11:31 +0200
Message-ID: <87woi80yfw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a00:1450:4864:20::531
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Consider the following text in html-mode with electric-pair-mode turned
on and electric-pair-skip-self set to electric-pair-default-skip-self:

         <|>

(Take | to denote point.)  In this situation, the expected result of
attempting to insert > is to skip over the one immediately after point,
i.e., end up with <>|.  However, what we get instead is <>|>.  Only if
we *now* attempt to insert >, we end up with <>>|, which doesn't make
any sense.

The same behavior is observed with ordinary parentheses in html-mode,
too.

From my debugging, the culprit seems to be an unnecessary (or mistaken?)
use of electric-pair--with-uncached-syntax.  I am not sure *why* exactly
it happens, and would appreciate further insight.

The patch shown below fixes the issue.

diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 5fb9d751e2..6450d02c9e 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -325,11 +325,9 @@ electric-pair--balance-info
                         (cond ((< direction 0)
                                (condition-case nil
                                    (eq (char-after pos)
-                                       (electric-pair--with-uncached-syntax
-                                           (table)
-                                         (matching-paren
-                                          (char-before
-                                           (scan-sexps (point) 1)))))
+                                       (matching-paren
+                                        (char-before
+                                         (scan-sexps (point) 1))))
                                  (scan-error nil)))
                               (t
                                ;; In this case, no need to use

-- 
Dario Gjorgjevski :: <dario.gjorgjevski@HIDDEN>
                  :: 744A 4F0B 4F1C 9371
                  :: +48 1525 8666837




Acknowledgement sent to Dario Gjorgjevski <dario.gjorgjevski@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#36006; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 27 Aug 2020 19:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.