bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#42654: Using electric-pair-inihibit-predicate won't work for all mem


From: Lars Ingebrigtsen
Subject: bug#42654: Using electric-pair-inihibit-predicate won't work for all members of electric-pair-pairs
Date: Tue, 07 Jun 2022 11:53:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

ej32u@protonmail.com writes:

> I tried setting ~electric-pair-inhibit-predicate~, but found that it
> isn't used unless the inserted character has the right syntax. That
> function is run by  ~electric-pair-post-self-insert-function~, which
> seems to only run the predicate function if the inserted character is
> ~(memq syntax '(?\( ?\" ?\$))~.

Ah, right.  Here's the complete recipe to reproduce the problem:

(progn
  (require 'elec-pair)

  (setq-local electric-pair-pairs (cons '(?* . ?*) electric-pair-pairs))
  (electric-pair-mode 1)

  (defun my-inhibit-for-org-heading (inserted-char)
    (or (and (eq inserted-char ?*)
             ;; If point was the beginning of the line, don't pair.
             (eq (1- (point)) (line-beginning-position)))
        (funcall (default-toplevel-value
                  'electric-pair-inhibit-predicate)
                 inserted-char)))

  (setq-local electric-pair-inhibit-predicate #'my-inhibit-for-org-heading))

`my-inhibit-for-org-heading' is never run when typing * in this
scenario, because it doesn't have parentheses/quote syntax, so
`electric-pair-syntax-info' returns UNCONDITIONAL true.

I'm not sure what the logic is behind this -- perhaps João has some
comments; added to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]