Subject: bug#48447: 27.2.50; Font-lock error in temporary bibtex-mode buffer

From: Stefan Monnier <[email-masked]>
Date: Wed, 13 Jul 2022 08:32:05 -0400

Lars Ingebrigtsen [2022-07-13 13:24:12] wrote:

> "Basil L. Contovounesios" <[email-masked]> writes:
>
>> This puts the following in *Messages*:
>>
>>   Error during redisplay: (internal--syntax-propertize 25) signaled
>>   (error "Font-lock trying to use keywords before setting them up")
>
> I've now fixed this in Emacs 29.
[...]
> @@ -3659,7 +3659,11 @@ if that value is non-nil.
>                                          ?\s)))))
>      (if (and buffer-file-name enable-local-variables)
>          (add-hook 'hack-local-variables-hook fun nil t)
> -      (funcall fun))))
> +      (funcall fun)))
> +  ;; We may be using the mode programmatically to extract data, and we
> +  ;; then need this to be set up first so that sexp-based movement
> +  ;; commands don't bug out.
> +  (font-lock-set-defaults))

Hmm... this looks like a workaround rather than a fix of the core
problem because I can't see any use of "font-lock internals" in
bibtex.el which would justify such a need.

I suspect that the problem is linked to
`syntax-propertize-via-font-lock`, so I think the fix should go there.

        Stefan