diff options
| author | Lars Ingebrigtsen | 2019-10-30 13:08:55 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-30 13:16:44 +0100 |
| commit | e1409379f7ce60eb845a0b9c3a614af4f5fac694 (patch) | |
| tree | 95136e61c64a5c8222bbb81e7cc7f1b3bcc6ab07 | |
| parent | 305dbc7e2be05748039aacb1a3d697f6f64bed4c (diff) | |
| download | emacs-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.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/font-lock.el | 9 |
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 |
| 2738 | accessible portion. Calls the function specified by | 2738 | accessible portion. Calls the function specified by |
| 2739 | @code{font-lock-ensure-function}. | 2739 | @code{font-lock-ensure-function}. |
| 2740 | |||
| 2741 | @item font-lock-refontify | ||
| 2742 | This is a convenience command meant to be used when developing font | ||
| 2743 | locking for a mode, and should not be called from Lisp code. It | ||
| 2744 | recomputes 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 |
| @@ -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'. | ||
| 580 | This is an interactive convenience function to be used when developing | ||
| 581 | font locking for a mode. It recomputes the font locking data and then | ||
| 582 | re-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 |
| 580 | the extracted file if the new user option 'tar-copy-preserve-time' is | 586 | 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 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. |
| 1101 | Called with two arguments BEG and END.") | 1101 | Called with two arguments BEG and END.") |
| 1102 | 1102 | ||
| 1103 | (defun font-lock-refontify () | ||
| 1104 | "Reinitialise the font-lock machinery and re-fontify the buffer. | ||
| 1105 | This functions is a convenience functions when developing font | ||
| 1106 | locking 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. |
| 1105 | If the region is not specified, it defaults to the entire accessible | 1114 | If the region is not specified, it defaults to the entire accessible |