Mercurial > emacs
comparison lisp/font-lock.el @ 72232:ed72e8922d85
(font-lock-extend-region-function, font-lock-extend-region):
Move from font-core.el. Simplify.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 01 Aug 2006 19:09:11 +0000 |
parents | d254902ce935 |
children | 482bf4e8cc00 |
comparison
equal
deleted
inserted
replaced
72231:3ca9684795fe | 72232:ed72e8922d85 |
---|---|
972 ;; pass. And Hairy mode would set `font-lock-defaults' so that font-lock.el | 972 ;; pass. And Hairy mode would set `font-lock-defaults' so that font-lock.el |
973 ;; would call your region fontification function instead of its own. For | 973 ;; would call your region fontification function instead of its own. For |
974 ;; example, TeX modes could fontify {\foo ...} and \bar{...} etc. multi-line | 974 ;; example, TeX modes could fontify {\foo ...} and \bar{...} etc. multi-line |
975 ;; directives correctly and cleanly. (It is the same problem as fontifying | 975 ;; directives correctly and cleanly. (It is the same problem as fontifying |
976 ;; multi-line strings and comments; regexps are not appropriate for the job.) | 976 ;; multi-line strings and comments; regexps are not appropriate for the job.) |
977 | |
978 (defvar font-lock-extend-region-function nil | |
979 "A function that determines the region to fontify after a change. | |
980 | |
981 This variable is either nil, or is a function that determines the | |
982 region to refontify after a change. | |
983 It is usually set by the major mode via `font-lock-defaults'. | |
984 Font-lock calls this function after each buffer change. | |
985 | |
986 The function is given three parameters, the standard BEG, END, and OLD-LEN | |
987 from `after-change-functions'. It should return either a cons of the beginning | |
988 and end buffer positions \(in that order) of the region to fontify, or nil | |
989 \(which directs the caller to fontify a default region). This function | |
990 should preserve point and the match-data. | |
991 The region it returns may start or end in the middle of a line.") | |
992 | |
993 (defun font-lock-extend-region (beg end old-len) | |
994 "Determine the region to fontify after a buffer change. | |
995 | |
996 BEG END and OLD-LEN are the standard parameters from `after-change-functions'. | |
997 The return value is either nil \(which directs the caller to chose the region | |
998 itself), or a cons of the beginning and end \(in that order) of the region. | |
999 The region returned may start or end in the middle of a line." | |
1000 (if font-lock-extend-region-function | |
1001 (funcall font-lock-extend-region-function beg end old-len))) | |
977 | 1002 |
978 (defun font-lock-fontify-buffer () | 1003 (defun font-lock-fontify-buffer () |
979 "Fontify the current buffer the way the function `font-lock-mode' would." | 1004 "Fontify the current buffer the way the function `font-lock-mode' would." |
980 (interactive) | 1005 (interactive) |
981 (font-lock-set-defaults) | 1006 (font-lock-set-defaults) |