diff options
| author | Simon Marshall | 1997-01-09 10:08:58 +0000 |
|---|---|---|
| committer | Simon Marshall | 1997-01-09 10:08:58 +0000 |
| commit | 1c626aaf749003439929908143e519befd64eb53 (patch) | |
| tree | c11826135d42e1d1b065d00d273a38327cc0d8d2 | |
| parent | ddb2b1814fb8a74c92200f71a971fdf292f64c3e (diff) | |
| download | emacs-1c626aaf749003439929908143e519befd64eb53.tar.gz emacs-1c626aaf749003439929908143e519befd64eb53.zip | |
Fix additional text prop fns to behave as proposed builtins.
Undo previous font-lock-after-change-function as that works better albeit not perfectly.
| -rw-r--r-- | lisp/font-lock.el | 179 |
1 files changed, 94 insertions, 85 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 0117d5f5c94..d3bb3d11d6b 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; font-lock.el --- Electric font lock mode | 1 | ;;; font-lock.el --- Electric font lock mode |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: jwz, then rms, then sm <simon@gnu.ai.mit.edu> | 5 | ;; Author: jwz, then rms, then sm <simon@gnu.ai.mit.edu> |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -195,7 +195,7 @@ for buffers in Rmail mode, and size is irrelevant otherwise.") | |||
| 195 | ;; and they give users another mechanism for changing face appearance. | 195 | ;; and they give users another mechanism for changing face appearance. |
| 196 | ;; We now allow a FACENAME in `font-lock-keywords' to be any expression that | 196 | ;; We now allow a FACENAME in `font-lock-keywords' to be any expression that |
| 197 | ;; returns a face. So the easiest thing is to continue using these variables, | 197 | ;; returns a face. So the easiest thing is to continue using these variables, |
| 198 | ;; rather than sometimes evaling FACENAME and sometimes not. | 198 | ;; rather than sometimes evaling FACENAME and sometimes not. sm. |
| 199 | (defvar font-lock-comment-face 'font-lock-comment-face | 199 | (defvar font-lock-comment-face 'font-lock-comment-face |
| 200 | "Face to use for comments.") | 200 | "Face to use for comments.") |
| 201 | 201 | ||
| @@ -485,7 +485,7 @@ This is normally set via `font-lock-defaults'.") | |||
| 485 | Currently, valid mode names as `fast-lock-mode' and `lazy-lock-mode'. | 485 | Currently, valid mode names as `fast-lock-mode' and `lazy-lock-mode'. |
| 486 | This is normally set via `font-lock-defaults'.") | 486 | This is normally set via `font-lock-defaults'.") |
| 487 | 487 | ||
| 488 | (defvar font-lock-mode nil) ; For the modeline. | 488 | (defvar font-lock-mode nil) ; Whether we are turned on/modeline. |
| 489 | (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. | 489 | (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. |
| 490 | 490 | ||
| 491 | ;;;###autoload | 491 | ;;;###autoload |
| @@ -499,6 +499,10 @@ This is normally set via `font-lock-defaults'.") | |||
| 499 | ;; We don't do this at the top-level as we only use non-autoloaded macros. | 499 | ;; We don't do this at the top-level as we only use non-autoloaded macros. |
| 500 | (require 'cl) | 500 | (require 'cl) |
| 501 | ;; | 501 | ;; |
| 502 | ;; Shut the byte-compiler up. | ||
| 503 | (require 'fast-lock) | ||
| 504 | (require 'lazy-lock) | ||
| 505 | ;; | ||
| 502 | ;; Borrowed from lazy-lock.el. | 506 | ;; Borrowed from lazy-lock.el. |
| 503 | ;; We use this to preserve or protect things when modifying text properties. | 507 | ;; We use this to preserve or protect things when modifying text properties. |
| 504 | (defmacro save-buffer-state (varlist &rest body) | 508 | (defmacro save-buffer-state (varlist &rest body) |
| @@ -607,8 +611,8 @@ Turn on only if the terminal can display it." | |||
| 607 | ;;;###autoload | 611 | ;;;###autoload |
| 608 | (defun font-lock-add-keywords (major-mode keywords &optional append) | 612 | (defun font-lock-add-keywords (major-mode keywords &optional append) |
| 609 | "Add highlighting KEYWORDS for MAJOR-MODE. | 613 | "Add highlighting KEYWORDS for MAJOR-MODE. |
| 610 | MODE should be a symbol, the major mode command name, such as `c-mode' or nil. | 614 | MAJOR-MODE should be a symbol, the major mode command name, such as `c-mode' |
| 611 | If nil, highlighting keywords are added for the current buffer. | 615 | or nil. If nil, highlighting keywords are added for the current buffer. |
| 612 | KEYWORDS should be a list; see the variable `font-lock-keywords'. | 616 | KEYWORDS should be a list; see the variable `font-lock-keywords'. |
| 613 | By default they are added at the beginning of the current highlighting list. | 617 | By default they are added at the beginning of the current highlighting list. |
| 614 | If optional argument APPEND is `set', they are used to replace the current | 618 | If optional argument APPEND is `set', they are used to replace the current |
| @@ -692,7 +696,7 @@ comments, and to fontify `and', `or' and `not' words as keywords." | |||
| 692 | ;; (add-hook 'c-mode-hook 'turn-on-font-lock), would cause Font Lock mode to be | 696 | ;; (add-hook 'c-mode-hook 'turn-on-font-lock), would cause Font Lock mode to be |
| 693 | ;; turned on everywhere. That would not be intuitive or informative because | 697 | ;; turned on everywhere. That would not be intuitive or informative because |
| 694 | ;; loading a file tells you nothing about the feature or how to control it. It | 698 | ;; loading a file tells you nothing about the feature or how to control it. It |
| 695 | ;; would also be contrary to the Principle of Least Surprise. | 699 | ;; would also be contrary to the Principle of Least Surprise. sm. |
| 696 | 700 | ||
| 697 | (defvar font-lock-buffers nil) ; For remembering buffers. | 701 | (defvar font-lock-buffers nil) ; For remembering buffers. |
| 698 | (defvar global-font-lock-mode nil) | 702 | (defvar global-font-lock-mode nil) |
| @@ -749,17 +753,17 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'." | |||
| 749 | ;; the user. | 753 | ;; the user. |
| 750 | (remove-hook 'post-command-hook 'turn-on-font-lock-if-enabled) | 754 | (remove-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
| 751 | (while font-lock-buffers | 755 | (while font-lock-buffers |
| 752 | (if (buffer-live-p (car font-lock-buffers)) | 756 | (when (buffer-live-p (car font-lock-buffers)) |
| 753 | (save-excursion | 757 | (save-excursion |
| 754 | (set-buffer (car font-lock-buffers)) | 758 | (set-buffer (car font-lock-buffers)) |
| 755 | (if (and (or font-lock-defaults | 759 | (when (and (or font-lock-defaults |
| 756 | (assq major-mode font-lock-defaults-alist)) | 760 | (assq major-mode font-lock-defaults-alist)) |
| 757 | (or (eq font-lock-global-modes t) | 761 | (or (eq font-lock-global-modes t) |
| 758 | (if (eq (car-safe font-lock-global-modes) 'not) | 762 | (if (eq (car-safe font-lock-global-modes) 'not) |
| 759 | (not (memq major-mode (cdr font-lock-global-modes))) | 763 | (not (memq major-mode (cdr font-lock-global-modes))) |
| 760 | (memq major-mode font-lock-global-modes)))) | 764 | (memq major-mode font-lock-global-modes)))) |
| 761 | (let (inhibit-quit) | 765 | (let (inhibit-quit) |
| 762 | (turn-on-font-lock))))) | 766 | (turn-on-font-lock))))) |
| 763 | (setq font-lock-buffers (cdr font-lock-buffers)))) | 767 | (setq font-lock-buffers (cdr font-lock-buffers)))) |
| 764 | 768 | ||
| 765 | (add-hook 'change-major-mode-hook 'font-lock-change-major-mode) | 769 | (add-hook 'change-major-mode-hook 'font-lock-change-major-mode) |
| @@ -901,7 +905,7 @@ The value of this variable is used when Font Lock mode is turned on.") | |||
| 901 | ;; Rescan between start of lines enclosing the region. | 905 | ;; Rescan between start of lines enclosing the region. |
| 902 | (font-lock-fontify-region | 906 | (font-lock-fontify-region |
| 903 | (progn (goto-char beg) (beginning-of-line) (point)) | 907 | (progn (goto-char beg) (beginning-of-line) (point)) |
| 904 | (progn (goto-char (+ end old-len)) (forward-line 1) (point)))))) | 908 | (progn (goto-char end) (forward-line 1) (point)))))) |
| 905 | 909 | ||
| 906 | (defun font-lock-fontify-block (&optional arg) | 910 | (defun font-lock-fontify-block (&optional arg) |
| 907 | "Fontify some lines the way `font-lock-fontify-buffer' would. | 911 | "Fontify some lines the way `font-lock-fontify-buffer' would. |
| @@ -934,7 +938,7 @@ delimit the region to fontify." | |||
| 934 | ;; line. Used to make `font-lock-fontify-syntactically-region' faster. | 938 | ;; line. Used to make `font-lock-fontify-syntactically-region' faster. |
| 935 | ;; Previously, `font-lock-cache-position' was just a buffer position. However, | 939 | ;; Previously, `font-lock-cache-position' was just a buffer position. However, |
| 936 | ;; under certain situations, this occasionally resulted in mis-fontification. | 940 | ;; under certain situations, this occasionally resulted in mis-fontification. |
| 937 | ;; I think those "situations" were deletion with Lazy Lock mode's deferral. | 941 | ;; I think the "situations" were deletion with Lazy Lock mode's deferral. sm. |
| 938 | (defvar font-lock-cache-state nil) | 942 | (defvar font-lock-cache-state nil) |
| 939 | (defvar font-lock-cache-position nil) | 943 | (defvar font-lock-cache-position nil) |
| 940 | 944 | ||
| @@ -1042,79 +1046,82 @@ START should be at the beginning of a line." | |||
| 1042 | 1046 | ||
| 1043 | ;;; Additional text property functions. | 1047 | ;;; Additional text property functions. |
| 1044 | 1048 | ||
| 1045 | ;; The following three text property functions are not generally available (and | 1049 | ;; The following text property functions should be builtins. This means they |
| 1046 | ;; it's not certain that they should be) so they are inlined for speed. | 1050 | ;; should be written in C and put with all the other text property functions. |
| 1047 | ;; The case for `fillin-text-property' is simple; it may or not be generally | 1051 | ;; In the meantime, those that are used by font-lock.el are defined in Lisp |
| 1048 | ;; useful. (Since it is used here, it is useful in at least one place.;-) | 1052 | ;; below and given a `font-lock-' prefix. Those that are not used are defined |
| 1049 | ;; However, the case for `append-text-property' and `prepend-text-property' is | 1053 | ;; in Lisp below and commented out. sm. |
| 1050 | ;; more complicated. Should they remove duplicate property values or not? If | ||
| 1051 | ;; so, should the first or last duplicate item remain? Or the one that was | ||
| 1052 | ;; added? In our implementation, the first duplicate remains. | ||
| 1053 | |||
| 1054 | (defsubst font-lock-fillin-text-property (start end prop value &optional object) | ||
| 1055 | "Fill in one property of the text from START to END. | ||
| 1056 | Arguments PROP and VALUE specify the property and value to put where none are | ||
| 1057 | already in place. Therefore existing property values are not overwritten. | ||
| 1058 | Optional argument OBJECT is the string or buffer containing the text." | ||
| 1059 | (let ((start (text-property-any start end prop nil object)) next) | ||
| 1060 | (while start | ||
| 1061 | (setq next (next-single-property-change start prop object end)) | ||
| 1062 | (put-text-property start next prop value object) | ||
| 1063 | (setq start (text-property-any next end prop nil object))))) | ||
| 1064 | 1054 | ||
| 1065 | ;; This function (from simon's unique.el) is rewritten and inlined for speed. | 1055 | (defun font-lock-prepend-text-property (start end prop value &optional object) |
| 1066 | ;(defun unique (list function) | ||
| 1067 | ; "Uniquify LIST, deleting elements using FUNCTION. | ||
| 1068 | ;Return the list with subsequent duplicate items removed by side effects. | ||
| 1069 | ;FUNCTION is called with an element of LIST and a list of elements from LIST, | ||
| 1070 | ;and should return the list of elements with occurrences of the element removed, | ||
| 1071 | ;i.e., a function such as `delete' or `delq'. | ||
| 1072 | ;This function will work even if LIST is unsorted. See also `uniq'." | ||
| 1073 | ; (let ((list list)) | ||
| 1074 | ; (while list | ||
| 1075 | ; (setq list (setcdr list (funcall function (car list) (cdr list)))))) | ||
| 1076 | ; list) | ||
| 1077 | |||
| 1078 | (defsubst font-lock-unique (list) | ||
| 1079 | "Uniquify LIST, deleting elements using `delq'. | ||
| 1080 | Return the list with subsequent duplicate items removed by side effects." | ||
| 1081 | (let ((list list)) | ||
| 1082 | (while list | ||
| 1083 | (setq list (setcdr list (delq (car list) (cdr list)))))) | ||
| 1084 | list) | ||
| 1085 | |||
| 1086 | ;; A generalisation of `facemenu-add-face' for any property, but without the | ||
| 1087 | ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special | ||
| 1088 | ;; treatment of `default'. Uses `unique' to remove duplicate property values. | ||
| 1089 | (defsubst font-lock-prepend-text-property (start end prop value &optional object) | ||
| 1090 | "Prepend to one property of the text from START to END. | 1056 | "Prepend to one property of the text from START to END. |
| 1091 | Arguments PROP and VALUE specify the property and value to prepend to the value | 1057 | Arguments PROP and VALUE specify the property and value to prepend to the value |
| 1092 | already in place. The resulting property values are always lists, and unique. | 1058 | already in place. The resulting property values are always lists. |
| 1093 | Optional argument OBJECT is the string or buffer containing the text." | 1059 | Optional argument OBJECT is the string or buffer containing the text." |
| 1094 | (let ((val (if (listp value) value (list value))) next prev) | 1060 | (let ((val (if (listp value) value (list value))) next prev) |
| 1095 | (while (/= start end) | 1061 | (while (/= start end) |
| 1096 | (setq next (next-single-property-change start prop object end) | 1062 | (setq next (next-single-property-change start prop object end) |
| 1097 | prev (get-text-property start prop object)) | 1063 | prev (get-text-property start prop object)) |
| 1098 | (put-text-property | 1064 | (put-text-property start next prop |
| 1099 | start next prop | 1065 | (append val (if (listp prev) prev (list prev))) |
| 1100 | (font-lock-unique (append val (if (listp prev) prev (list prev)))) | 1066 | object) |
| 1101 | object) | ||
| 1102 | (setq start next)))) | 1067 | (setq start next)))) |
| 1103 | 1068 | ||
| 1104 | (defsubst font-lock-append-text-property (start end prop value &optional object) | 1069 | (defun font-lock-append-text-property (start end prop value &optional object) |
| 1105 | "Append to one property of the text from START to END. | 1070 | "Append to one property of the text from START to END. |
| 1106 | Arguments PROP and VALUE specify the property and value to append to the value | 1071 | Arguments PROP and VALUE specify the property and value to append to the value |
| 1107 | already in place. The resulting property values are always lists, and unique. | 1072 | already in place. The resulting property values are always lists. |
| 1108 | Optional argument OBJECT is the string or buffer containing the text." | 1073 | Optional argument OBJECT is the string or buffer containing the text." |
| 1109 | (let ((val (if (listp value) value (list value))) next prev) | 1074 | (let ((val (if (listp value) value (list value))) next prev) |
| 1110 | (while (/= start end) | 1075 | (while (/= start end) |
| 1111 | (setq next (next-single-property-change start prop object end) | 1076 | (setq next (next-single-property-change start prop object end) |
| 1112 | prev (get-text-property start prop object)) | 1077 | prev (get-text-property start prop object)) |
| 1113 | (put-text-property | 1078 | (put-text-property start next prop |
| 1114 | start next prop | 1079 | (append (if (listp prev) prev (list prev)) val) |
| 1115 | (font-lock-unique (append (if (listp prev) prev (list prev)) val)) | 1080 | object) |
| 1116 | object) | ||
| 1117 | (setq start next)))) | 1081 | (setq start next)))) |
| 1082 | |||
| 1083 | (defun font-lock-fillin-text-property (start end prop value &optional object) | ||
| 1084 | "Fill in one property of the text from START to END. | ||
| 1085 | Arguments PROP and VALUE specify the property and value to put where none are | ||
| 1086 | already in place. Therefore existing property values are not overwritten. | ||
| 1087 | Optional argument OBJECT is the string or buffer containing the text." | ||
| 1088 | (let ((start (text-property-any start end prop nil object)) next) | ||
| 1089 | (while start | ||
| 1090 | (setq next (next-single-property-change start prop object end)) | ||
| 1091 | (put-text-property start next prop value object) | ||
| 1092 | (setq start (text-property-any next end prop nil object))))) | ||
| 1093 | |||
| 1094 | ;; For completeness: this is to `remove-text-properties' as `put-text-property' | ||
| 1095 | ;; is to `add-text-properties', etc. | ||
| 1096 | ;(defun remove-text-property (start end property &optional object) | ||
| 1097 | ; "Remove a property from text from START to END. | ||
| 1098 | ;Argument PROPERTY is the property to remove. | ||
| 1099 | ;Optional argument OBJECT is the string or buffer containing the text. | ||
| 1100 | ;Return t if the property was actually removed, nil otherwise." | ||
| 1101 | ; (remove-text-properties start end (list property) object)) | ||
| 1102 | |||
| 1103 | ;; For consistency: maybe this should be called `remove-single-property' like | ||
| 1104 | ;; `next-single-property-change' (not `next-single-text-property-change'), etc. | ||
| 1105 | ;(defun remove-single-text-property (start end prop value &optional object) | ||
| 1106 | ; "Remove a specific property value from text from START to END. | ||
| 1107 | ;Arguments PROP and VALUE specify the property and value to remove. The | ||
| 1108 | ;resulting property values are not equal to VALUE nor lists containing VALUE. | ||
| 1109 | ;Optional argument OBJECT is the string or buffer containing the text." | ||
| 1110 | ; (let ((start (text-property-not-all start end prop nil object)) next prev) | ||
| 1111 | ; (while start | ||
| 1112 | ; (setq next (next-single-property-change start prop object end) | ||
| 1113 | ; prev (get-text-property start prop object)) | ||
| 1114 | ; (cond ((and (symbolp prev) (eq value prev)) | ||
| 1115 | ; (remove-text-property start next prop object)) | ||
| 1116 | ; ((and (listp prev) (memq value prev)) | ||
| 1117 | ; (let ((new (delq value prev))) | ||
| 1118 | ; (cond ((null new) | ||
| 1119 | ; (remove-text-property start next prop object)) | ||
| 1120 | ; ((= (length new) 1) | ||
| 1121 | ; (put-text-property start next prop (car new) object)) | ||
| 1122 | ; (t | ||
| 1123 | ; (put-text-property start next prop new object)))))) | ||
| 1124 | ; (setq start (text-property-not-all next end prop nil object))))) | ||
| 1118 | 1125 | ||
| 1119 | ;;; Regexp fontification functions. | 1126 | ;;; Regexp fontification functions. |
| 1120 | 1127 | ||
| @@ -1137,16 +1144,13 @@ HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'." | |||
| 1137 | (put-text-property start end 'face (eval (nth 1 highlight)))) | 1144 | (put-text-property start end 'face (eval (nth 1 highlight)))) |
| 1138 | ((eq override 'prepend) | 1145 | ((eq override 'prepend) |
| 1139 | ;; Prepend to existing fontification. | 1146 | ;; Prepend to existing fontification. |
| 1140 | (font-lock-prepend-text-property start end 'face | 1147 | (font-lock-prepend-text-property start end 'face (eval (nth 1 highlight)))) |
| 1141 | (eval (nth 1 highlight)))) | ||
| 1142 | ((eq override 'append) | 1148 | ((eq override 'append) |
| 1143 | ;; Append to existing fontification. | 1149 | ;; Append to existing fontification. |
| 1144 | (font-lock-append-text-property start end 'face | 1150 | (font-lock-append-text-property start end 'face (eval (nth 1 highlight)))) |
| 1145 | (eval (nth 1 highlight)))) | ||
| 1146 | ((eq override 'keep) | 1151 | ((eq override 'keep) |
| 1147 | ;; Keep existing fontification. | 1152 | ;; Keep existing fontification. |
| 1148 | (font-lock-fillin-text-property start end 'face | 1153 | (font-lock-fillin-text-property start end 'face (eval (nth 1 highlight))))))) |
| 1149 | (eval (nth 1 highlight))))))) | ||
| 1150 | 1154 | ||
| 1151 | (defsubst font-lock-fontify-anchored-keywords (keywords limit) | 1155 | (defsubst font-lock-fontify-anchored-keywords (keywords limit) |
| 1152 | "Fontify according to KEYWORDS until LIMIT. | 1156 | "Fontify according to KEYWORDS until LIMIT. |
| @@ -1327,13 +1331,13 @@ Sets various variables using `font-lock-defaults' (or, if nil, using | |||
| 1327 | 1331 | ||
| 1328 | ;; Colour etc. support. | 1332 | ;; Colour etc. support. |
| 1329 | 1333 | ||
| 1330 | ;; This section of code is crying out for revision. | 1334 | ;; This section of code is crying out for revision. Come on down, custom.el? |
| 1331 | 1335 | ||
| 1332 | ;; To begin with, `display-type' and `background-mode' are `frame-parameters' | 1336 | ;; To begin with, `display-type' and `background-mode' are `frame-parameters' |
| 1333 | ;; so we don't have to calculate them here anymore. But all the face stuff | 1337 | ;; so we don't have to calculate them here anymore. But all the face stuff |
| 1334 | ;; should be frame-local (and thus display-local) anyway. Because we're not | 1338 | ;; should be frame-local (and thus display-local) anyway. Because we're not |
| 1335 | ;; sure what support Emacs is going to have for general frame-local face | 1339 | ;; sure what support Emacs is going to have for general frame-local face |
| 1336 | ;; attributes, we leave this section of code as it is. For now. --sm. | 1340 | ;; attributes, we leave this section of code as it is. For now. sm. |
| 1337 | 1341 | ||
| 1338 | (defvar font-lock-display-type nil | 1342 | (defvar font-lock-display-type nil |
| 1339 | "A symbol indicating the display Emacs is running under. | 1343 | "A symbol indicating the display Emacs is running under. |
| @@ -1366,7 +1370,12 @@ specified here and used in `font-lock-keywords'. | |||
| 1366 | Subsequent element items should be the attributes for the corresponding | 1370 | Subsequent element items should be the attributes for the corresponding |
| 1367 | Font Lock mode faces. Attributes FOREGROUND and BACKGROUND should be strings | 1371 | Font Lock mode faces. Attributes FOREGROUND and BACKGROUND should be strings |
| 1368 | \(default if nil), while BOLD-P, ITALIC-P, and UNDERLINE-P should specify the | 1372 | \(default if nil), while BOLD-P, ITALIC-P, and UNDERLINE-P should specify the |
| 1369 | corresponding face attributes (yes if non-nil). | 1373 | corresponding face attributes (yes if non-nil). For example: |
| 1374 | |||
| 1375 | (setq font-lock-face-attributes '((font-lock-warning-face \"HotPink\" nil t t) | ||
| 1376 | (font-lock-comment-face \"Red\"))) | ||
| 1377 | |||
| 1378 | in your ~/.emacs makes a garish bold-italic warning face and red comment face. | ||
| 1370 | 1379 | ||
| 1371 | Emacs uses default attributes based on display type and background brightness. | 1380 | Emacs uses default attributes based on display type and background brightness. |
| 1372 | See variables `font-lock-display-type' and `font-lock-background-mode'. | 1381 | See variables `font-lock-display-type' and `font-lock-background-mode'. |
| @@ -1533,9 +1542,9 @@ the face is also set; its value is the face name." | |||
| 1533 | ;;; Various regexp information shared by several modes. | 1542 | ;;; Various regexp information shared by several modes. |
| 1534 | ;;; Information specific to a single mode should go in its load library. | 1543 | ;;; Information specific to a single mode should go in its load library. |
| 1535 | 1544 | ||
| 1536 | ;; The C/C++/Objective-C/Java support is in cc-font.el loaded by cc-mode.el. | 1545 | ;; Font Lock support for C, C++, Objective-C and Java modes will one day be in |
| 1537 | ;; The below function should stay in font-lock.el, since it is used by many | 1546 | ;; cc-font.el (and required by cc-mode.el). However, the below function should |
| 1538 | ;; other libraries. | 1547 | ;; stay in font-lock.el, since it is used by other libraries. sm. |
| 1539 | 1548 | ||
| 1540 | (defun font-lock-match-c-style-declaration-item-and-skip-to-next (limit) | 1549 | (defun font-lock-match-c-style-declaration-item-and-skip-to-next (limit) |
| 1541 | "Match, and move over, any declaration/definition item after point. | 1550 | "Match, and move over, any declaration/definition item after point. |
| @@ -1774,7 +1783,7 @@ words (and words conforming to the Java id spec) are treated as type names.") | |||
| 1774 | ;; road. But we know our destiny. And our future. For we must not rest. | 1783 | ;; road. But we know our destiny. And our future. For we must not rest. |
| 1775 | ;; There are more tokens to overload, more shoehorn, more methodologies. But | 1784 | ;; There are more tokens to overload, more shoehorn, more methodologies. But |
| 1776 | ;; more is a plus! [Ha ha ha.] And more means plus! [Ho ho ho.] The future | 1785 | ;; more is a plus! [Ha ha ha.] And more means plus! [Ho ho ho.] The future |
| 1777 | ;; is C++! [Ohhh!] The Third Millennium Award will be ours! [Roar.] | 1786 | ;; is C++! [Ohhh!] The Third Millennium Award... Will be ours! [Roar.] |
| 1778 | 1787 | ||
| 1779 | (defconst c-font-lock-keywords-1 nil | 1788 | (defconst c-font-lock-keywords-1 nil |
| 1780 | "Subdued level highlighting for C mode.") | 1789 | "Subdued level highlighting for C mode.") |
| @@ -1925,7 +1934,7 @@ See also `c++-font-lock-extra-types'.") | |||
| 1925 | (when (looking-at (eval-when-compile | 1934 | (when (looking-at (eval-when-compile |
| 1926 | (concat "[ \t*&]*\\(\\sw+\\)" | 1935 | (concat "[ \t*&]*\\(\\sw+\\)" |
| 1927 | "\\(<\\(\\sw+\\)[ \t*&]*>\\)?" | 1936 | "\\(<\\(\\sw+\\)[ \t*&]*>\\)?" |
| 1928 | "\\(::\\**\\(\\sw+\\)\\)?" | 1937 | "\\(::\\*?\\(\\sw+\\)\\)?" |
| 1929 | "[ \t]*\\((\\)?"))) | 1938 | "[ \t]*\\((\\)?"))) |
| 1930 | (save-match-data | 1939 | (save-match-data |
| 1931 | (condition-case nil | 1940 | (condition-case nil |
| @@ -1957,7 +1966,7 @@ See also `c++-font-lock-extra-types'.") | |||
| 1957 | "+=" "-=" "*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" | 1966 | "+=" "-=" "*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" |
| 1958 | ">>=" "<<=" "==" "!=" "<=" ">=" "&&" "||" "++" "--" | 1967 | ">>=" "<<=" "==" "!=" "<=" ">=" "&&" "||" "++" "--" |
| 1959 | "->*" "," "->" "[]" "()") | 1968 | "->*" "," "->" "[]" "()") |
| 1960 | (function (lambda (a b) (> (length a) (length b)))))) | 1969 | #'(lambda (a b) (> (length a) (length b))))) |
| 1961 | "\\|")) | 1970 | "\\|")) |
| 1962 | (c++-type-types | 1971 | (c++-type-types |
| 1963 | ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" | 1972 | ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" |
| @@ -1977,7 +1986,7 @@ See also `c++-font-lock-extra-types'.") | |||
| 1977 | "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 12 ()s deep. | 1986 | "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 12 ()s deep. |
| 1978 | c++-font-lock-extra-types) | 1987 | c++-font-lock-extra-types) |
| 1979 | "\\|")) | 1988 | "\\|")) |
| 1980 | (c++-type-suffix "\\(<\\(\\sw+\\)[ \t*&]*>\\)?\\(::\\**\\(\\sw+\\)\\)?") | 1989 | (c++-type-suffix "\\(<\\(\\sw+\\)[ \t*&]*>\\)?\\(::\\*?\\(\\sw+\\)\\)?") |
| 1981 | (c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix)) | 1990 | (c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix)) |
| 1982 | ) | 1991 | ) |
| 1983 | (setq c++-font-lock-keywords-1 | 1992 | (setq c++-font-lock-keywords-1 |