diff options
| author | Tassilo Horn <tassilo@member.fsf.org> | 2009-12-28 20:34:10 +0100 |
|---|---|---|
| committer | Tassilo Horn <tassilo@member.fsf.org> | 2009-12-28 20:34:10 +0100 |
| commit | 543f553a8db74d2e450d966544013478a2ced902 (patch) | |
| tree | a98314fb52a658419da1252b06813321612dc8b1 | |
| parent | ac859983d70c71997a295239e2bc917130a6bd97 (diff) | |
| download | emacs-543f553a8db74d2e450d966544013478a2ced902.tar.gz | |
* font-lock.el (font-lock-refresh-defaults): New function, which
can be used to let font-lock react to external changes in
variables like font-lock-defaults and keywords.
See http://thread.gmane.org/gmane.emacs.devel/118777/focus=118802
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/font-lock.el | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a454f132733..236f2fe35ad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2009-12-28 Tassilo Horn <tassilo@member.fsf.org> + + * font-lock.el (font-lock-refresh-defaults): New function, which + can be used to let font-lock react to external changes in + variables like font-lock-defaults and keywords. + See http://thread.gmane.org/gmane.emacs.devel/118777/focus=118802 + 2009-12-28 Dan Nicolaescu <dann@ics.uci.edu> * vc-rcs.el (vc-rcs-register): Fix registering a specific version. diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 95d061b3024..c2fd86ed726 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1767,6 +1767,23 @@ A LEVEL of nil is equal to a LEVEL of 0, a LEVEL of t is equal to (defvar font-lock-set-defaults nil) ; Whether we have set up defaults. +(defun font-lock-refresh-defaults () + "Restart fontification in current buffer after recomputing from defaults. +Recompute fontification variables using `font-lock-defaults' (or, +if nil, using `font-lock-defaults-alist') and +`font-lock-maximum-decoration'. Then restart fontification. + +Use this function when you have changed any of the above +variables directly. + +Note: This function will erase modifications done by +`font-lock-add-keywords' or `font-lock-remove-keywords', but will +preserve `hi-lock-mode' highlighting patterns." + (let ((hi-lock--inhibit-font-lock-hook t)) + (font-lock-mode -1)) + (kill-local-variable 'font-lock-set-defaults) + (font-lock-mode 1)) + (defvar font-lock-mode-major-mode) (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode. |
