Subject: bug#68849: 30.0.50; font-lock does not flush fontification after calling open-line

From: Stefan Monnier <[email-masked]>
Date: Sat, 03 Feb 2024 13:46:58 -0500

> I am not 100% sure if is Emacs bug, but my preliminary testing showed
> anomalies in `jit-lock-after-change' -
> (put-text-property jit-lock-start jit-lock-end 'fontified nil) somehow
> did not apply the text properties. I suspect that I missed something
> though.

AFAICT the `put-text-property` works fine :-)
The problem is that your `org-fontify-extend-region` does not spread the
change to the "next line".

When `font-lock-extend-after-change-region-function` is nil, Emacs does
that for you.  Quoting `font-lock-extend-jit-lock-region-after-change`:

      (when (< end (point-max))
        (setq end
              (cond
               ((get-text-property end 'font-lock-multiline)
                (or (text-property-any end (point-max)
                                       'font-lock-multiline nil)
                    (point-max)))
               ;; If `end' has been set by the function above, don't corrupt it.
               (font-lock-extend-after-change-region-function end)
                ;; Rounding up to a whole number of lines should include the
                ;; line right after `end'.  Typical case: the first char of
                ;; the line was deleted.  Or a \n was inserted in the middle
                ;; of a line.
               (t (1+ end)))))

I still hope you can change Org mode so it uses
`font-lock-extend-region-functions` instead of
`font-lock-extend-after-change-region-function`.

        Stefan