GNU bug report logs - #68849
30.0.50; font-lock does not flush fontification after calling open-line

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Wed, 31 Jan 2024 12:42:02 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 68849 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to papadakis.k <at> yandex.com, bug-gnu-emacs <at> gnu.org:
bug#68849; Package emacs. (Wed, 31 Jan 2024 12:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> posteo.net>:
New bug report received and forwarded. Copy sent to papadakis.k <at> yandex.com, bug-gnu-emacs <at> gnu.org. (Wed, 31 Jan 2024 12:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; font-lock does not flush fontification after calling
 open-line
Date: Wed, 31 Jan 2024 12:44:09 +0000
This bug was originally reported in
https://orgmode.org/list/c5fb9f63-185c-4e36-b13f-e887a4a29aae <at> yandex.com

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.

May someone please help debugging this and figuring out if the problem
is on Emacs side?

Steps to reproduce:

1. Create bug.el:
(require 'org-faces)
(set-face-underline 'org-block-end-line t)
(setq org-fontify-whole-block-delimiter-line t)

2. Create bug.org:
#+begin_src
#+end_src

asd

3. Move point to the end of #+end_src line:
#+end_src<point>

4. M-x open-lien

5. Observe underline face being applied to the empty line _after_
#+end_src.

In GNU Emacs 30.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version
 3.24.39, cairo version 1.18.0) of 2024-01-30 built on localhost
Repository revision: 9de29fb5b0396cb3929bd5668604fda076ca5ec4
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: Gentoo Linux

Configured using:
 'configure JAVAC=/etc/java-config-2/current-system-vm/bin/javac'

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68849; Package emacs. (Sat, 03 Feb 2024 09:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 68849 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> posteo.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 68849 <at> debbugs.gnu.org, papadakis.k <at> yandex.com
Subject: Re: bug#68849: 30.0.50;
 font-lock does not flush fontification after calling open-line
Date: Sat, 03 Feb 2024 11:55:27 +0200
> Cc: Kostas Papadakis <papadakis.k <at> yandex.com>
> From: Ihor Radchenko <yantar92 <at> posteo.net>
> Date: Wed, 31 Jan 2024 12:44:09 +0000
> 
> This bug was originally reported in
> https://orgmode.org/list/c5fb9f63-185c-4e36-b13f-e887a4a29aae <at> yandex.com
> 
> 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.
> 
> May someone please help debugging this and figuring out if the problem
> is on Emacs side?
> 
> Steps to reproduce:
> 
> 1. Create bug.el:
> (require 'org-faces)
> (set-face-underline 'org-block-end-line t)
> (setq org-fontify-whole-block-delimiter-line t)
> 
> 2. Create bug.org:
> #+begin_src
> #+end_src
> 
> asd
> 
> 3. Move point to the end of #+end_src line:
> #+end_src<point>
> 
> 4. M-x open-lien
> 
> 5. Observe underline face being applied to the empty line _after_
> #+end_src.

Stefan, any suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68849; Package emacs. (Sat, 03 Feb 2024 18:48:01 GMT) Full text and rfc822 format available.

Message #11 received at 68849 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 68849 <at> debbugs.gnu.org, Kostas Papadakis <papadakis.k <at> yandex.com>
Subject: Re: bug#68849: 30.0.50; font-lock does not flush fontification
 after calling open-line
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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68849; Package emacs. (Sun, 04 Feb 2024 13:31:01 GMT) Full text and rfc822 format available.

Message #14 received at 68849 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 68849 <at> debbugs.gnu.org, Kostas Papadakis <papadakis.k <at> yandex.com>
Subject: Re: bug#68849: 30.0.50; font-lock does not flush fontification
 after calling open-line
Date: Sun, 04 Feb 2024 13:33:48 +0000
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> 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`:
> ...

Thanks for the pointer!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1abff3859

> 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`.

I am not taking on any major changes in the existing Org fontification
as it needs to be rewritten completely.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68849; Package emacs. (Sun, 04 Feb 2024 14:25:02 GMT) Full text and rfc822 format available.

Message #17 received at 68849 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 68849 <at> debbugs.gnu.org, Kostas Papadakis <papadakis.k <at> yandex.com>
Subject: Re: bug#68849: 30.0.50; font-lock does not flush fontification
 after calling open-line
Date: Sun, 04 Feb 2024 09:24:26 -0500
>> 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`.
>
> I am not taking on any major changes in the existing Org fontification
> as it needs to be rewritten completely.

So I heard, yes.  You won't crush my hopes so easily.
Oh, and BTW, in order to try and prevent that famous rewrite from making
the same mistake, a FIXME would be appreciated.


        Stefan





This bug report was last modified 90 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.