aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-10-30 13:08:55 +0100
committerLars Ingebrigtsen2019-10-30 13:16:44 +0100
commite1409379f7ce60eb845a0b9c3a614af4f5fac694 (patch)
tree95136e61c64a5c8222bbb81e7cc7f1b3bcc6ab07
parent305dbc7e2be05748039aacb1a3d697f6f64bed4c (diff)
downloademacs-e1409379f7ce60eb845a0b9c3a614af4f5fac694.tar.gz
emacs-e1409379f7ce60eb845a0b9c3a614af4f5fac694.zip
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.
-rw-r--r--doc/lispref/modes.texi6
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/font-lock.el9
3 files changed, 21 insertions, 0 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 2e0c9e4655e..fda5a106bbe 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -2737,6 +2737,12 @@ This function should make sure the region between @var{beg} and
2737@var{end} default to the beginning and the end of the buffer's 2737@var{end} default to the beginning and the end of the buffer's
2738accessible portion. Calls the function specified by 2738accessible portion. Calls the function specified by
2739@code{font-lock-ensure-function}. 2739@code{font-lock-ensure-function}.
2740
2741@item font-lock-refontify
2742This is a convenience command meant to be used when developing font
2743locking for a mode, and should not be called from Lisp code. It
2744recomputes all the relevant variables and then calls
2745@code{font-lock-ensure} on the entire buffer.
2740@end ftable 2746@end ftable
2741 2747
2742 There are several variables that control how Font Lock mode highlights 2748 There are several variables that control how Font Lock mode highlights
diff --git a/etc/NEWS b/etc/NEWS
index daf9e0e1f0c..3df50154e3e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -575,6 +575,12 @@ current and the previous or the next line, as before.
575 575
576* Changes in Specialized Modes and Packages in Emacs 27.1 576* Changes in Specialized Modes and Packages in Emacs 27.1
577 577
578+++
579** New command 'font-lock-refontify'.
580This is an interactive convenience function to be used when developing
581font locking for a mode. It recomputes the font locking data and then
582re-fontifies the buffer.
583
578--- 584---
579** The 'C' command in 'tar-mode' will now preserve the timestamp of 585** The 'C' command in 'tar-mode' will now preserve the timestamp of
580the extracted file if the new user option 'tar-copy-preserve-time' is 586the extracted file if the new user option 'tar-copy-preserve-time' is
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 9ae082736cc..971e37309e9 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1100,6 +1100,15 @@ accessible portion of the current buffer."
1100 "Function to make sure a region has been fontified. 1100 "Function to make sure a region has been fontified.
1101Called with two arguments BEG and END.") 1101Called with two arguments BEG and END.")
1102 1102
1103(defun font-lock-refontify ()
1104 "Reinitialise the font-lock machinery and re-fontify the buffer.
1105This functions is a convenience functions when developing font
1106locking for a mode, and is not meant to be called from lisp functions."
1107 (interactive)
1108 (declare (interactive-only t))
1109 (setq font-lock-major-mode nil)
1110 (font-lock-ensure))
1111
1103(defun font-lock-ensure (&optional beg end) 1112(defun font-lock-ensure (&optional beg end)
1104 "Make sure the region BEG...END has been fontified. 1113 "Make sure the region BEG...END has been fontified.
1105If the region is not specified, it defaults to the entire accessible 1114If the region is not specified, it defaults to the entire accessible