# HG changeset patch # User Tassilo Horn # Date 1262029109 -3600 # Node ID d3ca1d918965f159e84461c9d269be0e3d4dad1a # Parent 1b4df859a104371e571866f9a2d0c3260c200deb# Parent 17b93d093db8982233d34612ed6873a37467dc28 Merge: * 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 diff -r 1b4df859a104 -r d3ca1d918965 lisp/ChangeLog --- a/lisp/ChangeLog Mon Dec 28 11:20:02 2009 -0800 +++ b/lisp/ChangeLog Mon Dec 28 20:38:29 2009 +0100 @@ -1,3 +1,10 @@ +2009-12-28 Tassilo Horn + + * 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 * vc-rcs.el (vc-rcs-register): Fix registering a specific version. diff -r 1b4df859a104 -r d3ca1d918965 lisp/font-lock.el --- a/lisp/font-lock.el Mon Dec 28 11:20:02 2009 -0800 +++ b/lisp/font-lock.el Mon Dec 28 20:38:29 2009 +0100 @@ -1767,6 +1767,23 @@ (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.