From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode Date: Sat, 12 Oct 2024 15:21:28 +0300 Message-ID: <86iktxwlyv.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32391"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73688@debbugs.gnu.org To: Marc Soda , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 12 14:26:12 2024 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 1szbCF-0008FD-JS for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Oct 2024 14:26:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szbBu-0003OI-1g; Sat, 12 Oct 2024 08:25:50 -0400 Original-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 ) id 1szbBs-0003NZ-BH for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2024 08:25:49 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szbBs-0003kb-2c for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2024 08:25:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=w1NWkLHov7oshQ8qf+xJlviRczeLPj5lbKSdwB3u1UE=; b=qyHxQuoDK2RVCT/O1KY8NtQp4zZ570Q2U77Dw+jfrNor0J/m3fhhMx+Ot5oYIwVFIu6722Vm+klw/PRCH6mtpOZl0H4HkzKqm3vzQMglpI7n6jXPBosLcZkwCDlouBmvqTqqZljGp+6B13V3FjC636qMeXAUoCgmTNXhGFGtaaXqrKaeg4xkqIQGupu2+GqSS8uZg8ocIedqMsfEAw1o4t2PV44dH9MjuKwbXGMW5RdJHMUNxaAnPxN08L+OBhUYN1VymTTU1JtW0dicAp0EJwLr+iCOpd0Y73736uh/edChIs2GUxC5BL9PcdB97+ZySlX0cUpBCPGeSHs5vSG5HQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1szbC6-0002ze-1i for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2024 08:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Oct 2024 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73688-submit@debbugs.gnu.org id=B73688.172873591810926 (code B ref 73688); Sat, 12 Oct 2024 12:26:02 +0000 Original-Received: (at 73688) by debbugs.gnu.org; 12 Oct 2024 12:25:18 +0000 Original-Received: from localhost ([127.0.0.1]:41234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szbBN-0002q1-3W for submit@debbugs.gnu.org; Sat, 12 Oct 2024 08:25:17 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49876) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szb87-0002hP-5W for 73688@debbugs.gnu.org; Sat, 12 Oct 2024 08:21:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1szb7n-0003QX-Jx; Sat, 12 Oct 2024 08:21:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=w1NWkLHov7oshQ8qf+xJlviRczeLPj5lbKSdwB3u1UE=; b=XuBtLkgZytA6uIlDxcTa 3CJI7Zah0YM7ppcjPumDZI+BkX3O6Yumx1XnSalJMouv2CRbQxZkY3TdyGe0c5KCrNq3F/eaxg9nt kU+50Qy4bHJuZ5hWKXrsGaf5pmXwgO7+p87+6s0S7qY1okYpb3WbxUlYMVAxVZnM7CLcQd2cuibcx z+ISsClQl1dsrNESNU0fyo2U0VX2YDP98TVK/V3A3n97pBlGaIW/AmqUd6iNWwe2yu9paW/t+woB/ F9HbN+czP8gFNVD454nwLChTtkCkvT+9Adp+BpbpCdzoIN56MmDnmo68Ht6+vceUw3G6mCanKarDg a/Abeak7LJ+9Bw==; In-Reply-To: (message from Marc Soda on Tue, 08 Oct 2024 03:10:54 +0000) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293430 Archived-At: > Date: Tue, 08 Oct 2024 03:10:54 +0000 > From: Marc Soda > > 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. João, do you have any comments? > 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)))) Why duplicate lines there?