From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#54195: master 15a76160bb: Don't throw errors while propertizing in sgml-mode Date: Mon, 28 Feb 2022 09:44:01 -0500 Message-ID: References: <164604066920.6274.17125818957525062942@vcs2.savannah.gnu.org> <20220228093109.81A17C0DA33@vcs2.savannah.gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35209"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54195@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 28 15:45:36 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nOhHL-0008x6-I8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Feb 2022 15:45:35 +0100 Original-Received: from localhost ([::1]:54426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOhHK-0007J3-24 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Feb 2022 09:45:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOhGo-0007Hv-RQ for bug-gnu-emacs@gnu.org; Mon, 28 Feb 2022 09:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOhGo-0001dP-Hr for bug-gnu-emacs@gnu.org; Mon, 28 Feb 2022 09:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nOhGo-0001NP-6H for bug-gnu-emacs@gnu.org; Mon, 28 Feb 2022 09:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Feb 2022 14:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54195 X-GNU-PR-Package: emacs Original-Received: via spool by 54195-submit@debbugs.gnu.org id=B54195.16460594525219 (code B ref 54195); Mon, 28 Feb 2022 14:45:02 +0000 Original-Received: (at 54195) by debbugs.gnu.org; 28 Feb 2022 14:44:12 +0000 Original-Received: from localhost ([127.0.0.1]:60633 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOhFz-0001M7-U3 for submit@debbugs.gnu.org; Mon, 28 Feb 2022 09:44:12 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOhFy-0001Lt-GN for 54195@debbugs.gnu.org; Mon, 28 Feb 2022 09:44:11 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 62BFA804E6; Mon, 28 Feb 2022 09:44:04 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D6DB680543; Mon, 28 Feb 2022 09:44:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1646059442; bh=ZNbvxxlSL3Y2X+n+8U5BZXFKS2sa4vMEL36QRtdSRGg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=esviXTHtLhmY9rAjMf8MGs14kPX2r9J6uz1jSQbdO2cqFav1kkdOiwz5q3Y5DcZHS 2tYOjDXd8kNj4JOghj64mVawxdyIcarwOjktcrtm8zJx0W/ytPLAJfww7ZIZGG5csr qHL+SmckRlmT3AY1sfvtJv/aRBiOoTbetijHN/YJOeD5AIz781dZXcYU6Vm2XgwUMo bwqEVBvvk0PidTwQdztjMdFuKanFp4Z9JYFn3s0o9TqL9tKXrzpaAUt9kOEtT5V1L/ y0mE+ygnzQnP7yYZMDvhzO63QeQqEoRMtAEsRnk/rc+R2cF5NV9SU9iiY7x2y/3qYI JeFJkWbJ55SAw== Original-Received: from pastel (unknown [45.72.208.76]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B09A41204BE; Mon, 28 Feb 2022 09:44:02 -0500 (EST) In-Reply-To: <20220228093109.81A17C0DA33@vcs2.savannah.gnu.org> (Lars Ingebrigtsen's message of "Mon, 28 Feb 2022 04:31:09 -0500 (EST)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:227823 Archived-At: > * lisp/textmodes/sgml-mode.el (sgml-syntax-propertize): Don't > throw an error when propertizing (bug#54195). > --- > lisp/textmodes/sgml-mode.el | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el > index 83631e6475..b49541f47d 100644 > --- a/lisp/textmodes/sgml-mode.el > +++ b/lisp/textmodes/sgml-mode.el > @@ -419,11 +419,11 @@ These have to be run via `sgml-syntax-propertize'")) > (defun sgml-syntax-propertize (start end &optional rules-function) > "Syntactic keywords for `sgml-mode'." > (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start))) > - (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0)) > - (sgml-syntax-propertize-inside end) > - (funcall (or rules-function sgml--syntax-propertize) (point) end) > - ;; Catch any '>' after the last quote. > - (sgml--syntax-propertize-ppss end)) > + (when (>= (cadr sgml--syntax-propertize-ppss) 0) > + (sgml-syntax-propertize-inside end) > + (funcall (or rules-function sgml--syntax-propertize) (point) end) > + ;; Catch any '>' after the last quote. > + (sgml--syntax-propertize-ppss end))) Hmm... this isn't right. The PPSS really shouldn't have a negative value here. The problem is that when we do as in the recipe (which does not require `electric-pair-mode` to reproduce), mhtml calls `sgml-syntax-propertize` on the `` tag and the `syntax-ppss` call returns the state of the JS parsing at the end of the JS code rather than the state of the SGML parsing at the beginning of the tag. IOW it's a bug in the interaction between `mhtml` and `syntax-ppss`. To illustrate the problem in a way which doesn't signal an error, try the following: "foo "bar as you can see, the SGML part carefully ignores the " thingies outside of quotes. Now remove the closing paren in the JS code: suddenly the SGML code is all confused because it thinks everything after the open paren is inside of a tag (because the SGML mode gives paren syntax to < and > (but not to parens) and uses the paren depth to decide whether we're inside a tag or not). Stefan