aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-12-19 16:14:11 +0200
committerEli Zaretskii2015-12-19 16:14:11 +0200
commit277d7efd24082f989c72a1a91df6ded8546bfbfb (patch)
tree9ebf8a45d3bac985b888a6ff67b1089d1e9586a7
parentd30c30b04052aad10f817a3792e8c3719ee06423 (diff)
downloademacs-277d7efd24082f989c72a1a91df6ded8546bfbfb.tar.gz
emacs-277d7efd24082f989c72a1a91df6ded8546bfbfb.zip
Document new features of Font Lock
* doc/lispref/modes.texi (Other Font Lock Variables): Document 'font-lock-flush-function' and 'font-lock-ensure-function'. (Font Lock Basics): Document the basic fontification functions referenced in "Other Font Lock Variables". * lisp/font-lock.el (font-lock-flush, font-lock-ensure): Doc fix.
-rw-r--r--doc/lispref/modes.texi63
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/font-lock.el6
3 files changed, 71 insertions, 4 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index a1747707d11..3b8550e13b9 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -2509,6 +2509,53 @@ Search-based fontification happens second.
2509@node Font Lock Basics 2509@node Font Lock Basics
2510@subsection Font Lock Basics 2510@subsection Font Lock Basics
2511 2511
2512 The Font Lock functionality is based on several basic functions.
2513Each of these calls the function specified by the corresponding
2514variable. This indirection allows major modes to modify the way
2515fontification works in the buffers of that mode, and even use the Font
2516Lock mechanisms for features that have nothing to do with
2517fontification. (This is why the description below says ``should''
2518when it describes what the functions do: the major mode can customize
2519the values of the corresponding variables to do something entirely
2520different.) The variables mentioned below are described in @ref{Other
2521Font Lock Variables}.
2522
2523@ftable @code
2524@item font-lock-fontify-buffer
2525This function should fontify the current buffer's accessible portion,
2526by calling the function specified by
2527@code{font-lock-fontify-buffer-function}.
2528
2529@item font-lock-unfontify-buffer
2530Used when turning Font Lock off to remove the fontification. Calls
2531the function specified by @code{font-lock-unfontify-buffer-function}.
2532
2533@item font-lock-fontify-region beg end &optional loudly
2534Should fontify the region between @var{beg} and @var{end}. If
2535@var{loudly} is non-@code{nil}, should display status messages while
2536fontifying. Calls the function specified by
2537@code{font-lock-fontify-region-function}.
2538
2539@item font-lock-unfontify-region beg end
2540Should remove fontification from the region between @var{beg} and
2541@var{end}. Calls the function specified by
2542@code{font-lock-unfontify-region-function}.
2543
2544@item font-lock-flush &optional beg end
2545This function should mark the fontification of the region between
2546@var{beg} and @var{end} as outdated. If not specified or @code{nil},
2547@var{beg} and @var{end} default to the beginning and end of the
2548buffer's accessible portion. Calls the function specified by
2549@code{font-lock-flush-function}.
2550
2551@item font-lock-ensure &optional beg end
2552This function should make sure the region between @var{beg} and
2553@var{end} has been fontified. The optional arguments @var{beg} and
2554@var{end} default to the beginning and the end of the buffer's
2555accessible portion. Calls the function specified by
2556@code{font-lock-ensure-function}.
2557@end ftable
2558
2512 There are several variables that control how Font Lock mode highlights 2559 There are several variables that control how Font Lock mode highlights
2513text. But major modes should not set any of these variables directly. 2560text. But major modes should not set any of these variables directly.
2514Instead, they should set @code{font-lock-defaults} as a buffer-local 2561Instead, they should set @code{font-lock-defaults} as a buffer-local
@@ -2936,6 +2983,22 @@ arguments, the beginning and end of the region. The default value is
2936@code{font-lock-default-unfontify-region}. 2983@code{font-lock-default-unfontify-region}.
2937@end defvar 2984@end defvar
2938 2985
2986@defvar font-lock-flush-function
2987Function to use for declaring that a region's fontification is out of
2988date. It takes two arguments, the beginning and end of the region.
2989The default value of this variable is
2990@code{font-lock-after-change-function}.
2991@end defvar
2992
2993@defvar font-lock-ensure-function
2994Function to use for making sure a region of the current buffer has
2995been fontified. It is called with two arguments, the beginning and
2996end of the region. The default value of this variable is a function
2997that calls @code{font-lock-default-fontify-buffer} if the buffer is
2998not fontified; the effect is to make sure the entire accessible
2999portion of the buffer is fontified.
3000@end defvar
3001
2939@defun jit-lock-register function &optional contextual 3002@defun jit-lock-register function &optional contextual
2940This function tells Font Lock mode to run the Lisp function 3003This function tells Font Lock mode to run the Lisp function
2941@var{function} any time it has to fontify or refontify part of the 3004@var{function} any time it has to fontify or refontify part of the
diff --git a/etc/NEWS b/etc/NEWS
index 3a219851ff6..5f19c409722 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -642,8 +642,10 @@ respectively, `show-paren-when-point-inside-paren' or
642*** C-x C-x in rectangle-mark-mode now cycles through the four corners. 642*** C-x C-x in rectangle-mark-mode now cycles through the four corners.
643*** `string-rectangle' provides on-the-fly preview of the result. 643*** `string-rectangle' provides on-the-fly preview of the result.
644 644
645** New font-lock functions font-lock-ensure and font-lock-flush, which 645+++
646should be used instead of font-lock-fontify-buffer when called from Elisp. 646** New font-lock functions `font-lock-ensure' and `font-lock-flush'.
647These should be used in preference to `font-lock-fontify-buffer' when
648called from Lisp.
647 649
648** Macro `minibuffer-with-setup-hook' takes (:append FUN) to mean 650** Macro `minibuffer-with-setup-hook' takes (:append FUN) to mean
649appending FUN to `minibuffer-setup-hook'. 651appending FUN to `minibuffer-setup-hook'.
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 762720d5ba5..93d677c67e7 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1065,7 +1065,8 @@ Called with two arguments BEG and END.")
1065 1065
1066(defun font-lock-flush (&optional beg end) 1066(defun font-lock-flush (&optional beg end)
1067 "Declare the region BEG...END's fontification as out-of-date. 1067 "Declare the region BEG...END's fontification as out-of-date.
1068If the region is not specified, it defaults to the whole buffer." 1068If the region is not specified, it defaults to the entire
1069accessible portion of the current buffer."
1069 (and font-lock-mode 1070 (and font-lock-mode
1070 font-lock-fontified 1071 font-lock-fontified
1071 (funcall font-lock-flush-function 1072 (funcall font-lock-flush-function
@@ -1079,7 +1080,8 @@ Called with two arguments BEG and END.")
1079 1080
1080(defun font-lock-ensure (&optional beg end) 1081(defun font-lock-ensure (&optional beg end)
1081 "Make sure the region BEG...END has been fontified. 1082 "Make sure the region BEG...END has been fontified.
1082If the region is not specified, it defaults to the whole buffer." 1083If the region is not specified, it defaults to the entire accessible
1084portion of the buffer."
1083 (font-lock-set-defaults) 1085 (font-lock-set-defaults)
1084 (funcall font-lock-ensure-function 1086 (funcall font-lock-ensure-function
1085 (or beg (point-min)) (or end (point-max)))) 1087 (or beg (point-min)) (or end (point-max))))