emacs-diffs
[Top][All Lists]
Advanced

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

master e140937 3/4: Add a convenience function to be used when working o


From: Lars Ingebrigtsen
Subject: master e140937 3/4: Add a convenience function to be used when working on font locking
Date: Wed, 30 Oct 2019 08:16:51 -0400 (EDT)

branch: master
commit e1409379f7ce60eb845a0b9c3a614af4f5fac694
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 doc/lispref/modes.texi | 6 ++++++
 etc/NEWS               | 6 ++++++
 lisp/font-lock.el      | 9 +++++++++
 3 files changed, 21 insertions(+)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 2e0c9e4..fda5a10 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
 @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
diff --git a/etc/NEWS b/etc/NEWS
index daf9e0e..3df5015 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 9ae0827..971e373 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -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



reply via email to

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