all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's
@ 2024-06-05 22:06 JD Smith
  2024-06-06  5:34 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: JD Smith @ 2024-06-05 22:06 UTC (permalink / raw)
  To: 71384

The function treesit-font-lock-fontify-region in treesit.el calls (font-lock-unfontify-region start end) right away (see below).  But this function is called as the value of font-lock-fontify-syntactically-function from font-lock-default-fontify-region, which has just itself made the exact same call to font-lock-unfontify-region. I commented out that superfluous call in treesit-font-lock-fontify-region and noticed no ill effects.

(defun treesit-font-lock-fontify-region (start end &optional loudly)
  "Fontify the region between START and END.
If LOUDLY is non-nil, display some debugging information."
  (when (or loudly treesit--font-lock-verbose)
    (message "Fontifying region: %s-%s" start end))
  (treesit-update-ranges start end)
  (font-lock-unfontify-region start end)




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's
  2024-06-05 22:06 bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's JD Smith
@ 2024-06-06  5:34 ` Eli Zaretskii
  2024-06-06 11:35   ` JD Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-06-06  5:34 UTC (permalink / raw)
  To: JD Smith, Yuan Fu; +Cc: 71384

> From: JD Smith <jdtsmith@gmail.com>
> Date: Wed, 5 Jun 2024 18:06:54 -0400
> 
> The function treesit-font-lock-fontify-region in treesit.el calls (font-lock-unfontify-region start end) right away (see below).  But this function is called as the value of font-lock-fontify-syntactically-function from font-lock-default-fontify-region, which has just itself made the exact same call to font-lock-unfontify-region. I commented out that superfluous call in treesit-font-lock-fontify-region and noticed no ill effects.

Why is that duplicate call a problem?  We don't say that
treesit-font-lock-fontify-region _must_ be called _only_ from
font-lock-default-fontify-region, do we?

Adding Yuan in case he has comments.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's
  2024-06-06  5:34 ` Eli Zaretskii
@ 2024-06-06 11:35   ` JD Smith
  0 siblings, 0 replies; 3+ messages in thread
From: JD Smith @ 2024-06-06 11:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yuan Fu, 71384



> On Jun 6, 2024, at 1:34 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: JD Smith <jdtsmith@gmail.com>
>> Date: Wed, 5 Jun 2024 18:06:54 -0400
>> 
>> The function treesit-font-lock-fontify-region in treesit.el calls (font-lock-unfontify-region start end) right away (see below).  But this function is called as the value of font-lock-fontify-syntactically-function from font-lock-default-fontify-region, which has just itself made the exact same call to font-lock-unfontify-region. I commented out that superfluous call in treesit-font-lock-fontify-region and noticed no ill effects.
> 
> Why is that duplicate call a problem?  

I don't know if it's ever really a problem, other than the small amount of time spent removing properties that have just been removed.

> We don't say that treesit-font-lock-fontify-region _must_ be called _only_ from
> font-lock-default-fontify-region, do we?


I presume the same logic would apply to font-lock-fontify-keywords-region, but that does not re-run unfontify (and is obviously much older code).   Maybe treesit reuses treesit-font-lock-fontify-region in non-font-lock contexts?  Feel free to close if Yuan concurs.






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-06 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 22:06 bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's JD Smith
2024-06-06  5:34 ` Eli Zaretskii
2024-06-06 11:35   ` JD Smith

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.