diff options
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index a2ac2a32535..d352e5b08c9 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -292,12 +292,17 @@ | |||
| 292 | nil))))) | 292 | nil))))) |
| 293 | res)))) | 293 | res)))) |
| 294 | 294 | ||
| 295 | (defun c-make-font-lock-search-form (regexp highlights) | 295 | (defun c-make-font-lock-search-form (regexp highlights &optional check-point) |
| 296 | ;; Return a lisp form which will fontify every occurrence of REGEXP | 296 | ;; Return a lisp form which will fontify every occurrence of REGEXP |
| 297 | ;; (a regular expression, NOT a function) between POINT and `limit' | 297 | ;; (a regular expression, NOT a function) between POINT and `limit' |
| 298 | ;; with HIGHLIGHTS, a list of highlighters as specified on page | 298 | ;; with HIGHLIGHTS, a list of highlighters as specified on page |
| 299 | ;; "Search-based Fontification" in the elisp manual. | 299 | ;; "Search-based Fontification" in the elisp manual. If CHECK-POINT |
| 300 | `(while (re-search-forward ,regexp limit t) | 300 | ;; is non-nil, we will check (< (point) limit) in the main loop. |
| 301 | `(while | ||
| 302 | ,(if check-point | ||
| 303 | `(and (< (point) limit) | ||
| 304 | (re-search-forward ,regexp limit t)) | ||
| 305 | `(re-search-forward ,regexp limit t)) | ||
| 301 | (unless (progn | 306 | (unless (progn |
| 302 | (goto-char (match-beginning 0)) | 307 | (goto-char (match-beginning 0)) |
| 303 | (c-skip-comments-and-strings limit)) | 308 | (c-skip-comments-and-strings limit)) |
| @@ -476,7 +481,9 @@ | |||
| 476 | ,(c-make-font-lock-search-form | 481 | ,(c-make-font-lock-search-form |
| 477 | regexp highlights))))) | 482 | regexp highlights))))) |
| 478 | state-stanzas) | 483 | state-stanzas) |
| 479 | ,(c-make-font-lock-search-form (car normal) (cdr normal)) | 484 | ;; In the next form, check that point hasn't been moved beyond |
| 485 | ;; `limit' in any of the above stanzas. | ||
| 486 | ,(c-make-font-lock-search-form (car normal) (cdr normal) t) | ||
| 480 | nil)))) | 487 | nil)))) |
| 481 | 488 | ||
| 482 | ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. | 489 | ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. |