From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode Date: Sat, 26 Oct 2024 14:47:02 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11262"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 73688@debbugs.gnu.org To: Marc Soda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 26 20:47:58 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 1t4lpO-0002mk-6u for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Oct 2024 20:47:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4low-0003PV-Tz; Sat, 26 Oct 2024 14:47:31 -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 1t4lou-0003Os-GT for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 14:47:29 -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 1t4lou-0001oy-7q for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 14:47:28 -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:Date:References:In-Reply-To:From:To:Subject; bh=ksEjj4v2TU46xaLV0TqBTF2bSH1lOvIvE/pihcNYWN8=; b=GZOAFlYc8pbngl1YmFn+ZjbQbsjuhV/9h3a1giiyk4722cad2gKs3WUYiPOUrokIhZoXKA4/3jYjOOYLmd8duDMQHtXTxrMVh005O/H5zd3zzbXDTwHc5BWSHy6WUbYumi2rq/ktqsZnydu2OyIFfZeV97UNov4B1oAbFbEYY2XyzQ5L3nc5WVAAA4MTnl2v+3FDhKemtFfJ8k/PCbjBtz8pBkP5YMVrUviVOIws05+mf/kMHUatxCvuQFhlvB9w4D/pLqakreX5n5cqImTz+y77rO+VJago+h3bgREdjMLaPe8Ztl5BKB0bxv1fOn29kFhGxE6f8Kj54ujUB3m9sQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4lpR-0004Ft-NB for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 14:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Oct 2024 18:48:01 +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.172996847016334 (code B ref 73688); Sat, 26 Oct 2024 18:48:01 +0000 Original-Received: (at 73688) by debbugs.gnu.org; 26 Oct 2024 18:47:50 +0000 Original-Received: from localhost ([127.0.0.1]:42593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4lpG-0004FN-7h for submit@debbugs.gnu.org; Sat, 26 Oct 2024 14:47:50 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4lpD-0004F5-R2 for 73688@debbugs.gnu.org; Sat, 26 Oct 2024 14:47:48 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 451034416A5; Sat, 26 Oct 2024 14:47:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1729968425; bh=sWm9dCo4+TfTvM7n2qEDKxebjztKcC6gjXH6W62KlQk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=EfkRQ+NS4N3mA1GgaeBlcIORJIIBqWZTwaZYzJnhY6DOTk1Y7eegZobHJyMX0jlYu x2wc3dmG7bSdeL7nKd3tNa3QbpZIpB19oQXaauj+tfxa+AA8gwyCO+MJi1haLv4Rhe Iia5VCN6hXsV2ZSnnKWP/Yy0fGPX7z9N6E3mVc+qz4WaXDK39nmm1UDzUQN8Oa0VsW WWkQyf4xitZTvG9p3Cn/SEBvUfbS+rlN8Gwa3Bf9A8e42CcikhpFuSGNQm2AYBEIGd 3VHafLdyfwTBZQLkVdmT5Beu1ssxJUdE0iCK1V9AdQRjd13dJ5Kllr/AeDJR1YRaTx 37dqCq7qrgtSQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 23D57440CB5; Sat, 26 Oct 2024 14:47:05 -0400 (EDT) Original-Received: from pastel (69-196-161-60.dsl.teksavvy.com [69.196.161.60]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EE63C12041C; Sat, 26 Oct 2024 14:47:04 -0400 (EDT) In-Reply-To: (Marc Soda's message of "Sat, 26 Oct 2024 17:48:33 +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:294292 Archived-At: >> 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