Subject: bug#38372: Error in mhtml-syntax-propertize in HTML with inline script

From: Dmitry Gutov <[email-masked]>
Date: Tue, 26 Nov 2019 00:28:47 +0200

On 25.11.2019 18:57, Richard Copley wrote:
> HTML with inline script can cause an error in mhtml-syntax-propertize.
> 
> Recipe from emacs -Q: Visit a new file "index.html" and insert these 
> contents:
> 
> <html>
>    <head>
>      <script> 0 </script>
>    </head>
>    <body>
>      it's
>    </body>
> </html>
> 
> Put the cursor after the zero and type a semicolon. An error is signalled.
> 
> (Note the "unmatched" apostrophe in the HTML body.)
> 
> Errors:
> Error during redisplay: (jit-lock-function 1) signaled 
> (wrong-type-argument number-or-marker-p nil)
> mhtml-syntax-propertize: Wrong type argument: number-or-marker-p, nil
> 
> Backtrace:
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>    sgml--syntax-propertize-ppss(86)
>    mhtml-syntax-propertize(33 107)
>    syntax-propertize(50)
>    syntax-ppss()
>    electric-indent-post-self-insert-function()
>    self-insert-command(1 59)
>    funcall-interactively(self-insert-command 1 59)
>    call-interactively(self-insert-command nil nil)
>    command-execute(self-insert-command)

Seems it's only triggered when electric-indent-mode is on.

And the error is in sgml--syntax-propertize-ppss, a function that was 
added after mhtml-mode was written.

A quick attempt at fixing it (adding "sgml--syntax-" to 
mhtml--crucial-variable-prefix) didn't help, so I'm just going to Cc the 
people who might have better idea.