1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Add a convenience function to be used when working on font locking

* doc/lispref/modes.texi (Font Lock Basics): Document it.

* lisp/font-lock.el (font-lock-refontify): New convenience command.
This commit is contained in:
Lars Ingebrigtsen 2019-10-30 13:08:55 +01:00
parent 305dbc7e2b
commit e1409379f7
3 changed files with 21 additions and 0 deletions

View file

@ -2737,6 +2737,12 @@ This function should make sure the region between @var{beg} and
@var{end} default to the beginning and the end of the buffer's
accessible portion. Calls the function specified by
@code{font-lock-ensure-function}.
@item font-lock-refontify
This is a convenience command meant to be used when developing font
locking for a mode, and should not be called from Lisp code. It
recomputes all the relevant variables and then calls
@code{font-lock-ensure} on the entire buffer.
@end ftable
There are several variables that control how Font Lock mode highlights

View file

@ -575,6 +575,12 @@ current and the previous or the next line, as before.
* Changes in Specialized Modes and Packages in Emacs 27.1
+++
** New command 'font-lock-refontify'.
This is an interactive convenience function to be used when developing
font locking for a mode. It recomputes the font locking data and then
re-fontifies the buffer.
---
** The 'C' command in 'tar-mode' will now preserve the timestamp of
the extracted file if the new user option 'tar-copy-preserve-time' is

View file

@ -1100,6 +1100,15 @@ accessible portion of the current buffer."
"Function to make sure a region has been fontified.
Called with two arguments BEG and END.")
(defun font-lock-refontify ()
"Reinitialise the font-lock machinery and re-fontify the buffer.
This functions is a convenience functions when developing font
locking for a mode, and is not meant to be called from lisp functions."
(interactive)
(declare (interactive-only t))
(setq font-lock-major-mode nil)
(font-lock-ensure))
(defun font-lock-ensure (&optional beg end)
"Make sure the region BEG...END has been fontified.
If the region is not specified, it defaults to the entire accessible