all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode
@ 2024-10-08  3:10 Marc Soda
  2024-10-12 12:21 ` Eli Zaretskii
  2024-10-17 16:48 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 13+ messages in thread
From: Marc Soda @ 2024-10-08  3:10 UTC (permalink / raw)
  To: 73688


[-- Attachment #1.1: Type: text/plain, Size: 1407 bytes --]

When using electric-pair-mode, electric-pair-conservative-inhibit
doesn't respect electric-pair-preserve-balance. For example, type out a
string, go to the beginning of the line, type ", go to the end of the
line, and type ". You are left with "foo"". (Exact keys from the start
of a line are fooC-a"C-e", if that's more clear.) I would expect to be
left with "foo" instead.

This is easy to resolve in your init file (after some digging), but I
think the current behavior is non-intuitive.

Please consider the attached patch.

In GNU Emacs 29.4 (build 2, x86_64-apple-darwin23.6.0, NS appkit-2487.70
Version 14.6.1 (Build 23G93)) of 2024-10-03 built on gemini.local
Windowing system distributor 'Apple', version 10.3.2566
System Description: macOS 15.0.1

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs-plus@29/29.4/share/info/emacs
--prefix=/usr/local/Cellar/emacs-plus@29/29.4 --with-xml2 --with-gnutls
--with-native-compilation --without-compress-install --without-dbus
--without-imagemagick --with-modules --with-rsvg --with-ns
--disable-ns-self-contained 'CFLAGS=-O2 -DFD_SETSIZE=10000
-DDARWIN_UNLIMITED_SELECT -I/usr/local/opt/gcc/include
-I/usr/local/opt/libgccjit/include' 'LDFLAGS=-L/usr/local/lib/gcc/14
-I/usr/local/opt/gcc/include -I/usr/local/opt/libgccjit/include''

[-- Attachment #1.2: Type: text/html, Size: 2548 bytes --]

[-- Attachment #2: 0001-preserve-balance-in-conservative-mode.patch --]
[-- Type: application/octet-stream, Size: 1012 bytes --]

From 7b75b4d1447157fac733c6a1bf23b5e4b7362a65 Mon Sep 17 00:00:00 2001
From: Marc Soda <marc@soda.fm>
Date: Mon, 7 Oct 2024 22:54:33 -0400
Subject: [PATCH] preserve balance in conservative mode

---
 lisp/elec-pair.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index c9627763d8d..382307503e8 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -200,7 +200,11 @@ be considered.")
    (and (eq char (char-before))
 	(eq char (char-before (1- (point)))))
    ;; I also find it often preferable not to pair next to a word.
-   (eq (char-syntax (following-char)) ?w)))
+   (eq (char-syntax (following-char)) ?w)
+   (eq (char-syntax (following-char)) ?w)
+   ;; Also consider preserving balance
+   (and electric-pair-preserve-balance
+        (electric-pair-inhibit-if-helps-balance char))))
 
 (defmacro electric-pair--with-syntax (string-or-comment &rest body)
   "Run BODY with appropriate syntax table active.
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-11-10 14:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08  3:10 bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode Marc Soda
2024-10-12 12:21 ` Eli Zaretskii
2024-10-12 19:47   ` Marc Soda
2024-10-12 20:36   ` João Távora
2024-10-12 20:43     ` Marc Soda
2024-10-12 23:36       ` João Távora
2024-10-17 16:48 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-26 17:48   ` Marc Soda
2024-10-26 18:47     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09  9:22       ` Eli Zaretskii
2024-11-09 10:30         ` Nikolay Kudryavtsev
2024-11-09 15:55           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-10 14:28             ` Nikolay Kudryavtsev

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.