GNU bug report logs - #40865
26.3; Electric pair mode and syntax class $

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; Reported by: Augusto Stoffel <arstoffel@HIDDEN>; merged with #32076; dated Sun, 26 Apr 2020 10:40:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 32076 40865. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 40865) by debbugs.gnu.org; 12 May 2020 21:58:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 12 17:58:50 2020
Received: from localhost ([127.0.0.1]:56752 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jYcvK-0002s9-9k
	for submit <at> debbugs.gnu.org; Tue, 12 May 2020 17:58:50 -0400
Received: from mail-wm1-f46.google.com ([209.85.128.46]:37498)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1jYcvE-0002rp-IO
 for 40865 <at> debbugs.gnu.org; Tue, 12 May 2020 17:58:49 -0400
Received: by mail-wm1-f46.google.com with SMTP id z72so16145182wmc.2
 for <40865 <at> debbugs.gnu.org>; Tue, 12 May 2020 14:58:44 -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:content-transfer-encoding;
 bh=tg4lRkJgw89J4HAh25ARka+sNFoSSCxBsT0izoQyByQ=;
 b=B2YXh3ccagB5Nmy3OPa7Grf3EawREugZ/v12x1asEgizEMLgpOM38j9KbbVtve3kG5
 fIOJJGoK9O8PKtTHoVuXoYR9ws3lPfCmoKWcr3reEhqsSkH0qPkrV24X6TGZ9twP2JI2
 1aGc5NvrFe2NFkQDovSuWMH7nm8tgGK/FyaXSd8BD13l7qafClvBtbRPOVsZ7irtQvMO
 a78yvRbma26R2889vF4nR0JVQ0Fd7bGmeAOT+A5nzdI9pKYD0cIOVbKwRPQ0WdRFbs+4
 w6DF6MNk2zLuJ6eYrvSDIw2eFE/pZ1g+RmD2oh+ELLw5hH0DPIW1ExlZItUQ7dze2nqU
 lvFw==
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:content-transfer-encoding;
 bh=tg4lRkJgw89J4HAh25ARka+sNFoSSCxBsT0izoQyByQ=;
 b=DZrdyxm0fP0PzB5G9p9BhzOLOMWUpCSS+OH3/9SPlhVAhW8R9xfw1Yor09KhKLxUt3
 QPnd2twFQdhXI8+J/0iqDWQk77dPu8TO4UixpAADwXn216+t5rL+BGnawuRFjeenhD+3
 HWR8N1xf/XIVm7QOy6PKZIaqBMutRe3nFCavQIsyV6fMllL7J19ICbCNxO0V1XvNCF9i
 DM/vz0P0eqOwYi1jIUexGTjkv1fJOsxedbiWLjhY0YGCyr6UQKtoYhZ6inCh6yyk54vC
 B3cZiH+HAfHMR7ZydCl8c3DKnUigDsVjNI0dCaKWOr3nbNqNxIuHA2VPDaHeXL6Svo6O
 A9ag==
X-Gm-Message-State: AGi0PuY0KFSKHBVpLZwhFn3UOwVeUvLb1/xyJRoXalvTQr9dqq56wkAh
 ARMq99eIU/5VAq89n4/b9e6TZyJB0tI=
X-Google-Smtp-Source: APiQypIC2mKa0qMgY0jxWmjH+FAfOP8bDKFlY58BVNF4RrZ6yz/e9R+5TxXZYgznGNy5IcmhU4RD9A==
X-Received: by 2002:a1c:7308:: with SMTP id d8mr19056845wmb.6.1589320718297;
 Tue, 12 May 2020 14:58:38 -0700 (PDT)
Received: from krug ([2001:818:d820:9500:824a:171:15a:2213])
 by smtp.gmail.com with ESMTPSA id r11sm21751300wma.35.2020.05.12.14.58.36
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 12 May 2020 14:58:37 -0700 (PDT)
From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
To: Augusto Stoffel <arstoffel@HIDDEN>
Subject: Re: bug#40865: 26.3; Electric pair mode and syntax class $
References: <993210aab0f5abcac7e2e84e4289468431c5b5f5.camel@HIDDEN>
Date: Tue, 12 May 2020 22:58:36 +0100
In-Reply-To: <993210aab0f5abcac7e2e84e4289468431c5b5f5.camel@HIDDEN>
 (Augusto Stoffel's message of "Sun, 26 Apr 2020 12:18:32 +0200")
Message-ID: <87imh0ak8j.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 40865
Cc: 40865 <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 (-)

Augusto Stoffel <arstoffel@HIDDEN> writes:

Hi Augusto, thank you for the report.

> Electric pair mode does not treat string quote characters and paired
> delimiters (syntax class "$") in the same way, but it should probably
> do so.

Paired delimiters don't formally define any kind of syntactic region
between them, contrary to string delimiters.

Therefore, electric-pair-mode can't easily know if a decision to skip or
auto-pair would be benefitting the balance of the syntax buffer.
Therefore, it decides to be dumb and always autopair, never autoskip.

If I had chosen the alternative, having your point just before a '$foo$'
would make autoskip put it inside the group, instead of creating a new
'$$$foo$', which is probably what you wanted in that particular
situation.

Maybe, even though flawed, that is more defensible as a default
behaviour than the current one.  At least it doesn't seem to break any
tests.

The "correct" way to fix this is to make latex-mode treat paired
delimiters like it does string delimiteres.  But that probably has other
negative implications that I'm not aware of.

I have the vague recollection that this came up when I was developing
electric-pair-mode, particularly in latex-mode, some 6 years ago, but I
can't remember anymore.

Anyway, if you do prefer the alternative I gave earlier you can do this:

(add-hook 'latex-mode-hook
          (lambda ()
            (add-function :before-until
                          (local 'electric-pair-skip-self)
                          (lambda (char) (eq char ?$))
                          '((name . latex-skip-paired-delimiters)))))

Jo=C3=A3o

PS: On a related note, note that AUCTex mode (a different mode to edit
TeX files) has a special binding for the dollar sign, TeX-insert-dollar,
which doesn't follow _any_ of electric-pair-mode.





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

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


Received: (at submit) by debbugs.gnu.org; 26 Apr 2020 10:39:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 26 06:39:21 2020
Received: from localhost ([127.0.0.1]:60934 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jSegy-0006ya-1v
	for submit <at> debbugs.gnu.org; Sun, 26 Apr 2020 06:39:20 -0400
Received: from lists.gnu.org ([209.51.188.17]:39816)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <arstoffel@HIDDEN>) id 1jSeMx-0006Ms-A2
 for submit <at> debbugs.gnu.org; Sun, 26 Apr 2020 06:18:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:46084)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <arstoffel@HIDDEN>) id 1jSeMw-0002EU-LR
 for bug-gnu-emacs@HIDDEN; Sun, 26 Apr 2020 06:18:39 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,
 RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <arstoffel@HIDDEN>) id 1jSeMv-0007ly-Ue
 for bug-gnu-emacs@HIDDEN; Sun, 26 Apr 2020 06:18:38 -0400
Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35025)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1jSeMv-0007ln-Fx
 for bug-gnu-emacs@HIDDEN; Sun, 26 Apr 2020 06:18:37 -0400
Received: by mail-wr1-x42d.google.com with SMTP id x18so16912894wrq.2
 for <bug-gnu-emacs@HIDDEN>; Sun, 26 Apr 2020 03:18:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=message-id:subject:from:to:date:user-agent:mime-version
 :content-transfer-encoding;
 bh=Lddyk2sttBlqR6qZAPsL3+WuULDflEbNE9EjQcW9Op0=;
 b=nvaOWtcpUcxdq3ibKXSYluJbg3E+exumh7xO99SHif2ErOQDAyrUjg3naUqysce+Z8
 Gme42UqKgM1j+hBCyn3JsqqKPuzu09XVTKYBhRtfOZ0VxuQgeLK45PMUTd0Ou5vX1guZ
 v9ayBo0S7M2Nz6n6Lkfp8eat6o4hLJD46EizTukCWfElEV6hpb9FVzhMEkZ4PmMMES4z
 HHKz+KEALZn+byodg0bIBLXmvzqzVHmocVmX6mR771SeWeWi9oT+oJK9AvTvOd5rkYUu
 27mEWPlFyvKmsgCnWgD2BITXpgbrPY6UOVFYK/yWCKCAMg9n0Y0zt+cstZbq5luBSl5e
 T4XA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:message-id:subject:from:to:date:user-agent
 :mime-version:content-transfer-encoding;
 bh=Lddyk2sttBlqR6qZAPsL3+WuULDflEbNE9EjQcW9Op0=;
 b=PRk95YGW6Rke2Io+OQt8YCbdVj7OkLm/nw4uao0YjBwsqR1aLZoAFrnIGo3rOETVaN
 bu5okVvYA+Lr+yZ5pcRQfJ1340J/va/hUP/v6gJyu7jntP9NRp7tjZ7MSy+yyfW+Mo3N
 yfB4CbSAVxH7q6rJfpE5WQ6WLCgxyGye2SvKmqd1KF4vWh/+WIKqvoeoK+ySkvJimTDj
 t2xYI3jaz77leoeFYtKyvWVm9pyRSyQTP02+DdRCxPteFZqaqhJnWJAEDeLyjN1Ypuy+
 +26j7me3vCVLe0qgB5yz4OwXIrKBL4jypRdOPjng0TjTc5j7KS2Dlk6hIgLcLvQaH3w/
 ScJg==
X-Gm-Message-State: AGi0PubgQME1rBqqayDeyupJlO8l8NmCKYS0JaL2eh4+E0JyjiFkpvef
 9id9j+BksHGaztmSWamvXmUC7Tq6
X-Google-Smtp-Source: APiQypL75xdnRj0QWaze37WCpd1yPsa+EXh0DFcxRgVsM/2Wc+WQ3Bl/h/PvqANaldnVC2vsIj2FKw==
X-Received: by 2002:a5d:464d:: with SMTP id j13mr21840249wrs.269.1587896314789; 
 Sun, 26 Apr 2020 03:18:34 -0700 (PDT)
Received: from ars3 ([2a02:908:2210:8d60:5f6d:b463:4bd5:6b76])
 by smtp.gmail.com with ESMTPSA id l4sm16586379wrv.60.2020.04.26.03.18.33
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 26 Apr 2020 03:18:34 -0700 (PDT)
Message-ID: <993210aab0f5abcac7e2e84e4289468431c5b5f5.camel@HIDDEN>
Subject: 26.3; Electric pair mode and syntax class $
From: Augusto Stoffel <arstoffel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Date: Sun, 26 Apr 2020 12:18:32 +0200
Content-Type: text/plain; charset="UTF-8"
User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) 
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Received-SPF: pass client-ip=2a00:1450:4864:20::42d;
 envelope-from=arstoffel@HIDDEN; helo=mail-wr1-x42d.google.com
X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT :
 Malformed IPv6 address (bad octet value).
 Location : parse_addr6(), p0f-client.c:67
X-Received-From: 2a00:1450:4864:20::42d
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sun, 26 Apr 2020 06:39:19 -0400
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 (--)

Electric pair mode does not treat string quote characters and paired
delimiters (syntax class "$") in the same way, but it should probably
do so.

For instance, in TeX mode with electric pair mode active, typing a
dollar sign in the situation

    $a<point here>$

shold result in

    $a$<point here>

but instead results in

    $a$<point here>$$

The issue seems to be related with the function
`electric-pair-skip-if-helps-balance'.

In GNU Emacs 26.3 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
3.24.13)
 of 2019-12-10 built on buildhw-07.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.12006000
Recent messages:

Quit [2 times]
Making completion list... [2 times]

next-line: End of buffer
Quit
(New file)
Making completion list...

Auto-saving...done
delete-backward-char: Beginning of buffer
Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-
png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no --with-xwidgets --with-modules
 build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Werror=format-security
 -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
 -fstack-protector-strong -grecord-gcc-switches
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS GLIB NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LCMS2

Important settings:
  value of $LC_MONETARY: en_IE.UTF-8
  value of $LC_NUMERIC: en_IE.UTF-8
  value of $LC_TIME: en_IE.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  electric-pair-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils pp wid-edit descr-text cl-extra help-fns
radix-tree help-mode easymenu cl-loaddefs cl-lib cus-start cus-load
tex-mode compile shell pcomplete comint ansi-color ring elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham
georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 119197 10577)
 (symbols 48 34191 1)
 (miscs 40 85 126)
 (strings 32 90141 1712)
 (string-bytes 1 2065674)
 (vectors 16 16375)
 (vector-slots 8 917191 21162)
 (floats 8 65 235)
 (intervals 56 429 0)
 (buffers 992 14))





Acknowledgement sent to Augusto Stoffel <arstoffel@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#40865; 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, 24 Jun 2021 16:45:02 UTC

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