From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Marc Soda Newsgroups: gmane.emacs.bugs Subject: bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode Date: Sat, 26 Oct 2024 17:48:33 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6979"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73688@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 26 19:49:49 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 1t4kv7-0001gL-D6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Oct 2024 19:49:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4kuu-0007kq-IN; Sat, 26 Oct 2024 13:49:37 -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 1t4kum-0007g1-EQ for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 13:49:28 -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 1t4kum-0003Ax-5D for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 13:49: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:References:In-Reply-To:From:Date:To:Subject; bh=MPbQSfg8RCETGWOxkgz9lMMi3YnDtEJkSys487ag/Ho=; b=gafZTGxo+wqLLZlHx01UvYf1TfSC10dAdqOldQzdZWGM2rumbCa7jTinweFdcus4Qz6xXzJScYleCpVO6ohHYUe2QuyLhifmPrugf0yu9KJhHAt/1HL30u+dL8/2uv4Nh5VnnRKXnR4P/vwWOPI5wMQWUlrpnsABLibRXUgLD/fVR51zTNklqjKxWhsy0fjI12P9laSAMMSdoWu0r13Kn/10Lc63xDQV++kIWwvyqHBlmnvkeo0Raml+MmQTx4DoV3k29ZF9H8pdJ+p1JCHCxbSqQ0BFTIQhTgStA9an9G3hqsQG6/aEn7QXyesZuiGqQoLFls73c7aAP1DkTZFqmg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t4kvJ-0001TT-O8 for bug-gnu-emacs@gnu.org; Sat, 26 Oct 2024 13:50:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marc Soda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Oct 2024 17:50: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.17299649585596 (code B ref 73688); Sat, 26 Oct 2024 17:50:01 +0000 Original-Received: (at 73688) by debbugs.gnu.org; 26 Oct 2024 17:49:18 +0000 Original-Received: from localhost ([127.0.0.1]:42517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4kuc-0001SC-9H for submit@debbugs.gnu.org; Sat, 26 Oct 2024 13:49:18 -0400 Original-Received: from mail-4022.proton.ch ([185.70.40.22]:24463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t4kua-0001Rw-3E for 73688@debbugs.gnu.org; Sat, 26 Oct 2024 13:49:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soda.fm; s=protonmail; t=1729964915; x=1730224115; bh=MPbQSfg8RCETGWOxkgz9lMMi3YnDtEJkSys487ag/Ho=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=gDFqSEEbF0bxuUXjdUeBlUlvnzx7GDFPiTogtPLenSxty+KYpamS7teHtPkX2JV1a vYA7t0hLA9mF5NyqGVMg/QTK7fFwjsFVShIumbZLqjLi09yPOuvljpj0eJDJtfBBTH iRiI3f7/MqMFkTz6hA+hY4JtL84wGYYmmTXv6hNA= In-Reply-To: Feedback-ID: 9188694:user:proton X-Pm-Message-ID: 841d80e79ba01542edf67e46db391e7fbd6795b6 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:294290 Archived-At: > That's a feature. > > 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 list= ed in `electric-pair-conservative-inhibit`. In particular, the line comment= ed "I also find it often preferable not to pair next to a word." is very va= luable to me. However, I can solve my issue pretty easily by add 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)))) 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 abo= ve, it seemed non-intuitive. Thanks for considering, but feel free to disre= gard. Are there any improvements you want made here? Only asking because I curren= tly have the context. Thanks, Marc On Thursday, October 17th, 2024 at 12:48 PM, Stefan Monnier wrote: >=20 >=20 > > When using electric-pair-mode, electric-pair-conservative-inhibit >=20 > > doesn't respect electric-pair-preserve-balance. >=20 >=20 > That's a feature. > At least that was for me the main reason to have > `electric-pair-conservative-inhibit`, i.e. so the behavior does not > depend on the global paren balance of the whole buffer (both because it > can be costly to compute and because it can be difficult to predict for > the user). >=20 > IOW, why do you use `electric-pair-conservative-inhibit` if you care > about preserving global balance? >=20 >=20 > Stefan