Subject: Re: bug#23272: 25.0.92; syntax-propertize-via-font-lock considered harmful

From: Dmitry Gutov <[email-masked]>
Date: Thu, 21 Nov 2019 01:22:41 +0200

On 30.10.2019 17:56, Lars Ingebrigtsen wrote:
> I'm unable to reproduce this bug on the current trunk.  Has this been
> fixed in the three years since it was reported?

I think it's still there as a possibility, but the odds of triggering it 
are becoming more rare with each year.

Looking at the backtrace, it requires a major mode that uses 
font-lock-syntactic-keywords and calls syntax-propertize-via-font-lock 
to set its syntax-propertize-function.

Since Emacs 26 (where the bug still reproduces), ada-mode has both 
switched to a proper syntax-propertize-function instead of the one 
mentioned above and moved out of Emacs core, so "mode: ada" isn't doing 
anything in 'emacs -Q'.

So the repro scenario is like this now:

(define-derived-mode foo-mode fundamental-mode "Foo"
   (setq-local syntax-propertize-function
	      (syntax-propertize-via-font-lock nil)))

(with-temp-buffer
   (insert "-- -*- mode: foo -*-")
   (delay-mode-hooks
     (set-auto-mode))
   (syntax-propertize (point)))

The resulting backtrace:

Debugger entered--Lisp error: (error "Font-lock trying to use keywords 
before setting th...")
   signal(error ("Font-lock trying to use keywords before setting th..."))
   error("Font-lock trying to use keywords before setting th...")
   font-lock-compile-keywords(nil t)
   font-lock-fontify-syntactic-keywords-region(1 21)
   #f(compiled-function (start end) #<bytecode 0x15817a4f1981>)(1 21)
   syntax-propertize(21)

Considering font-lock-syntactic-keywords are obsolete since Emacs 24, 
this is not very important, and people should feel free to close this if 
a fix is not found soon.