comparison lisp/font-lock.el @ 221:6c0ae1f9357f r20-4b9

Import from CVS: tag r20-4b9
author cvs
date Mon, 13 Aug 2007 10:10:02 +0200
parents 262b8bb4a523
children 0e522484dd2a
comparison
equal deleted inserted replaced
220:04f4bca7b601 221:6c0ae1f9357f
151 documentation strings in another, and so on. 151 documentation strings in another, and so on.
152 152
153 Comments will be displayed in `font-lock-comment-face'. 153 Comments will be displayed in `font-lock-comment-face'.
154 Strings will be displayed in `font-lock-string-face'. 154 Strings will be displayed in `font-lock-string-face'.
155 Doc strings will be displayed in `font-lock-doc-string-face'. 155 Doc strings will be displayed in `font-lock-doc-string-face'.
156 Function and variable names (in their defining forms) will be 156 Function and variable names (in their defining forms) will be displayed
157 displayed in `font-lock-function-name-face'. 157 in `font-lock-function-name-face'.
158 Reserved words will be displayed in `font-lock-keyword-face'." 158 Reserved words will be displayed in `font-lock-keyword-face'.
159 Preprocessor conditionals will be displayed in `font-lock-preprocessor-face'."
159 :group 'languages) 160 :group 'languages)
160 161
161 (defgroup font-lock-faces nil 162 (defgroup font-lock-faces nil
162 "Faces used by the font-lock package." 163 "Faces used by the font-lock package."
163 :group 'font-lock 164 :group 'font-lock
498 "Non-nil means use this function to move back outside of a syntactic block. 499 "Non-nil means use this function to move back outside of a syntactic block.
499 If this is nil, the beginning of the buffer is used (in the worst case). 500 If this is nil, the beginning of the buffer is used (in the worst case).
500 This is normally set via `font-lock-defaults'.") 501 This is normally set via `font-lock-defaults'.")
501 (make-variable-buffer-local 'font-lock-beginning-of-syntax-function) 502 (make-variable-buffer-local 'font-lock-beginning-of-syntax-function)
502 503
504 (defvar font-lock-fontify-buffer-function 'font-lock-default-fontify-buffer
505 "Function to use for fontifying the buffer.
506 This is normally set via `font-lock-defaults'.")
507
508 (defvar font-lock-unfontify-buffer-function 'font-lock-default-unfontify-buffer
509 "Function to use for unfontifying the buffer.
510 This is used when turning off Font Lock mode.
511 This is normally set via `font-lock-defaults'.")
512
513 (defvar font-lock-fontify-region-function 'font-lock-default-fontify-region
514 "Function to use for fontifying a region.
515 It should take two args, the beginning and end of the region, and an optional
516 third arg VERBOSE. If non-nil, the function should print status messages.
517 This is normally set via `font-lock-defaults'.")
518
519 (defvar font-lock-unfontify-region-function 'font-lock-default-unfontify-region
520 "Function to use for unfontifying a region.
521 It should take two args, the beginning and end of the region.
522 This is normally set via `font-lock-defaults'.")
523
524 (defvar font-lock-inhibit-thing-lock nil
525 "List of Font Lock mode related modes that should not be turned on.
526 Currently, valid mode names as `fast-lock-mode' and `lazy-lock-mode'.
527 This is normally set via `font-lock-defaults'.")
528
503 ;;;###autoload 529 ;;;###autoload
504 (defvar font-lock-mode nil) ; for modeline 530 (defvar font-lock-mode nil) ; for modeline
505 (defvar font-lock-fontified nil) ; whether we have hacked this buffer 531 (defvar font-lock-fontified nil) ; whether we have hacked this buffer
506 (put 'font-lock-fontified 'permanent-local t) 532 (put 'font-lock-fontified 'permanent-local t)
507 533
628 654
629 ;; #### FSF has font-lock-builtin-face. 655 ;; #### FSF has font-lock-builtin-face.
630 656
631 (defface font-lock-preprocessor-face 657 (defface font-lock-preprocessor-face
632 '((((class color) (background dark)) (:foreground "steelblue1")) 658 '((((class color) (background dark)) (:foreground "steelblue1"))
633 (((class color) (background black)) (:foreground "blue3")) 659 (((class color) (background light)) (:foreground "blue3"))
634 (t (:underline t))) 660 (t (:underline t)))
635 "Font Lock Mode face used to highlight preprocessor conditionals." 661 "Font Lock Mode face used to highlight preprocessor conditionals."
636 :group 'font-lock-faces) 662 :group 'font-lock-faces)
637 663
638 ;; #### Currently unused 664 ;; #### Currently unused
819 ;;;###autoload 845 ;;;###autoload
820 (defun turn-off-font-lock () 846 (defun turn-off-font-lock ()
821 "Unconditionally turn off Font Lock mode." 847 "Unconditionally turn off Font Lock mode."
822 (font-lock-mode 0)) 848 (font-lock-mode 0))
823 849
850 ;;; FSF has here:
851
852 ;; support for add-keywords, global-font-lock-mode and
853 ;; font-lock-support-mode (unified support for various *-lock modes).
854
855
856 ;; Fontification functions.
857
858 ;; We first define some defsubsts to encapsulate the way we add
859 ;; faces to a region of text. I am planning on modifying the
860 ;; text-property mechanism so that multiple independent classes
861 ;; of text properties can exist. That way, for example, ediff's
862 ;; face text properties don't interfere with font lock's face
863 ;; text properties. Due to the XEmacs implementation of text
864 ;; properties in terms of extents, doing this is fairly trivial:
865 ;; instead of using the `text-prop' property, you just use a
866 ;; specified property.
867
868 (defsubst font-lock-set-face (start end face)
869 ;; Set the face on the characters in the range.
870 (put-nonduplicable-text-property start end 'face face)
871 (put-nonduplicable-text-property start end 'font-lock t))
872
873 (defsubst font-lock-remove-face (start end)
874 ;; Remove any syntax highlighting on the characters in the range.
875 (put-nonduplicable-text-property start end 'face nil)
876 (put-nonduplicable-text-property start end 'font-lock nil))
877
878 (defsubst font-lock-any-faces-p (start end)
879 ;; Return non-nil if we've put any syntax highlighting on
880 ;; the characters in the range.
881 ;;
882 ;; used to look for 'text-prop property, but this has problems if
883 ;; you put any other text properties in the vicinity. Simon
884 ;; Marshall suggested looking for the 'face property (this is what
885 ;; FSF Emacs does) but that's equally bogus. Only reliable way is
886 ;; for font-lock to specially mark its extents.
887 ;;
888 ;; FSF's (equivalent) definition of this defsubst would be
889 ;; (text-property-not-all start end 'font-lock nil)
890 ;;
891 ;; Perhaps our `map-extents' is faster than our definition
892 ;; of `text-property-not-all'. #### If so, `text-property-not-all'
893 ;; should be fixed ...
894 ;;
895 (map-extents 'extent-property (current-buffer) start (1- end) 'font-lock))
896
897
898 ;; Fontification functions.
899
900 ;; Rather than the function, e.g., `font-lock-fontify-region' containing the
901 ;; code to fontify a region, the function runs the function whose name is the
902 ;; value of the variable, e.g., `font-lock-fontify-region-function'. Normally,
903 ;; the value of this variable is, e.g., `font-lock-default-fontify-region'
904 ;; which does contain the code to fontify a region. However, the value of the
905 ;; variable could be anything and thus, e.g., `font-lock-fontify-region' could
906 ;; do anything. The indirection of the fontification functions gives major
907 ;; modes the capability of modifying the way font-lock.el fontifies. Major
908 ;; modes can modify the values of, e.g., `font-lock-fontify-region-function',
909 ;; via the variable `font-lock-defaults'.
910 ;;
911 ;; For example, Rmail mode sets the variable `font-lock-defaults' so that
912 ;; font-lock.el uses its own function for buffer fontification. This function
913 ;; makes fontification be on a message-by-message basis and so visiting an
914 ;; RMAIL file is much faster. A clever implementation of the function might
915 ;; fontify the headers differently than the message body. (It should, and
916 ;; correspondingly for Mail mode, but I can't be bothered to do the work. Can
917 ;; you?) This hints at a more interesting use...
918 ;;
919 ;; Languages that contain text normally contained in different major modes
920 ;; could define their own fontification functions that treat text differently
921 ;; depending on its context. For example, Perl mode could arrange that here
922 ;; docs are fontified differently than Perl code. Or Yacc mode could fontify
923 ;; rules one way and C code another. Neat!
924 ;;
925 ;; A further reason to use the fontification indirection feature is when the
926 ;; default syntactual fontification, or the default fontification in general,
927 ;; is not flexible enough for a particular major mode. For example, perhaps
928 ;; comments are just too hairy for `font-lock-fontify-syntactically-region' to
929 ;; cope with. You need to write your own version of that function, e.g.,
930 ;; `hairy-fontify-syntactically-region', and make your own version of
931 ;; `hairy-fontify-region' call that function before calling
932 ;; `font-lock-fontify-keywords-region' for the normal regexp fontification
933 ;; pass. And Hairy mode would set `font-lock-defaults' so that font-lock.el
934 ;; would call your region fontification function instead of its own. For
935 ;; example, TeX modes could fontify {\foo ...} and \bar{...} etc. multi-line
936 ;; directives correctly and cleanly. (It is the same problem as fontifying
937 ;; multi-line strings and comments; regexps are not appropriate for the job.)
938
824 ;;;###autoload 939 ;;;###autoload
825 (defun font-lock-fontify-buffer () 940 (defun font-lock-fontify-buffer ()
826 "Fontify the current buffer the way `font-lock-mode' would. 941 "Fontify the current buffer the way `font-lock-mode' would.
827 See `font-lock-mode' for details. 942 See `font-lock-mode' for details.
828 943
829 This can take a while for large buffers." 944 This can take a while for large buffers."
945 (interactive)
946 (let ((font-lock-verbose (or font-lock-verbose (interactive-p))))
947 (funcall font-lock-fontify-buffer-function)))
948
949 (defun font-lock-unfontify-buffer ()
950 (funcall font-lock-unfontify-buffer-function))
951
952 (defun font-lock-fontify-region (beg end &optional loudly)
953 (funcall font-lock-fontify-region-function beg end loudly))
954
955 (defun font-lock-unfontify-region (beg end &optional loudly)
956 (funcall font-lock-unfontify-region-function beg end loudly))
957
958 ;; #### In these functions, the FSF is careful to do
959 ;; (save-restriction
960 ;; (widen)
961 ;; before anything else. Should we copy?
962 (defun font-lock-default-fontify-buffer ()
830 (interactive) 963 (interactive)
831 (let ((was-on font-lock-mode) 964 (let ((was-on font-lock-mode)
832 (font-lock-verbose (or font-lock-verbose (interactive-p))) 965 (font-lock-verbose (or font-lock-verbose (interactive-p)))
833 (font-lock-message-threshold 0) 966 (font-lock-message-threshold 0)
834 (aborted nil)) 967 (aborted nil))
859 (font-lock-mode 0))) 992 (font-lock-mode 0)))
860 (set (make-local-variable 'font-lock-fontified) t) 993 (set (make-local-variable 'font-lock-fontified) t)
861 (when (and aborted font-lock-verbose) 994 (when (and aborted font-lock-verbose)
862 (lmessage 'command "Fontifying %s... aborted." (buffer-name)))) 995 (lmessage 'command "Fontifying %s... aborted." (buffer-name))))
863 (run-hooks 'font-lock-after-fontify-buffer-hook)) 996 (run-hooks 'font-lock-after-fontify-buffer-hook))
864 997
865 ;; Fontification functions. 998 (defun font-lock-default-unfontify-buffer ()
866 999 (font-lock-unfontify-region (point-min) (point-max))
867 ;; We first define some defsubsts to encapsulate the way we add 1000 (set (make-local-variable 'font-lock-fontified) nil))
868 ;; faces to a region of text. I am planning on modifying the 1001
869 ;; text-property mechanism so that multiple independent classes 1002 ;; This used to be `font-lock-fontify-region', and before that,
870 ;; of text properties can exist. That way, for example, ediff's 1003 ;; `font-lock-fontify-region' used to be the name used for what is now
871 ;; face text properties don't interfere with font lock's face 1004 ;; `font-lock-fontify-syntactically-region'.
872 ;; text properties. Due to the XEmacs implementation of text 1005 (defun font-lock-default-fontify-region (beg end &optional loudly)
873 ;; properties in terms of extents, doing this is fairly trivial:
874 ;; instead of using the `text-prop' property, you just use a
875 ;; specified property.
876
877 (defsubst font-lock-set-face (start end face)
878 ;; Set the face on the characters in the range.
879 (put-nonduplicable-text-property start end 'face face)
880 (put-nonduplicable-text-property start end 'font-lock t))
881
882 (defsubst font-lock-remove-face (start end)
883 ;; Remove any syntax highlighting on the characters in the range.
884 (put-nonduplicable-text-property start end 'face nil)
885 (put-nonduplicable-text-property start end 'font-lock nil))
886
887 (defsubst font-lock-any-faces-p (start end)
888 ;; Return non-nil if we've put any syntax highlighting on
889 ;; the characters in the range.
890 ;;
891 ;; used to look for 'text-prop property, but this has problems if
892 ;; you put any other text properties in the vicinity. Simon
893 ;; Marshall suggested looking for the 'face property (this is what
894 ;; FSF Emacs does) but that's equally bogus. Only reliable way is
895 ;; for font-lock to specially mark its extents.
896 ;;
897 ;; FSF's (equivalent) definition of this defsubst would be
898 ;; (text-property-not-all start end 'font-lock nil)
899 ;;
900 ;; Perhaps our `map-extents' is faster than our definition
901 ;; of `text-property-not-all'. #### If so, `text-property-not-all'
902 ;; should be fixed ...
903 ;;
904 (map-extents 'extent-property (current-buffer) start (1- end) 'font-lock))
905
906
907 ;; Fontification functions.
908
909 ;; We use this wrapper. However, `font-lock-fontify-region' used to be the
910 ;; name used for `font-lock-fontify-syntactically-region', so a change isn't
911 ;; back-compatible. But you shouldn't be calling these directly, should you?
912 (defun font-lock-fontify-region (beg end &optional loudly)
913 (let ((modified (buffer-modified-p)) 1006 (let ((modified (buffer-modified-p))
914 (buffer-undo-list t) (inhibit-read-only t) 1007 (buffer-undo-list t) (inhibit-read-only t)
915 (old-syntax-table (syntax-table)) 1008 (old-syntax-table (syntax-table))
916 buffer-file-name buffer-file-truename) 1009 buffer-file-name buffer-file-truename)
917 (unwind-protect 1010 (unwind-protect
933 ; (let ((state (parse-partial-sexp beg end nil nil 1026 ; (let ((state (parse-partial-sexp beg end nil nil
934 ; font-lock-cache-state))) 1027 ; font-lock-cache-state)))
935 ; (or (nth 4 state) (nth 7 state)))) 1028 ; (or (nth 4 state) (nth 7 state))))
936 ; (font-lock-fontify-keywords-region beg end)) 1029 ; (font-lock-fontify-keywords-region beg end))
937 1030
938 (defun font-lock-unfontify-region (beg end &optional maybe-loudly) 1031 (defun font-lock-default-unfontify-region (beg end &optional maybe-loudly)
939 (when (and maybe-loudly font-lock-verbose 1032 (when (and maybe-loudly font-lock-verbose
940 (>= (- end beg) font-lock-message-threshold)) 1033 (>= (- end beg) font-lock-message-threshold))
941 (lmessage 'progress "Fontifying %s..." (buffer-name))) 1034 (lmessage 'progress "Fontifying %s..." (buffer-name)))
942 (let ((modified (buffer-modified-p)) 1035 (let ((modified (buffer-modified-p))
943 (buffer-undo-list t) (inhibit-read-only t) 1036 (buffer-undo-list t) (inhibit-read-only t)
1435 ;; If the buffer has just been reverted, normally that turns off 1528 ;; If the buffer has just been reverted, normally that turns off
1436 ;; Font Lock mode. So turn the mode back on if necessary. 1529 ;; Font Lock mode. So turn the mode back on if necessary.
1437 (defalias 'font-lock-revert-cleanup 'turn-on-font-lock) 1530 (defalias 'font-lock-revert-cleanup 'turn-on-font-lock)
1438 1531
1439 1532
1533 ;; Various functions.
1534
1440 (defun font-lock-compile-keywords (&optional keywords) 1535 (defun font-lock-compile-keywords (&optional keywords)
1441 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD 1536 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD
1442 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. 1537 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string.
1443 (let ((keywords (or keywords font-lock-keywords))) 1538 (let ((keywords (or keywords font-lock-keywords)))
1444 (setq font-lock-keywords 1539 (setq font-lock-keywords
1736 "window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|un\\(less\\|" 1831 "window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|un\\(less\\|"
1737 "wind-protect\\)\\|w\\(h\\(en\\|ile\\)\\|ith-\\(current-buffer\\|" 1832 "wind-protect\\)\\|w\\(h\\(en\\|ile\\)\\|ith-\\(current-buffer\\|"
1738 "output-to-string\\|string-as-buffer-contents\\|temp-\\(buffer\\|" 1833 "output-to-string\\|string-as-buffer-contents\\|temp-\\(buffer\\|"
1739 "file\\)\\)\\)" 1834 "file\\)\\)\\)"
1740 "\\)\\>") 1) 1835 "\\)\\>") 1)
1836 ;;
1837 ;; Feature symbols as references.
1838 '("(\\(featurep\\|provide\\|require\\)\\>[ \t']*\\(\\sw+\\)?"
1839 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
1741 ;; 1840 ;;
1742 ;; Words inside \\[] tend to be for `substitute-command-keys'. 1841 ;; Words inside \\[] tend to be for `substitute-command-keys'.
1743 '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend) 1842 '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend)
1744 ;; 1843 ;;
1745 ;; Words inside `' tend to be symbol names. 1844 ;; Words inside `' tend to be symbol names.
2137 (defvar c-font-lock-keywords c-font-lock-keywords-1 2236 (defvar c-font-lock-keywords c-font-lock-keywords-1
2138 "Default expressions to highlight in C mode.") 2237 "Default expressions to highlight in C mode.")
2139 2238
2140 (defvar c++-font-lock-keywords c++-font-lock-keywords-1 2239 (defvar c++-font-lock-keywords c++-font-lock-keywords-1
2141 "Default expressions to highlight in C++ mode.") 2240 "Default expressions to highlight in C++ mode.")
2142 2241
2143 ;; The previous version, before replacing it with the FSF version. 2242 ;;; Java.
2144 ;(defconst c-font-lock-keywords-1 nil 2243
2145 ; "For consideration as a value of `c-font-lock-keywords'. 2244 ;; Java support has been written by XEmacs people, and it's apparently
2146 ;This does fairly subdued highlighting.") 2245 ;; totally divergent from the FSF. I don't know if it's better or
2147 ; 2246 ;; worse, so I'm leaving it in until someone convinces me the FSF
2148 ;(defconst c-font-lock-keywords-2 nil 2247 ;; version is better. --hniksic
2149 ; "For consideration as a value of `c-font-lock-keywords'.
2150 ;This does a lot more highlighting.")
2151 ;
2152 ;(let ((storage "auto\\|extern\\|register\\|static\\|volatile")
2153 ; (prefixes "unsigned\\|short\\|long\\|const")
2154 ; (types (concat "int\\|long\\|char\\|float\\|double\\|void\\|struct\\|"
2155 ; "union\\|enum\\|typedef"))
2156 ; (ctoken "\\(\\sw\\|\\s_\\|[:~*&]\\)+")
2157 ; )
2158 ; (setq c-font-lock-keywords-1 (purecopy
2159 ; (list
2160 ; ;; fontify preprocessor directives.
2161 ; '("^#[ \t]*[a-z]+" . font-lock-preprocessor-face)
2162 ; ;;
2163 ; ;; fontify names being defined.
2164 ; '("^#[ \t]*\\(define\\|undef\\)[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 2
2165 ; font-lock-function-name-face)
2166 ; ;;
2167 ; ;; fontify other preprocessor lines.
2168 ; '("^#[ \t]*\\(if\\|ifn?def\\|elif\\)[ \t]+\\([^\n]+\\)"
2169 ; 2 font-lock-function-name-face t)
2170 ; ;;
2171 ; ;; fontify the filename in #include <...>
2172 ; ;; don't need to do this for #include "..." because those were
2173 ; ;; already fontified as strings by the syntactic pass.
2174 ; ;; (Changed to not include the <> in the face, since "" aren't.)
2175 ; '("^#[ \t]*include[ \t]+<\\([^>\"\n]+\\)>" 1 font-lock-string-face)
2176 ; ;;
2177 ; ;; fontify the names of functions being defined.
2178 ; ;; I think this should be fast because it's anchored at bol, but it's not.
2179 ; (list (concat
2180 ; "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no
2181 ; "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right?
2182 ; "\\(" ctoken "[ \t]+\\)?"
2183 ; "\\([*&]+[ \t]*\\)?" ; pointer
2184 ; "\\(" ctoken "\\)[ \t]*(") ; name
2185 ; 8 'font-lock-function-name-face)
2186 ; ;;
2187 ; ;; This is faster but not by much. I don't see why not.
2188 ;; (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
2189 ; ;;
2190 ; ;; Fontify structure names (in structure definition form).
2191 ; (list (concat "^\\(typedef[ \t]+struct\\|struct\\|static[ \t]+struct\\)"
2192 ; "[ \t]+\\(" ctoken "\\)[ \t]*\\(\{\\|$\\)")
2193 ; 2 'font-lock-function-name-face)
2194 ; ;;
2195 ; ;; Fontify case clauses. This is fast because its anchored on the left.
2196 ; '("case[ \t]+\\(\\(\\sw\\|\\s_\\)+\\):". 1)
2197 ; '("\\<\\(default\\):". 1)
2198 ; )))
2199 ;
2200 ; (setq c-font-lock-keywords-2 (purecopy
2201 ; (append c-font-lock-keywords-1
2202 ; (list
2203 ; ;;
2204 ; ;; fontify all storage classes and type specifiers
2205 ; ;; types should be surrounded by non alphanumerics (Raymond Toy)
2206 ; (cons (concat "\\<\\(" storage "\\)\\>") 'font-lock-type-face)
2207 ; (list (concat "\\([^a-zA-Z0-9_]\\|^\\)\\("
2208 ; types
2209 ; "\\)\\([^a-zA-Z0-9_]\\|$\\)")
2210 ; 2 'font-lock-type-face)
2211 ; ;; fontify the prefixes now. The types should have been fontified
2212 ; ;; previously.
2213 ; (list (concat "\\<\\(" prefixes "\\)[ \t]+\\(" types "\\)\\>")
2214 ; 1 'font-lock-type-face)
2215 ; ;;
2216 ; ;; fontify all builtin tokens
2217 ; (cons (concat
2218 ; "[ \t]\\("
2219 ; (mapconcat 'identity
2220 ; '("for" "while" "do" "return" "goto" "case" "break" "switch"
2221 ; "if" "then" "else if" "else" "return" "continue" "default"
2222 ; )
2223 ; "\\|")
2224 ; "\\)[ \t\n(){};,]")
2225 ; 1)
2226 ; ;;
2227 ; ;; fontify case targets and goto-tags. This is slow because the
2228 ; ;; expression is anchored on the right.
2229 ; "\\(\\(\\sw\\|\\s_\\)+\\):"
2230 ; ;;
2231 ; ;; Fontify variables declared with structures, or typedef names.
2232 ; '("}[ \t*]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t]*[,;]"
2233 ; 1 font-lock-function-name-face)
2234 ; ;;
2235 ; ;; Fontify global variables without a type.
2236 ;; '("^\\([_a-zA-Z0-9:~*]+\\)[ \t]*[[;={]" 1 font-lock-function-name-face)
2237 ;
2238 ; ))))
2239 ; )
2240 ;
2241 ;
2242 ;;; default to the gaudier variety?
2243 ;;(defconst c-font-lock-keywords c-font-lock-keywords-2
2244 ;; "Additional expressions to highlight in C mode.")
2245 ;(defconst c-font-lock-keywords c-font-lock-keywords-1
2246 ; "Additional expressions to highlight in C mode.")
2247 ;
2248 ;(defconst c++-font-lock-keywords-1 nil
2249 ; "For consideration as a value of `c++-font-lock-keywords'.
2250 ;This does fairly subdued highlighting.")
2251 ;
2252 ;(defconst c++-font-lock-keywords-2 nil
2253 ; "For consideration as a value of `c++-font-lock-keywords'.
2254 ;This does a lot more highlighting.")
2255 ;
2256 ;(let ((ctoken "\\(\\sw\\|\\s_\\|[:~*&]\\)+")
2257 ; (c++-types (concat "complex\\|public\\|private\\|protected\\|virtual\\|"
2258 ; "friend\\|inline"))
2259 ; c++-font-lock-keywords-internal-1
2260 ; c++-font-lock-keywords-internal-2
2261 ; )
2262 ; (setq c++-font-lock-keywords-internal-1 (purecopy
2263 ; (list
2264 ; ;;
2265 ; ;; fontify friend operator functions
2266 ; '("^\\(operator[^(]*\\)(" 1 font-lock-function-name-face)
2267 ; '("^\\(operator[ \\t]*([ \\t]*)[^(]*\\)(" 1 font-lock-function-name-face)
2268 ;
2269 ; ;; fontify the class names only in the definition
2270 ; (list (concat "^class[ \t]+" ctoken "[ \t\n{: ;]") 1
2271 ; 'font-lock-function-name-face)
2272 ;
2273 ; (list (concat
2274 ; "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no
2275 ; "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right?
2276 ; "\\(" ctoken "[ \t]+\\)?"
2277 ; "\\(\\*+[ \t]*\\)?" ; pointer
2278 ; "\\(" ctoken "\\(::\\)?~?\\(\\(operator[ \t]*[^ \ta-zA-Z]+\\)\\|"
2279 ; ctoken "\\)\\)[ \t]*(") ; name
2280 ; 8 'font-lock-function-name-face t)
2281 ; )))
2282 ;
2283 ; (setq c++-font-lock-keywords-internal-2 (purecopy
2284 ; (list
2285 ; ;; fontify extra c++ storage classes and type specifiers
2286 ; (cons (concat "\\<\\(" c++-types "\\)\\>") 'font-lock-type-face)
2287 ;
2288 ; ;;special check for class
2289 ; '("^\\(\\<\\|template[ \t]+<[ \t]*\\)\\(class\\)[ \t\n]+" 2
2290 ; font-lock-type-face)
2291 ;
2292 ; ;; special handling of template
2293 ; "^\\(template\\)\\>"
2294 ; ;; fontify extra c++ builtin tokens
2295 ; (cons (concat
2296 ; "[ \t]\\("
2297 ; (mapconcat 'identity
2298 ; '("asm" "catch" "throw" "try" "delete" "new" "operator"
2299 ; "sizeof" "this"
2300 ; )
2301 ; "\\|")
2302 ; "\\)[ \t\n(){};,]")
2303 ; 1)
2304 ; )))
2305 ;
2306 ; (setq c++-font-lock-keywords-1 (purecopy
2307 ; (append c-font-lock-keywords-1 c++-font-lock-keywords-internal-1)))
2308 ;
2309 ; (setq c++-font-lock-keywords-2 (purecopy
2310 ; (append c-font-lock-keywords-2 c++-font-lock-keywords-internal-1
2311 ; c++-font-lock-keywords-internal-2)))
2312 ; )
2313 ;
2314 ;(defconst c++-font-lock-keywords c++-font-lock-keywords-1
2315 ; "Additional expressions to highlight in C++ mode.")
2316
2317 ;; Java support from Anders Lindgren and Bob Weiner
2318 2248
2319 (defconst java-font-lock-keywords-1 nil 2249 (defconst java-font-lock-keywords-1 nil
2320 "For consideration as a value of `java-font-lock-keywords'. 2250 "For consideration as a value of `java-font-lock-keywords'.
2321 This does fairly subdued highlighting.") 2251 This does fairly subdued highlighting.")
2322 2252
2611 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables. 2541 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables.
2612 ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" 2542 ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
2613 3 (if (match-beginning 2) 'bold 'italic) keep)) 2543 3 (if (match-beginning 2) 'bold 'italic) keep))
2614 "Default expressions to highlight in TeX modes.") 2544 "Default expressions to highlight in TeX modes.")
2615 2545
2616 ;; The previous version, before replacing it with the FSF version.
2617 ;(defconst tex-font-lock-keywords (purecopy
2618 ; (list
2619 ; ;; Lionel Mallet: Thu Oct 14 09:41:38 1993
2620 ; ;; I've added an exit condition to the regexp below, and the other
2621 ; ;; regexps for the second part.
2622 ; ;; What would be useful here is something like:
2623 ; ;; ("\\(\\\\\\w+\\)\\({\\(\\w+\\)}\\)+" 1 font-lock-keyword-face t 3
2624 ; ;; font-lock-function-name-face t)
2625 ; '("\\(\\\\\\w+\\)\\W" 1 font-lock-keyword-face t)
2626 ; '("\\(\\\\\\w+\\){\\([^}\n]+\\)}" 2 font-lock-function-name-face t)
2627 ; '("\\(\\\\\\w+\\){\\(\\w+\\)}{\\(\\w+\\)}" 3
2628 ; font-lock-function-name-face t)
2629 ; '("\\(\\\\\\w+\\){\\(\\w+\\)}{\\(\\w+\\)}{\\(\\w+\\)}" 4
2630 ; font-lock-function-name-face t)
2631 ; '("{\\\\\\(em\\|tt\\)\\([^}]+\\)}" 2 font-lock-comment-face t)
2632 ; '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t)
2633 ; '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)\\W" 1 font-lock-function-name-face t)
2634 ; ;; Lionel Mallet: Thu Oct 14 09:40:10 1993
2635 ; ;; the regexp below is useless as it is now covered by the first 2 regexps
2636 ; ;; '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}"
2637 ; ;; 2 font-lock-function-name-face t)
2638 ; '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
2639 ;; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
2640 ; ))
2641 ; "Additional expressions to highlight in TeX mode.")
2642
2643 (defconst ksh-font-lock-keywords (purecopy 2546 (defconst ksh-font-lock-keywords (purecopy
2644 (list 2547 (list
2645 '("\\(^\\|[^\$\\\]\\)#.*" . font-lock-comment-face) 2548 '("\\(^\\|[^\$\\\]\\)#.*" . font-lock-comment-face)
2646 '("\\<\\(if\\|then\\|else\\|elif\\|fi\\|case\\|esac\\|for\\|do\\|done\\|foreach\\|in\\|end\\|select\\|while\\|repeat\\|time\\|function\\|until\\|exec\\|command\\|coproc\\|noglob\\|nohup\\|nocorrect\\|source\\|autoload\\|alias\\|unalias\\|export\\|set\\|echo\\|eval\\|cd\\|log\\|compctl\\)\\>" . font-lock-keyword-face) 2549 '("\\<\\(if\\|then\\|else\\|elif\\|fi\\|case\\|esac\\|for\\|do\\|done\\|foreach\\|in\\|end\\|select\\|while\\|repeat\\|time\\|function\\|until\\|exec\\|command\\|coproc\\|noglob\\|nohup\\|nocorrect\\|source\\|autoload\\|alias\\|unalias\\|export\\|set\\|echo\\|eval\\|cd\\|log\\|compctl\\)\\>" . font-lock-keyword-face)
2647 '("\\<\\[\\[.*\\]\\]\\>" . font-lock-type-face) 2550 '("\\<\\[\\[.*\\]\\]\\>" . font-lock-type-face)