GNU logs - #66155, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66155: 'electric-pair-inhibit-if-helps-balance' has side-effects
Resent-From: Akib Azmain Turja <akib@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 22 Sep 2023 11:53:01 +0000
Resent-Message-ID: <handler.66155.B.16953835715213 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 66155
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 66155 <at> debbugs.gnu.org
Cc: Daniel Mendler <mail@HIDDEN>
X-Debbugs-Original-To: bug-gnu-emacs <bug-gnu-emacs@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.16953835715213
          (code B ref -1); Fri, 22 Sep 2023 11:53:01 +0000
Received: (at submit) by debbugs.gnu.org; 22 Sep 2023 11:52:51 +0000
Received: from localhost ([127.0.0.1]:35455 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qjeiI-0001M1-Hc
	for submit <at> debbugs.gnu.org; Fri, 22 Sep 2023 07:52:50 -0400
Received: from lists.gnu.org ([2001:470:142::17]:46494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <akib@HIDDEN>) id 1qjeiF-0001Ln-K6
 for submit <at> debbugs.gnu.org; Fri, 22 Sep 2023 07:52:48 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <akib@HIDDEN>) id 1qjehz-0003kl-E7
 for bug-gnu-emacs@HIDDEN; Fri, 22 Sep 2023 07:52:31 -0400
Received: from layka.disroot.org ([178.21.23.139])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <akib@HIDDEN>) id 1qjehx-0001T5-Af
 for bug-gnu-emacs@HIDDEN; Fri, 22 Sep 2023 07:52:31 -0400
