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, 09 Nov 2024 11:22:48 +0200 Message-ID: <86v7wwn4lz.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28072"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73688@debbugs.gnu.org To: Marc Soda , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 09 10:23:06 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 1t9hgQ-00079x-8l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Nov 2024 10:23:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9hgN-0004GF-Qd; Sat, 09 Nov 2024 04:23:04 -0500 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 1t9hgM-0004Fx-MM for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 04:23:02 -0500 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 1t9hgM-0002Kc-Dk for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 04:23:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=7+fgVvbn4s7XwBnqEaqD2zU177hypTE/niyCSCUqOF0=; b=Q8E4RzYG1E34xg0ws/n1fIS3PWzZgq9y4tdt3/rzgLe08RZfxn95LjKWK85S3Jc+ItHkBaAvHfh2W3vhCzXLIzTXdJ3zgs/hzQGxZM/mN+VW1uZNj531qK6rbDK4uWBtviu9PFNNsl8zfrRW55r5G3mdQQfIzuvYDeW5je/2Tjeu3gedRLOVUO51v7P/FzANHbx7qF05oo51qzZp/8/4C8C7ggCo4NbIjLib7EqKpVO0oGsOsysbj7ICUNsYLNgpS+wCfVtTVWqBGV9GUnDQoxT1OSrAwsupaj581PsqzGi3JvWMSQZG5np3LDfJpxGOr/DKxDmdnarXPf1fqMQuzg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9hgM-0001on-9J for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 04:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Nov 2024 09:23: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.17311441806980 (code B ref 73688); Sat, 09 Nov 2024 09:23:02 +0000 Original-Received: (at 73688) by debbugs.gnu.org; 9 Nov 2024 09:23:00 +0000 Original-Received: from localhost ([127.0.0.1]:53430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9hgJ-0001oU-Ty for submit@debbugs.gnu.org; Sat, 09 Nov 2024 04:23:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9hgH-0001oI-Rs for 73688@debbugs.gnu.org; Sat, 09 Nov 2024 04:22:58 -0500 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 1t9hgB-0002Jr-7H; Sat, 09 Nov 2024 04:22:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7+fgVvbn4s7XwBnqEaqD2zU177hypTE/niyCSCUqOF0=; b=dqWEcpR4rOY8 dNsZb4yhH2OrYedJsy3JzyR/W6ukAOCewt/sUWDpICILphAwIJKjn6wDoiUAIKbtzWf0lZW2S2Eld nRfaT5Z3s0nFEFtnm5Uo5+tozg4E1yRs6shb1icn0Zwgy1Inl2I40HNwpWyZikBdhCz71O9BUieOO KA7oE13WxoYMX0QnPibCol/27a2mdlPvSY/0e++3uIAqozq2KvyBhRhraijcIak1oLJ+FwhLvQdF0 FxZb1Epg593D/fAYxEbz6bL4y3IbVU6VS1JkqDwCbRUGaUdV9RErtihexmoaE3y/KOXn/ZYhw/jR5 fEjKYBolsXerf58HfUxa1A==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:295113 Archived-At: Ping! Marc, can you please answer Stefan's questions? > Cc: 73688@debbugs.gnu.org > Date: Sat, 26 Oct 2024 14:47:02 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > >> IOW, why do you use `electric-pair-conservative-inhibit` if you care > >> about preserving global balance? > > > > Fair enough. To answer your question, I want the other things you have > > listed in `electric-pair-conservative-inhibit`. In particular, the > > line commented "I also find it often preferable not to pair next to > > a word." is very valuable to me. However, I can solve my issue pretty > > easily by adding something like the following to my init.el: > > > > (setq electric-pair-inhibit-predicate > > ;; Also inhibit if the pair would balanced > > (lambda (char) > > (or (electric-pair-conservative-inhibit char) > > (electric-pair-inhibit-if-helps-balance char)))) > > I see, I think you can get the same result with > > (add-function :before-until electric-pair-inhibit-predicate > #'electric-pair-conservative-inhibit) > > But maybe it would make sense to add a third value to > `electric-pair-preserve-balance` to get the behavior you describe. > > > The reason I submitted the patch is because is took me several years > > to get irritated enough to dig in and fix it for myself! :) Also, like > > I said above, it seemed non-intuitive. Thanks for considering, but > > feel free to disregard. > > Do you have an idea of how/where we could change some of the > documentation to avoid that kind of problem in the future? > > > Stefan > > > > >