GNU bug report logs -
#49629
27.2; electric-pair-mode doesn't work for angle brackets in HTML file
Previous Next
Reported by: Allen Li <darkfeline <at> felesatra.moe>
Date: Sun, 18 Jul 2021 23:53:01 UTC
Severity: normal
Found in version 27.2
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 49629 <at> debbugs.gnu.org (full text, mbox):
> To reproduce:
>
> 1. emacs -Q
> 2. C-x C-f /tmp/tmp.html RET
> 3. M-x electric-pair-local-mode RET
> 4. < >
>
> Expected:
>
> Buffer contains <>
>
> Actual:
>
> Buffer contains <>>
>
> By default, typing > should skip over the > inserted by
> electric-pair-mode when the first < is type (but it doesn't).
>
> I tried stepping through with Edebug, but the bug disappears when using
> Edebug. The difference seems to be in what is returned by
> electric-pair--balance-info, but that function is big and unfamiliar to
> me.
What I've found so far is that using Edebug to step through
electric-pair-skip-if-helps-balance, if I manually step past
(delete-char -1) and then press g (edebug-go-mode) then the bug
disappears. Pressing g before stepping past (delete-char -1) causes
the bug.
For reference, here is the function:
(defun electric-pair-skip-if-helps-balance (char)
"Return non-nil if skipping CHAR would benefit parentheses' balance.
Works by first removing the character from the buffer, then doing
some list calculations, finally restoring the situation as if nothing
happened."
(pcase (electric-pair-syntax-info char)
(`(,syntax ,pair ,_ ,s-or-c)
(unwind-protect
(progn
(delete-char -1)
(cond ((eq syntax ?\))
(let* ((pair-data
(electric-pair--balance-info
-1 s-or-c))
(innermost (car pair-data))
(outermost (cdr pair-data)))
(and
(cond ((car outermost)
(car innermost))
((car innermost)
(not (eq (cdr outermost) pair)))))))
((eq syntax ?\")
(electric-pair--inside-string-p char))))
(insert char)))))
This bug report was last modified 3 years and 17 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.