diff options
| -rw-r--r-- | doc/lispref/modes.texi | 63 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/font-lock.el | 6 |
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. | ||
| 2513 | Each of these calls the function specified by the corresponding | ||
| 2514 | variable. This indirection allows major modes to modify the way | ||
| 2515 | fontification works in the buffers of that mode, and even use the Font | ||
| 2516 | Lock mechanisms for features that have nothing to do with | ||
| 2517 | fontification. (This is why the description below says ``should'' | ||
| 2518 | when it describes what the functions do: the major mode can customize | ||
| 2519 | the values of the corresponding variables to do something entirely | ||
| 2520 | different.) The variables mentioned below are described in @ref{Other | ||
| 2521 | Font Lock Variables}. | ||
| 2522 | |||
| 2523 | @ftable @code | ||
| 2524 | @item font-lock-fontify-buffer | ||
| 2525 | This function should fontify the current buffer's accessible portion, | ||
| 2526 | by calling the function specified by | ||
| 2527 | @code{font-lock-fontify-buffer-function}. | ||
| 2528 | |||
| 2529 | @item font-lock-unfontify-buffer | ||
| 2530 | Used when turning Font Lock off to remove the fontification. Calls | ||
| 2531 | the function specified by @code{font-lock-unfontify-buffer-function}. | ||
| 2532 | |||
| 2533 | @item font-lock-fontify-region beg end &optional loudly | ||
| 2534 | Should fontify the region between @var{beg} and @var{end}. If | ||
| 2535 | @var{loudly} is non-@code{nil}, should display status messages while | ||
| 2536 | fontifying. Calls the function specified by | ||
| 2537 | @code{font-lock-fontify-region-function}. | ||
| 2538 | |||
| 2539 | @item font-lock-unfontify-region beg end | ||
| 2540 | Should 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 | ||
| 2545 | This 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 | ||
| 2548 | buffer's accessible portion. Calls the function specified by | ||
| 2549 | @code{font-lock-flush-function}. | ||
| 2550 | |||
| 2551 | @item font-lock-ensure &optional beg end | ||
| 2552 | This 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 | ||
| 2555 | accessible 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 |
| 2513 | text. But major modes should not set any of these variables directly. | 2560 | text. But major modes should not set any of these variables directly. |
| 2514 | Instead, they should set @code{font-lock-defaults} as a buffer-local | 2561 | Instead, 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 | ||
| 2987 | Function to use for declaring that a region's fontification is out of | ||
| 2988 | date. It takes two arguments, the beginning and end of the region. | ||
| 2989 | The default value of this variable is | ||
| 2990 | @code{font-lock-after-change-function}. | ||
| 2991 | @end defvar | ||
| 2992 | |||
| 2993 | @defvar font-lock-ensure-function | ||
| 2994 | Function to use for making sure a region of the current buffer has | ||
| 2995 | been fontified. It is called with two arguments, the beginning and | ||
| 2996 | end of the region. The default value of this variable is a function | ||
| 2997 | that calls @code{font-lock-default-fontify-buffer} if the buffer is | ||
| 2998 | not fontified; the effect is to make sure the entire accessible | ||
| 2999 | portion 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 |
| 2940 | This function tells Font Lock mode to run the Lisp function | 3003 | This 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 |
| @@ -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 | +++ |
| 646 | should be used instead of font-lock-fontify-buffer when called from Elisp. | 646 | ** New font-lock functions `font-lock-ensure' and `font-lock-flush'. |
| 647 | These should be used in preference to `font-lock-fontify-buffer' when | ||
| 648 | called 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 |
| 649 | appending FUN to `minibuffer-setup-hook'. | 651 | appending 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. |
| 1068 | If the region is not specified, it defaults to the whole buffer." | 1068 | If the region is not specified, it defaults to the entire |
| 1069 | accessible 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. |
| 1082 | If the region is not specified, it defaults to the whole buffer." | 1083 | If the region is not specified, it defaults to the entire accessible |
| 1084 | portion 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)))) |