GNU bug report logs - #36006
electric-pair-mode fails to balance in certain cases

Previous Next

Package: emacs;

Reported by: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>

Date: Thu, 30 May 2019 15:12:01 UTC

Severity: minor

Tags: confirmed

Found in version 27.0.50

Full log


Message #37 received at 36006 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Gregory Heytings <ghe <at> sdf.org>
Cc: 36006 <at> debbugs.gnu.org
Subject: Re: bug#36006: electric-pair-mode fails to balance in certain cases
Date: Thu, 10 Feb 2022 08:50:04 +0100
Gregory Heytings <ghe <at> sdf.org> writes:

> A more specific note: removing `(put-text-property
> ... (string-to-syntax "."))' in `sgml--syntax-propertize-ppss' also
> fixes the bug.  So this bug is indeed specific to html-mode/sgml-mode.

This problem is still present in Emacs 29.

I guess the issue here is that electric-pair-mode works by letting the
user insert the '>' before the final <div>, and then fixes things up (by
removing the extra '>' and moving point), but this defeats that:

(defun sgml--syntax-propertize-ppss (pos)
  "Return PPSS at POS, fixing the syntax of any lone `>' along the way."
  (cl-assert (>= pos (car sgml--syntax-propertize-ppss)))
  (let ((ppss (parse-partial-sexp (car sgml--syntax-propertize-ppss) pos -1
                                  nil (cdr sgml--syntax-propertize-ppss))))
    (while (eq -1 (car ppss))
      (put-text-property (1- (point)) (point)
                         'syntax-table (string-to-syntax "."))
      ;; Hack attack: rather than recompute the ppss from
      ;; (car sgml--syntax-propertize-ppss), we manually "fix it".
      (setcar ppss 0)
      (setq ppss (parse-partial-sexp (point) pos -1 nil ppss)))
    (setcdr sgml--syntax-propertize-ppss ppss)
    (setcar sgml--syntax-propertize-ppss pos)
    ppss))

Because it's marking the extra '>' as punctuation?  

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




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

Previous Next


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