From: Marc Soda <marc@soda.fm>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 73688@debbugs.gnu.org
Subject: bug#73688: [PATCH] electric-pair-mode - preserve balance in conservative mode
Date: Sat, 26 Oct 2024 17:48:33 +0000 [thread overview]
Message-ID: <funmhnoKdk7mBk-FC8okHkJWgn7iqnXer7vL2ItxFNSiNl0EDSLHDR6wu9kvKi9qurJ853fAGILXsVl8SYW6MTFlJ8RX1Mdsa-8fjkiQd_Q=@soda.fm> (raw)
In-Reply-To: <jwvplnyn0f4.fsf-monnier+emacs@gnu.org>
> 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 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 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 above, it seemed non-intuitive. Thanks for considering, but feel free to disregard.
Are there any improvements you want made here? Only asking because I currently have the context.
Thanks,
Marc
On Thursday, October 17th, 2024 at 12:48 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>
> > When using electric-pair-mode, electric-pair-conservative-inhibit
>
> > doesn't respect electric-pair-preserve-balance.
>
>
> 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).
>
> IOW, why do you use `electric-pair-conservative-inhibit` if you care
> about preserving global balance?
>
>
> Stefan
next prev parent reply other threads:[~2024-10-26 17:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-10-26 18:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='funmhnoKdk7mBk-FC8okHkJWgn7iqnXer7vL2ItxFNSiNl0EDSLHDR6wu9kvKi9qurJ853fAGILXsVl8SYW6MTFlJ8RX1Mdsa-8fjkiQd_Q=@soda.fm' \
--to=marc@soda.fm \
--cc=73688@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).