# HG changeset patch # User Stefan Monnier # Date 1154459351 0 # Node ID ed72e8922d85772963cfad907aea16e1d99435f2 # Parent 3ca9684795fe323b2929d59e10ab17f73b6eff45 (font-lock-extend-region-function, font-lock-extend-region): Move from font-core.el. Simplify. diff -r 3ca9684795fe -r ed72e8922d85 lisp/ChangeLog --- a/lisp/ChangeLog Tue Aug 01 19:01:24 2006 +0000 +++ b/lisp/ChangeLog Tue Aug 01 19:09:11 2006 +0000 @@ -1,5 +1,17 @@ 2006-08-01 Stefan Monnier + * font-core.el (font-lock-extend-region-function) + (font-lock-extend-region): Move to font-lock.el. + + * font-lock.el (font-lock-extend-region-function) + (font-lock-extend-region): Move from font-core.el. Simplify. + + * jit-lock.el (jit-lock-fontify-now): Cause a second redisplay + if needed. + (jit-lock-start, jit-lock-end): New dynamic scoped vars. + (jit-lock-after-change-extend-region-functions): New hook. + (jit-lock-after-change): Use it instead of hard-coding font-lock code. + * font-lock.el (font-lock-extend-jit-lock-region-after-change): New fun. (font-lock-turn-on-thing-lock): Use it. diff -r 3ca9684795fe -r ed72e8922d85 lisp/font-lock.el --- a/lisp/font-lock.el Tue Aug 01 19:01:24 2006 +0000 +++ b/lisp/font-lock.el Tue Aug 01 19:09:11 2006 +0000 @@ -975,6 +975,31 @@ ;; directives correctly and cleanly. (It is the same problem as fontifying ;; multi-line strings and comments; regexps are not appropriate for the job.) +(defvar font-lock-extend-region-function nil + "A function that determines the region to fontify after a change. + +This variable is either nil, or is a function that determines the +region to refontify after a change. +It is usually set by the major mode via `font-lock-defaults'. +Font-lock calls this function after each buffer change. + +The function is given three parameters, the standard BEG, END, and OLD-LEN +from `after-change-functions'. It should return either a cons of the beginning +and end buffer positions \(in that order) of the region to fontify, or nil +\(which directs the caller to fontify a default region). This function +should preserve point and the match-data. +The region it returns may start or end in the middle of a line.") + +(defun font-lock-extend-region (beg end old-len) + "Determine the region to fontify after a buffer change. + +BEG END and OLD-LEN are the standard parameters from `after-change-functions'. +The return value is either nil \(which directs the caller to chose the region +itself), or a cons of the beginning and end \(in that order) of the region. +The region returned may start or end in the middle of a line." + (if font-lock-extend-region-function + (funcall font-lock-extend-region-function beg end old-len))) + (defun font-lock-fontify-buffer () "Fontify the current buffer the way the function `font-lock-mode' would." (interactive)