| 85 | | |
|---|
| 86 | | (defvar font-lock-extend-region-function nil |
|---|
| 87 | | "A function that determines the region to fontify after a change. |
|---|
| 88 | | |
|---|
| 89 | | This buffer-local variable is either nil, or is a function that determines the |
|---|
| 90 | | region to fontify. It is usually set by the major mode. The currently active |
|---|
| 91 | | font-lock after-change function calls this function after each buffer change. |
|---|
| 92 | | |
|---|
| 93 | | The function is given three parameters, the standard BEG, END, and OLD-LEN |
|---|
| 94 | | from after-change-functions. It should return either a cons of the beginning |
|---|
| 95 | | and end buffer positions \(in that order) of the region to fontify, or nil |
|---|
| 96 | | \(which directs the caller to fontify a default region). This function need |
|---|
| 97 | | not preserve point or the match-data, but must preserve the current |
|---|
| 98 | | restriction. The region it returns may start or end in the middle of a |
|---|
| 99 | | line.") |
|---|
| 100 | | (make-variable-buffer-local 'font-lock-extend-region-function) |
|---|
| 101 | | |
|---|
| 102 | | (defun font-lock-extend-region (beg end old-len) |
|---|
| 103 | | "Determine the region to fontify after a buffer change. |
|---|
| 104 | | |
|---|
| 105 | | BEG END and OLD-LEN are the standard parameters from after-change-functions. |
|---|
| 106 | | The return value is either nil \(which directs the caller to chose the region |
|---|
| 107 | | itself), or a cons of the beginning and end \(in that order) of the region. |
|---|
| 108 | | The region returned may start or end in the middle of a line." |
|---|
| 109 | | (if font-lock-extend-region-function |
|---|
| 110 | | (save-match-data |
|---|
| 111 | | (save-excursion |
|---|
| 112 | | (funcall font-lock-extend-region-function beg end old-len))))) |
|---|