GNU bug report logs - #53661
29.0.50; electric-pair-mode not respecting electric-pair-inhibit-predicate.

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Mon, 31 Jan 2022 15:08:01 UTC

Severity: normal

Found in version 29.0.50

Full log


View this message in rfc822 format

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53661 <at> debbugs.gnu.org
Subject: bug#53661: 29.0.50; electric-pair-mode not respecting electric-pair-inhibit-predicate.
Date: Mon, 31 Jan 2022 18:29:31 +0100
On Mon, Jan 31, 2022 at 06:41:59PM +0200, Eli Zaretskii wrote:
>> Date: Mon, 31 Jan 2022 16:06:39 +0100
>> From:  Ergus via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> When adding new pairs to `electric-pair-pairs' the
>> `electric-pair-inhibit-predicate' variable is not respected.
>>
>> Looking at the elect-pair file it seems to be related with:
>> `electric-pair-post-self-insert-function' that hard-coded the condition
>> to call `electric-pair-inhibit-predicate' with:
>>
>> (memq syntax '(?\( ?\" ?\$))
>>
>> So, for other pairs, the function electric-pair-inhibit-predicate is
>> never called.
>
>The above condition looks at the _syntax_ of a character, not at the
>character itself.  So what do you find "hard-coded" there,and what
>kind of pairs of characters did you want to add that don't have one of
>those syntaxes?

Hi Eli:

I wanted to add "<>" so I added to my init:

(add-to-list 'electric-pair-pairs '(?< . ?>))

But I wanted to restrict the electric-insertion only to when the region
was active; else using `<` to compare may be wrong; so I thought that
implementing my own `electric-pair-inhibit-predicate' in a simple way
like more or less:

(if (and (eq char ?<) (not (use-region-p)))
    t
    (electric-pair-default-inhibit))

could make the trick, but this doesn't work as I thought. I don't know
if there is a better way to go around this. 




This bug report was last modified 3 years and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.