[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Remove obsolete fast-lock and lazy-lock libraries

From: Jeff Norden
Subject: Re: [PATCH] Remove obsolete fast-lock and lazy-lock libraries
Date: Mon, 10 Aug 2020 11:59:09 -0500

>> Anything that makes it clear how to disable Jit Lock while still
>> using Font Lock seem like an improvement to me.
> Suggestions for how to improve the discoverability of this are
> welcome.

I like Stefan's font-lock-debug suggestion even more as I think about it.
It definitely would have helped me when I was starting out to write
fontification code.  The current situation makes debugging font-lock rather
confusing for someone new.  In addition to the un-helpful name, f-l-s-m only
works if set before font-lock is initialized.  On the other hand,
jit-lock-debug-mode can be invoked at any time.

Historically, I think there was a need to set f-l-s-m to the value that worked
best for the mode one was using.  Now, all it does is enable/disable Jit.  It
seems like the only reason to disable Jit is if fontification isn't working
properly, i.e., for debugging.  This doesn't seem like the sort of thing that
would usually be done via the "Easy Customization" menus.  Furthermore,
"M-x set-variable" doesn't work as expected for f-l-s-m, since it doesn't have
any effect for a buffer that is already running font-lock (this puzzled me at

It also seems to me that the abstraction of a 'minor mode' for font debugging
options doesn't help much, and perhaps just adds to the confusion.  The same
goes for the idea that jit-lock is a mode, rather than just another feature of
font-lock (it isn't defined as a minor mode, in fact).

So, here is an idea for consideration:

A new buffer-local variable:  font-lock-debug
The possible values for now (more could be added later) would be:

nil:         normal fontification using Jit
jit-defer:   equivalent to currently setting jit-lock-debug-mode
jit-disable: equivalent to currently having f-l-s-m nil when font-lock starts

This variable could be set via font-lock-defaults like most other font-related

Also add a new command, font-lock-set-debug, for changing font-lock-debug
on the fly. This command would make the required adjustments to the change
functions, jit registration, jit-lock-defer-timer, etc.  This could also be
used for initialization at font-lock startup, and then maybe the remaining
confusing thing-lock things could be obsoleted.

For backward compatibility:

a) When font-lock-mode starts:
if font-lock-support-mode is bound, and
   font-lock-debug is not set in font-lock-defaults, and
   (font-lock-value-in-major-mode f-l-s-m) returns nil,
then set font-lock-debug to 'jit-disable.

b) jit-lock-debug-mode would be a command that uses font-lock-set-debug to
toggle font-lock-debug between nil and jit-defer (or set it to one of those
when given an argument).  If font-lock-debug is jit-disable, this command
would give a "Jit Lock is disabled" message.

Here are some ideas for possible future values of font-lock-debug:

keyword-trace: write a line into a *Font Lock Debug* buffer each time a
  keyword matches, including the appropriate match-data values.

jit-trace: write a line into a *Font Lock Debug* buffer each time
  Jit Lock decides to fontify, with the begin and end positions of the chunk.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]