Received: from localhost (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 76C42419F5;
 Fri, 22 Sep 2023 13:52:25 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from layka.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 44KvHDcsUNMB; Fri, 22 Sep 2023 13:52:24 +0200 (CEST)
From: Akib Azmain Turja <akib@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
 t=1695383544; bh=gMifL5b4EevuAmY8ABJkz5R4TWmyDsT4l82vF3T8Pb0=;
 h=From:To:Cc:Subject:Date;
 b=Qg2ijt1NI5UF/Km5CHIzOYUntdtD7vDw7Trd7X1Q3NTMyAkLozMCNZ0wceCOPvIRU
 LCl2PS7N1ewoSc2RFBd76t7VxnGRCKCNXV9iKHfUV7rsubiEnNoacgY9IPVDLg/fhL
 RWSkYl1drZrkn9wVmOw04lrbzRWOTiH1Y9hyfQMY8ph1qDJL8qcECTVI+DMWb/Fbjs
 cdnvbF6JRxYhs6d5why0JYbLnguA/SR11SqYcInD567mpX0wh8ryKQu7AVDz6v9VRK
 i48YyqAImLfV65F61ejhp05CPgg1+HsiHxLbw3PiDKs7ubXz6M5TwWACNWzNNAqzRY
 Id/JHiSywojwQ==
Date: Fri, 22 Sep 2023 17:51:55 +0600
Message-ID: <878r8ye884.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
Received-SPF: pass client-ip=178.21.23.139; envelope-from=akib@HIDDEN;
 helo=layka.disroot.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
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: -0.1 (/)

--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


With the default configuration (which uses
'electric-pair-inhibit-if-helps-balance'), inserting parens at the end
of a Tempel field doesn't extend the field.

I think the modify+undo magic in electric-pair-inhibit-if-helps-balance
moves markers.

The following is the solution that works for me atleast; it uses insert
to insert back the character, and let-bind buffer-undo-list to not
clobber the undo list.

=2D-8<---------------cut here---------------start------------->8---
(defun *electric-pair-inhibit-if-helps-balance (char)
  "Return non-nil if auto-pairing of CHAR would hurt parens' balance.

Works by first removing the character from the buffer, then doing
some list calculations, finally restoring the situation as if nothing
happened."
  (pcase (electric-pair-syntax-info char)
    (`(,syntax ,pair ,_ ,s-or-c)
     (let ((buffer-undo-list t))
       ;; Don't use `delete-char'; that may modify the head of the
       ;; undo list.
       (delete-region (point) (1- (point)))
       (let ((ret
              (cond
               ((eq ?\( syntax)
                (let* ((pair-data
                        (electric-pair--balance-info 1 s-or-c))
                       (outermost (cdr pair-data)))
                  (cond ((car outermost)
                         nil)
                        (t
                         (eq (cdr outermost) pair)))))
               ((eq syntax ?\")
                (electric-pair--unbalanced-strings-p char)))))
         (insert (string char))
         ret)))))
=2D-8<---------------cut here---------------end--------------->8---

=2D-=20
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@HIDDEN
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEyVTKmrtL6kNBe3FRVTX89U2IYWsFAmUNf9wACgkQVTX89U2I
YWtUBBAAq4tjyT8nLnQm5Pm8YYmplYCqQa1ByRGJP4WB2pwtlRqHwjIQo8N5rhoU
RHL8UmdA9ofkEHs3trU95z45yLhQT7T6XbwOQlBJL/jc9qnFhcVAkm2VJbh2WKEC
H2RsJN8ADYNv0MW1+a5b6RTH3c8oN9SQaMG+qeucysv5rqfkLDstOjeGwiKi9xhF
NNIx9UBSNgh5Dga1Dpj+7TQEhZFOWRRj7UPlKUjk5Fh+PKYpiSrfYQb41WXkrpvT
h3fQLqtDdjByoFAyLvFWqPc27BKzd87mc4271zwO1JLbjircvgf+ON1nRRsNB7Z7
n4rJPZKKgoCnypmdu3ZYbVzrNwtDmOPQbLdAzbkKC9I13GkO1k4mnrNknwXMOFrZ
6ID6eNMGcMzYb1C7i1lzI37YMi+FayQQCEo8qsDIZAWWCHzLyd+2upnVKlUTW5Oi
Hptpwwf9hl3WGWjYLDHzEOQGABtiglqPnnSP71sSbRLt8G/++OQ9Ol1uh4kD/MQ/
XowuM5f0j9B1Q57+7eVSsKyeYsJsujZOTxUl4pAc7ZET7lAiew5SPXw56Y8o8c2y
Ap19ue30AB9QuJR153uiE641ueEGWRcO3Jp6sjGNiabCz01a4HZxqdCu0AVE+vkd
GD9krO6J56//Wumn5y0lxFy4OkEjCDkK5rpeahIcicMuzF1kTlc=
=HRFU
-----END PGP SIGNATURE-----
--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Akib Azmain Turja <akib@HIDDEN>
Subject: bug#66155: Acknowledgement ('electric-pair-inhibit-if-helps-balance'
 has side-effects)
Message-ID: <handler.66155.B.16953835715213.ack <at> debbugs.gnu.org>
References: <878r8ye884.fsf@HIDDEN>
X-Gnu-PR-Message: ack 66155
X-Gnu-PR-Package: emacs
Reply-To: 66155 <at> debbugs.gnu.org
Date: Fri, 22 Sep 2023 11:53:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 66155 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
66155: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66155
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#66155: 'electric-pair-inhibit-if-helps-balance' has side-effects
Resent-From: Stefan Kangas <stefankangas@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 01 Oct 2023 08:11:01 +0000
Resent-Message-ID: <handler.66155.B66155.16961478149313 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 66155
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Akib Azmain Turja <akib@HIDDEN>
Cc: Daniel Mendler <mail@HIDDEN>, 66155 <at> debbugs.gnu.org
Received: via spool by 66155-submit <at> debbugs.gnu.org id=B66155.16961478149313
          (code B ref 66155); Sun, 01 Oct 2023 08:11:01 +0000
Received: (at 66155) by debbugs.gnu.org; 1 Oct 2023 08:10:14 +0000
Received: from localhost ([127.0.0.1]:60456 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qmrWn-0002Q9-Lm
	for submit <at> debbugs.gnu.org; Sun, 01 Oct 2023 04:10:14 -0400
Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:56515)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1qmrWl-0002Ps-Th
 for 66155 <at> debbugs.gnu.org; Sun, 01 Oct 2023 04:10:12 -0400
Received: by mail-lf1-x132.google.com with SMTP id
 2adb3069b0e04-5041335fb9cso23971567e87.0
 for <66155 <at> debbugs.gnu.org>; Sun, 01 Oct 2023 01:09:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1696147790; x=1696752590; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=yAAAJ9xOlM6ea37d+/ur1U2JdFB981GXSIwQBKeuRxk=;
 b=kNtQwt3as1PBd/wVPs4CjUqiqNhDfeB3Gygzt7H5bW0xXYmgD9BJ5R7ma4oK6NMtr2
 lvVTzLmkn38ZqaWZT7hqzP1PL08crke2oMq5IirkyyjztGaIR+el6wrVTiE8jqrSvWjR
 3iSjdGtszlbxJz0t2YzZx2wE8wGVk/zxeqI5+LKmgKkMV1WQslbnj+5xJuxIA7nw7jHB
 pJawsXPKm0ooHSLK2bAAUT04tiVdWqrP2cZJENF3J+HZLXRYTZTc6DQozbnFwMoLIddF
 CREltPWHGu6zCVDPO+nJH7Jvuky7Is6WGBkcBUZDUeic7CVZcBiOAhu84LF5S1YbM3Ot
 uoxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1696147790; x=1696752590;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=yAAAJ9xOlM6ea37d+/ur1U2JdFB981GXSIwQBKeuRxk=;
 b=dbVrC6vl6igpMZLa6hGPIU+Iaj94XsaU5fKSsIZw6GNimRP7FyOgtiIJr3EPvDTr8o
 F/CMIPkWP7KqplIBjICozRhllLiXC0oYrlyWnrcVPBX9A4f97rbMte35fNMR8VPVOVtR
 0U3HBekTE+d+mzCP5KtY74rGwmm91yu0PSCdakauMyo0Ly25mTp067Z+DAt8V/1SgL5T
 GB/mWdpSPS8IOzoCwXmrHSP/+llFgHnPaVQqdBBp3vItOKuxvKIIlkv9hY89KU6/mSlm
 slZzX6H150oIRbiukhOa00cuHurLOtJMf1Nw8WH/JPNCKgXPgy1O9of5eO3a+8tSBazA
 Ukww==
X-Gm-Message-State: AOJu0Yyd0f8wCHKhr3bYbQnowS47tC48yTLWGtaLRSV1KJju1NhOCnAf
 fV6gdmQwPVpnwR9i68GTsWJ4cYybG5bl5lxFrNk4EHwW
X-Google-Smtp-Source: AGHT+IHQBpSED6WwLlsfwI9p3oiJ6Zl42VntgRp8IkLCPvbVKnfZAu3pMxm0X88nhcftYZZj1ASB+x3TToJk7Px366E=
X-Received: by 2002:ac2:4c4e:0:b0:503:3281:2ffd with SMTP id
 o14-20020ac24c4e000000b0050332812ffdmr9212059lfk.41.1696147790019; Sun, 01
 Oct 2023 01:09:50 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 1 Oct 2023 01:09:49 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <878r8ye884.fsf@HIDDEN> (Akib Azmain Turja's message of
 "Fri, 22 Sep 2023 17:51:55 +0600")
References: <878r8ye884.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sun, 1 Oct 2023 01:09:49 -0700
Message-ID: <CADwFkm=9zvHeRUGXrNY2Z87sh+Q5MT6fMu6Mg9YzQ_tHhAHOjQ@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
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 (-)

Akib Azmain Turja <akib@HIDDEN> writes:

> With the default configuration (which uses
> 'electric-pair-inhibit-if-helps-balance'), inserting parens at the end
> of a Tempel field doesn't extend the field.
>
> I think the modify+undo magic in electric-pair-inhibit-if-helps-balance
> moves markers.
>
> The following is the solution that works for me atleast; it uses insert
> to insert back the character, and let-bind buffer-undo-list to not
> clobber the undo list.
>
> (defun *electric-pair-inhibit-if-helps-balance (char)
>   "Return non-nil if auto-pairing of CHAR would hurt parens' balance.
>
> Works by first removing the character from the buffer, then doing
> some list calculations, finally restoring the situation as if nothing
> happened."
>   (pcase (electric-pair-syntax-info char)
>     (`(,syntax ,pair ,_ ,s-or-c)
>      (let ((buffer-undo-list t))
>        ;; Don't use `delete-char'; that may modify the head of the
>        ;; undo list.
>        (delete-region (point) (1- (point)))
>        (let ((ret
>               (cond
>                ((eq ?\( syntax)
>                 (let* ((pair-data
>                         (electric-pair--balance-info 1 s-or-c))
>                        (outermost (cdr pair-data)))
>                   (cond ((car outermost)
>                          nil)
>                         (t
>                          (eq (cdr outermost) pair)))))
>                ((eq syntax ?\")
>                 (electric-pair--unbalanced-strings-p char)))))
>          (insert (string char))
>          ret)))))

Could you please send the patch as an attachment instead?  We prefer
that patches are created with a command like `git format-patch -1'.

Please also include:

- The bug number of this bug in the commit message, like so: Bug#66155

- A ChangeLog entry, as described in the file CONTRIBUTE.

That would make it easier for us to review and hopefully install
this patch.  Thanks in advance.





Last modified: Sun, 1 Oct 2023 08:15:02 UTC

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