diff options
| author | Richard M. Stallman | 1999-09-07 19:21:50 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-09-07 19:21:50 +0000 |
| commit | fb0e4f8a84131a7a176f7dad4cbb61ac71e2e7c3 (patch) | |
| tree | 8314b16f4624e3e90370bca6a51f35183b10c96d | |
| parent | 505ab9bc44237e371309c555e3d5d245252e0964 (diff) | |
| download | emacs-fb0e4f8a84131a7a176f7dad4cbb61ac71e2e7c3.tar.gz emacs-fb0e4f8a84131a7a176f7dad4cbb61ac71e2e7c3.zip | |
(font-lock-multiline): New text property contains
a boolean to indicate if the char is part of a multiline match.
(font-lock-default-fontify-region): Extend the region appropriately
for multiline keywords.
(font-lock-default-unfontify-region): Also remove the new
font-lock-multiline text property.
(font-lock-fontify-anchored-keywords): Mark multiline anchored matches.
(font-lock-fontify-keywords-region): Mark multiline regexp matches.
| -rw-r--r-- | lisp/font-lock.el | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index bfc4a1460c6..fe45bf5675a 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -1093,6 +1093,16 @@ The value of this variable is used when Font Lock mode is turned on." | |||
| 1093 | ;; Use the fontification syntax table, if any. | 1093 | ;; Use the fontification syntax table, if any. |
| 1094 | (when font-lock-syntax-table | 1094 | (when font-lock-syntax-table |
| 1095 | (set-syntax-table font-lock-syntax-table)) | 1095 | (set-syntax-table font-lock-syntax-table)) |
| 1096 | ;; check to see if we should expand the beg/end area for | ||
| 1097 | ;; proper multiline matches | ||
| 1098 | (setq beg (if (get-text-property beg 'font-lock-multiline) | ||
| 1099 | (or (previous-single-property-change | ||
| 1100 | beg 'font-lock-multiline) | ||
| 1101 | (point-min)) | ||
| 1102 | beg)) | ||
| 1103 | (setq end (or (text-property-any end (point-max) | ||
| 1104 | 'font-lock-multiline nil) | ||
| 1105 | (point-max))) | ||
| 1096 | ;; Now do the fontification. | 1106 | ;; Now do the fontification. |
| 1097 | (font-lock-unfontify-region beg end) | 1107 | (font-lock-unfontify-region beg end) |
| 1098 | (when font-lock-syntactic-keywords | 1108 | (when font-lock-syntactic-keywords |
| @@ -1113,9 +1123,10 @@ The value of this variable is used when Font Lock mode is turned on." | |||
| 1113 | 1123 | ||
| 1114 | (defun font-lock-default-unfontify-region (beg end) | 1124 | (defun font-lock-default-unfontify-region (beg end) |
| 1115 | (save-buffer-state nil | 1125 | (save-buffer-state nil |
| 1116 | (if font-lock-syntactic-keywords | 1126 | (remove-text-properties beg end |
| 1117 | (remove-text-properties beg end '(face nil syntax-table nil)) | 1127 | (if font-lock-syntactic-keywords |
| 1118 | (remove-text-properties beg end '(face nil))))) | 1128 | '(face nil syntax-table nil font-lock-multiline nil) |
| 1129 | '(face nil font-lock-multiline nil))))) | ||
| 1119 | 1130 | ||
| 1120 | ;; Called when any modification is made to buffer text. | 1131 | ;; Called when any modification is made to buffer text. |
| 1121 | (defun font-lock-after-change-function (beg end old-len) | 1132 | (defun font-lock-after-change-function (beg end old-len) |
| @@ -1425,12 +1436,16 @@ HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'." | |||
| 1425 | KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords', | 1436 | KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords', |
| 1426 | LIMIT can be modified by the value of its PRE-MATCH-FORM." | 1437 | LIMIT can be modified by the value of its PRE-MATCH-FORM." |
| 1427 | (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights | 1438 | (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights |
| 1439 | (lead-start (match-beginning 0)) | ||
| 1428 | ;; Evaluate PRE-MATCH-FORM. | 1440 | ;; Evaluate PRE-MATCH-FORM. |
| 1429 | (pre-match-value (eval (nth 1 keywords)))) | 1441 | (pre-match-value (eval (nth 1 keywords)))) |
| 1430 | ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line. | 1442 | ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line. |
| 1431 | (if (and (numberp pre-match-value) (> pre-match-value (point))) | 1443 | (if (not (and (numberp pre-match-value) (> pre-match-value (point)))) |
| 1432 | (setq limit pre-match-value) | 1444 | (save-excursion (end-of-line) (setq limit (point))) |
| 1433 | (save-excursion (end-of-line) (setq limit (point)))) | 1445 | (setq limit pre-match-value) |
| 1446 | (when (>= pre-match-value (save-excursion (forward-line 1) (point))) | ||
| 1447 | ;; this is a multiline anchored match | ||
| 1448 | (put-text-property (point) limit 'font-lock-multiline t))) | ||
| 1434 | (save-match-data | 1449 | (save-match-data |
| 1435 | ;; Find an occurrence of `matcher' before `limit'. | 1450 | ;; Find an occurrence of `matcher' before `limit'. |
| 1436 | (while (if (stringp matcher) | 1451 | (while (if (stringp matcher) |
| @@ -1466,6 +1481,13 @@ START should be at the beginning of a line." | |||
| 1466 | (if (stringp matcher) | 1481 | (if (stringp matcher) |
| 1467 | (re-search-forward matcher end t) | 1482 | (re-search-forward matcher end t) |
| 1468 | (funcall matcher end))) | 1483 | (funcall matcher end))) |
| 1484 | (when (and (match-beginning 0) | ||
| 1485 | (>= (point) | ||
| 1486 | (save-excursion (goto-char (match-beginning 0)) | ||
| 1487 | (forward-line 1) (point)))) | ||
| 1488 | ;; this is a multiline regexp match | ||
| 1489 | (put-text-property (match-beginning 0) (point) | ||
| 1490 | 'font-lock-multiline t)) | ||
| 1469 | ;; Apply each highlight to this instance of `matcher', which may be | 1491 | ;; Apply each highlight to this instance of `matcher', which may be |
| 1470 | ;; specific highlights or more keywords anchored to `matcher'. | 1492 | ;; specific highlights or more keywords anchored to `matcher'. |
| 1471 | (setq highlights (cdr keyword)) | 1493 | (setq highlights (cdr keyword)) |