aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2001-11-18 02:10:01 +0000
committerStefan Monnier2001-11-18 02:10:01 +0000
commit2d5eba0eb7dbdaa7be591131384ea14c20167b9b (patch)
tree913348d19da75aafe1d2fe432412ccacf6e3fa4d
parentd6b3b5f4f8fcd64c1131fec3794da47eed278b4b (diff)
downloademacs-2d5eba0eb7dbdaa7be591131384ea14c20167b9b.tar.gz
emacs-2d5eba0eb7dbdaa7be591131384ea14c20167b9b.zip
(font-lock-compile-keywords): New arg `regexp'.
If set and if applicable, add a regexp to highlight defun-like text inside comments and strings. (font-lock-fontify-keywords-region): Pass that new arg. (font-lock-set-defaults): Move the code to set `font-lock-keywords' to the end and pass that new arg. (c-font-lock-keywords-2): Fix regex for labels. (font-lock-match-c++-style-declaration-item-and-skip-to-next): Make it work when LIMIT is several lines further. (c-font-lock-keywords-3, c++-font-lock-keywords-3) (objc-font-lock-keywords-3, java-font-lock-keywords-3): Use backquote and make the regexes for `int a, b, c;' work on multiple lines.
-rw-r--r--lisp/font-lock.el342
1 files changed, 184 insertions, 158 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index d68098a82f1..447f6db7d45 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1631,7 +1631,8 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM."
1631 "Fontify according to `font-lock-keywords' between START and END. 1631 "Fontify according to `font-lock-keywords' between START and END.
1632START should be at the beginning of a line." 1632START should be at the beginning of a line."
1633 (unless (eq (car font-lock-keywords) t) 1633 (unless (eq (car font-lock-keywords) t)
1634 (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords))) 1634 (setq font-lock-keywords
1635 (font-lock-compile-keywords font-lock-keywords t)))
1635 (let ((case-fold-search font-lock-keywords-case-fold-search) 1636 (let ((case-fold-search font-lock-keywords-case-fold-search)
1636 (keywords (cdr font-lock-keywords)) 1637 (keywords (cdr font-lock-keywords))
1637 (bufname (buffer-name)) (count 0) 1638 (bufname (buffer-name)) (count 0)
@@ -1677,13 +1678,33 @@ START should be at the beginning of a line."
1677 1678
1678;; Various functions. 1679;; Various functions.
1679 1680
1680(defun font-lock-compile-keywords (keywords) 1681(defun font-lock-compile-keywords (keywords &optional regexp)
1681 "Compile KEYWORDS into the form (t KEYWORD ...). 1682 "Compile KEYWORDS into the form (t KEYWORD ...).
1682Here KEYWORD is of the form (MATCHER HIGHLIGHT ...) as shown in the 1683Here KEYWORD is of the form (MATCHER HIGHLIGHT ...) as shown in the
1683`font-lock-keywords' doc string." 1684`font-lock-keywords' doc string.
1685If REGEXP is non-nil, it means these keywords are used for
1686`font-lock-keywords' rather than for `font-lock-syntactic-keywords'."
1684 (if (eq (car-safe keywords) t) 1687 (if (eq (car-safe keywords) t)
1685 keywords 1688 keywords
1686 (cons t (mapcar 'font-lock-compile-keyword keywords)))) 1689 (setq keywords (cons t (mapcar 'font-lock-compile-keyword keywords)))
1690 (if (and regexp
1691 (eq (or syntax-begin-function
1692 font-lock-beginning-of-syntax-function)
1693 'beginning-of-defun)
1694 (not beginning-of-defun-function))
1695 ;; Try to detect when a string or comment contains something that
1696 ;; looks like a defun and would thus confuse font-lock.
1697 (nconc keywords
1698 `((,(if defun-prompt-regexp
1699 (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")
1700 "^\\s(")
1701 (0
1702 (if (memq (get-text-property (point) 'face)
1703 '(font-lock-string-face font-lock-doc-face
1704 font-lock-comment-face))
1705 font-lock-warning-face)
1706 prepend)))))
1707 keywords))
1687 1708
1688(defun font-lock-compile-keyword (keyword) 1709(defun font-lock-compile-keyword (keyword)
1689 (cond ((nlistp keyword) ; MATCHER 1710 (cond ((nlistp keyword) ; MATCHER
@@ -1753,15 +1774,6 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1753 (local (cdr (assq major-mode font-lock-keywords-alist))) 1774 (local (cdr (assq major-mode font-lock-keywords-alist)))
1754 (removed-keywords 1775 (removed-keywords
1755 (cdr-safe (assq major-mode font-lock-removed-keywords-alist)))) 1776 (cdr-safe (assq major-mode font-lock-removed-keywords-alist))))
1756 ;; Regexp fontification?
1757 (set (make-local-variable 'font-lock-keywords)
1758 (font-lock-compile-keywords (font-lock-eval-keywords keywords)))
1759 ;; Local fontification?
1760 (while local
1761 (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
1762 (setq local (cdr local)))
1763 (when removed-keywords
1764 (font-lock-remove-keywords nil removed-keywords))
1765 ;; Syntactic fontification? 1777 ;; Syntactic fontification?
1766 (when (nth 1 defaults) 1778 (when (nth 1 defaults)
1767 (set (make-local-variable 'font-lock-keywords-only) t)) 1779 (set (make-local-variable 'font-lock-keywords-only) t))
@@ -1785,7 +1797,18 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1785 (nth 4 defaults))) 1797 (nth 4 defaults)))
1786 ;; Variable alist? 1798 ;; Variable alist?
1787 (dolist (x (nthcdr 5 defaults)) 1799 (dolist (x (nthcdr 5 defaults))
1788 (set (make-local-variable (car x)) (cdr x)))))) 1800 (set (make-local-variable (car x)) (cdr x)))
1801 ;; Setup `font-lock-keywords' last because its value might depend
1802 ;; on other settings (e.g. font-lock-compile-keywords uses
1803 ;; font-lock-beginning-of-syntax-function).
1804 (set (make-local-variable 'font-lock-keywords)
1805 (font-lock-compile-keywords (font-lock-eval-keywords keywords) t))
1806 ;; Local fontification?
1807 (while local
1808 (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
1809 (setq local (cdr local)))
1810 (when removed-keywords
1811 (font-lock-remove-keywords nil removed-keywords)))))
1789 1812
1790;;; Colour etc. support. 1813;;; Colour etc. support.
1791 1814
@@ -2344,7 +2367,10 @@ The value of this variable is used when Font Lock mode is turned on."
2344 ;; Anders Lindgren <andersl@andersl.com> points out that it is quicker 2367 ;; Anders Lindgren <andersl@andersl.com> points out that it is quicker
2345 ;; to use MATCH-ANCHORED to effectively anchor the regexp on the left. 2368 ;; to use MATCH-ANCHORED to effectively anchor the regexp on the left.
2346 ;; This must come after the one for keywords and targets. 2369 ;; This must come after the one for keywords and targets.
2347 '(":" ("\\(\\sw+\\)[ \t]*:" 2370 ;; Note: the lack of `:' in the first char-range prevents `bar' from being
2371 ;; highlighted in "foo: bar:". But adding `:' would break cases like
2372 ;; "test1 ? test2 ? foo : bar : baz".
2373 '(":" ("\\(?:^\\|[{};]\\)[ \t]*\\(\\sw+\\)[ \t]*:"
2348 (beginning-of-line) (end-of-line) 2374 (beginning-of-line) (end-of-line)
2349 (1 font-lock-constant-face))) 2375 (1 font-lock-constant-face)))
2350 )) 2376 ))
@@ -2362,47 +2388,47 @@ The value of this variable is used when Font Lock mode is turned on."
2362 (list (concat "\\<\\(" ,c-type-names "\\)\\>" 2388 (list (concat "\\<\\(" ,c-type-names "\\)\\>"
2363 "\\([ \t*&]+\\sw+\\>\\)*") 2389 "\\([ \t*&]+\\sw+\\>\\)*")
2364 ;; Fontify each declaration item. 2390 ;; Fontify each declaration item.
2365 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next 2391 `(font-lock-match-c-style-declaration-item-and-skip-to-next
2366 ;; Start with point after all type specifiers. 2392 ;; Start with point after all type specifiers.
2367 (list 'goto-char (list 'or 2393 (prog1 (progn (skip-chars-forward "^;{}") (point))
2368 (list 'match-beginning 2394 (goto-char (or (match-beginning
2369 (+ ,c-type-names-depth 2)) 2395 ,(+ ,c-type-names-depth 2))
2370 '(match-end 1))) 2396 (match-end 1))))
2371 ;; Finish with point after first type specifier. 2397 ;; Finish with point after first type specifier.
2372 '(goto-char (match-end 1)) 2398 (goto-char (match-end 1))
2373 ;; Fontify as a variable or function name. 2399 ;; Fontify as a variable or function name.
2374 '(1 (if (match-beginning 2) 2400 (1 (if (match-beginning 2)
2375 font-lock-function-name-face 2401 font-lock-function-name-face
2376 font-lock-variable-name-face))))) 2402 font-lock-variable-name-face)))))
2377 ;; 2403 ;;
2378 ;; Fontify all storage specs and types, plus their items. 2404 ;; Fontify all storage specs and types, plus their items.
2379 `(eval . 2405 `(,(concat "\\<\\(" c-type-specs "\\)\\>" "[ \t]*\\(\\sw+\\)?")
2380 (list (concat "\\<\\(" ,c-type-specs "\\)\\>" 2406 (1 font-lock-keyword-face)
2381 "[ \t]*\\(\\sw+\\)?") 2407 (,(+ c-type-specs-depth 2) font-lock-type-face nil t)
2382 (list 1 'font-lock-keyword-face) 2408 (font-lock-match-c-style-declaration-item-and-skip-to-next
2383 (list ,(+ c-type-specs-depth 2) 'font-lock-type-face nil t) 2409 (save-excursion (skip-chars-forward "^;{}") (point))
2384 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next 2410 ;; Finish with point after the variable name if
2385 nil 2411 ;; there is one.
2386 ;; Finish with point after the variable name if 2412 (if (match-end 2)
2387 ;; there is one. 2413 (goto-char (match-end 2)))
2388 `(if (match-end 2) 2414 ;; Fontify as a variable or function name.
2389 (goto-char (match-end 2))) 2415 (1 (if (match-beginning 2)
2390 ;; Fontify as a variable or function name. 2416 font-lock-function-name-face
2391 '(1 (if (match-beginning 2) 2417 font-lock-variable-name-face) nil t)))
2392 font-lock-function-name-face
2393 font-lock-variable-name-face) nil t))))
2394 ;; 2418 ;;
2395 ;; Fontify structures, or typedef names, plus their items. 2419 ;; Fontify structures, or typedef names, plus their items.
2396 '("\\(}\\)[ \t*]*\\sw" 2420 '("\\(}\\)[ \t*]*\\sw"
2397 (font-lock-match-c-style-declaration-item-and-skip-to-next 2421 (font-lock-match-c-style-declaration-item-and-skip-to-next
2398 (goto-char (match-end 1)) nil 2422 (prog1 (progn (skip-chars-forward "^;{}") (point))
2423 (goto-char (match-end 1))) nil
2399 (1 font-lock-type-face))) 2424 (1 font-lock-type-face)))
2400 ;; 2425 ;;
2401 ;; Fontify anything at beginning of line as a declaration or definition. 2426 ;; Fontify anything at beginning of line as a declaration or definition.
2402 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" 2427 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
2403 (1 font-lock-type-face) 2428 (1 font-lock-type-face)
2404 (font-lock-match-c-style-declaration-item-and-skip-to-next 2429 (font-lock-match-c-style-declaration-item-and-skip-to-next
2405 (goto-char (or (match-beginning 2) (match-end 1))) nil 2430 (prog1 (progn (skip-chars-forward "^;{}") (point))
2431 (goto-char (or (match-beginning 2) (match-end 1)))) nil
2406 (1 (if (match-beginning 2) 2432 (1 (if (match-beginning 2)
2407 font-lock-function-name-face 2433 font-lock-function-name-face
2408 font-lock-variable-name-face)))) 2434 font-lock-variable-name-face))))
@@ -2441,13 +2467,13 @@ See also `c-font-lock-extra-types'.")
2441 (when (looking-at (eval-when-compile 2467 (when (looking-at (eval-when-compile
2442 (concat 2468 (concat
2443 ;; Skip any leading whitespace. 2469 ;; Skip any leading whitespace.
2444 "[ \t*&]*" 2470 "[ \t\n*&]*"
2445 ;; This is `c++-type-spec' from below. (Hint hint!) 2471 ;; This is `c++-type-spec' from below. (Hint hint!)
2446 "\\(\\sw+\\)" ; The instance? 2472 "\\(\\sw+\\)" ; The instance?
2447 "\\([ \t]*<\\(\\(?:[^<>\n]\\|<[^>\n]+>\\)+\\)[ \t*&]*>\\)?" ; Or template? 2473 "\\([ \t\n]*<\\(\\(?:[^<>]\\|<[^>]+>\\)+\\)[ \t\n*&]*>\\)?" ; Or template?
2448 "\\([ \t]*::[ \t*~]*\\(\\sw+\\)\\)*" ; Or member? 2474 "\\([ \t\n]*::[ \t\n*~]*\\(\\sw+\\)\\)*" ; Or member?
2449 ;; Match any trailing parenthesis. 2475 ;; Match any trailing parenthesis.
2450 "[ \t]*\\((\\)?"))) 2476 "[ \t\n]*\\((\\)?")))
2451 (save-match-data 2477 (save-match-data
2452 (condition-case nil 2478 (condition-case nil
2453 (save-restriction 2479 (save-restriction
@@ -2455,7 +2481,7 @@ See also `c-font-lock-extra-types'.")
2455 (narrow-to-region (point-min) limit) 2481 (narrow-to-region (point-min) limit)
2456 (goto-char (match-end 1)) 2482 (goto-char (match-end 1))
2457 ;; Move over any item value, etc., to the next item. 2483 ;; Move over any item value, etc., to the next item.
2458 (while (not (looking-at "[ \t]*\\(\\(,\\)\\|;\\|$\\)")) 2484 (while (not (looking-at "[ \t\n]*\\(\\(,\\)\\|;\\|\\'\\)"))
2459 (goto-char (or (scan-sexps (point) 1) (point-max)))) 2485 (goto-char (or (scan-sexps (point) 1) (point-max))))
2460 (goto-char (match-end 2))) 2486 (goto-char (match-end 2)))
2461 (error t))))) 2487 (error t)))))
@@ -2609,74 +2635,75 @@ See also `c++-font-lock-extra-types'.")
2609 (list (concat "\\<\\(" ,c++-type-names "\\)\\>" ,c++-type-suffix 2635 (list (concat "\\<\\(" ,c++-type-names "\\)\\>" ,c++-type-suffix
2610 "\\([ \t*&]+" ,c++-type-spec "\\)*") 2636 "\\([ \t*&]+" ,c++-type-spec "\\)*")
2611 ;; The name of any template type. 2637 ;; The name of any template type.
2612 (list (+ ,c++-type-names-depth 3) 'font-lock-type-face nil t) 2638 `(,(+ ,c++-type-names-depth 3) font-lock-type-face nil t)
2613 ;; Fontify each declaration item. 2639 ;; Fontify each declaration item.
2614 (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next 2640 `(font-lock-match-c++-style-declaration-item-and-skip-to-next
2615 ;; Start with point after all type specifiers. 2641 ;; Start with point after all type specifiers.
2616 (list 'goto-char (list 'or (list 'match-beginning 2642 (prog1 (progn (skip-chars-forward "^;{}") (point))
2617 (+ ,c++-type-depth 2)) 2643 (goto-char (or (match-beginning
2618 '(match-end 1))) 2644 ,(+ ,c++-type-depth 2))
2619 ;; Finish with point after first type specifier. 2645 (match-end 1))))
2620 '(goto-char (match-end 1)) 2646 ;; Finish with point after first type specifier.
2621 ;; Fontify as a variable or function name. 2647 (goto-char (match-end 1))
2622 '(1 (cond ((or (match-beginning 2) (match-beginning 4)) 2648 ;; Fontify as a variable or function name.
2623 font-lock-type-face) 2649 (1 (cond ((or (match-beginning 2) (match-beginning 4))
2624 ((and (match-beginning 6) (c-at-toplevel-p)) 2650 font-lock-type-face)
2625 font-lock-function-name-face) 2651 ((and (match-beginning 6) (c-at-toplevel-p))
2626 (t 2652 font-lock-function-name-face)
2627 font-lock-variable-name-face))) 2653 (t
2628 '(3 font-lock-type-face nil t) 2654 font-lock-variable-name-face)))
2629 '(5 (if (match-beginning 6) 2655 (3 font-lock-type-face nil t)
2630 font-lock-function-name-face 2656 (5 (if (match-beginning 6)
2631 font-lock-variable-name-face) nil t)))) 2657 font-lock-function-name-face
2658 font-lock-variable-name-face) nil t))))
2632 ;; 2659 ;;
2633 ;; Fontify all storage specs and types, plus their items. 2660 ;; Fontify all storage specs and types, plus their items.
2634 `(eval . 2661 `(,(concat "\\<" c++-type-specs "\\>" c++-type-suffix
2635 (list (concat "\\<" ,c++-type-specs "\\>" ,c++-type-suffix 2662 "[ \t]*\\(" c++-type-spec "\\)?")
2636 "[ \t]*\\(" ,c++-type-spec "\\)?") 2663 ;; The name of any template type.
2637 ;; The name of any template type. 2664 (,(+ c++-type-specs-depth 2) 'font-lock-type-face nil t)
2638 (list ,(+ c++-type-specs-depth 2) 'font-lock-type-face nil t) 2665 ;; The name of any type.
2639 ;; The name of any type. 2666 (,(+ c++-type-specs-depth c++-type-suffix-depth 2)
2640 (list (+ ,c++-type-specs-depth ,c++-type-suffix-depth 2) 2667 font-lock-type-face nil t)
2641 'font-lock-type-face nil t) 2668 ;; Fontify each declaration item.
2642 ;; Fontify each declaration item. 2669 (font-lock-match-c++-style-declaration-item-and-skip-to-next
2643 (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next 2670 ;; Start with point after all type specifiers.
2644 ;; Start with point after all type specifiers. 2671 (save-excursion (skip-chars-forward "^;{}") (point))
2645 nil 2672 ;; Finish with point after first type specifier.
2646 ;; Finish with point after first type specifier. 2673 nil
2647 nil 2674 ;; Fontify as a variable or function name.
2648 ;; Fontify as a variable or function name. 2675 (1 (cond ((or (match-beginning 2) (match-beginning 4))
2649 '(1 (cond ((or (match-beginning 2) (match-beginning 4)) 2676 font-lock-type-face)
2650 font-lock-type-face) 2677 ((and (match-beginning 6) (c-at-toplevel-p))
2651 ((and (match-beginning 6) (c-at-toplevel-p)) 2678 font-lock-function-name-face)
2652 font-lock-function-name-face) 2679 (t
2653 (t 2680 font-lock-variable-name-face)))
2654 font-lock-variable-name-face))) 2681 (3 font-lock-type-face nil t)
2655 '(3 font-lock-type-face nil t) 2682 (5 (if (match-beginning 6)
2656 '(5 (if (match-beginning 6) 2683 font-lock-function-name-face
2657 font-lock-function-name-face 2684 font-lock-variable-name-face) nil t)))
2658 font-lock-variable-name-face) nil t))
2659 ))
2660 ;; 2685 ;;
2661 ;; Fontify structures, or typedef names, plus their items. 2686 ;; Fontify structures, or typedef names, plus their items.
2662 '("\\(}\\)[ \t*]*\\sw" 2687 '("\\(}\\)[ \t*]*\\sw"
2663 (font-lock-match-c++-style-declaration-item-and-skip-to-next 2688 (font-lock-match-c++-style-declaration-item-and-skip-to-next
2664 (goto-char (match-end 1)) nil 2689 (prog1 (progn (skip-chars-forward "^;{}") (point))
2690 (goto-char (match-end 1))) nil
2665 (1 font-lock-type-face))) 2691 (1 font-lock-type-face)))
2666 ;; 2692 ;;
2667 ;; Fontify anything at beginning of line as a declaration or definition. 2693 ;; Fontify anything at beginning of line as a declaration or definition.
2668 (list (concat "^\\(" c++-type-spec "[ \t*&]*\\)+") 2694 `(,(concat "^\\(" c++-type-spec "[ \t*&]*\\)+")
2669 '(font-lock-match-c++-style-declaration-item-and-skip-to-next 2695 (font-lock-match-c++-style-declaration-item-and-skip-to-next
2670 (goto-char (match-beginning 1)) 2696 (prog1 (progn (skip-chars-forward "^;{}") (point))
2671 (goto-char (match-end 1)) 2697 (goto-char (match-beginning 1)))
2672 (1 (cond ((or (match-beginning 2) (match-beginning 4)) 2698 (goto-char (match-end 1))
2673 font-lock-type-face) 2699 (1 (cond ((or (match-beginning 2) (match-beginning 4))
2674 ((match-beginning 6) font-lock-function-name-face) 2700 font-lock-type-face)
2675 (t font-lock-variable-name-face))) 2701 ((match-beginning 6) font-lock-function-name-face)
2676 (3 font-lock-type-face nil t) 2702 (t font-lock-variable-name-face)))
2677 (5 (if (match-beginning 6) 2703 (3 font-lock-type-face nil t)
2678 font-lock-function-name-face 2704 (5 (if (match-beginning 6)
2679 font-lock-variable-name-face) nil t))) 2705 font-lock-function-name-face
2706 font-lock-variable-name-face) nil t)))
2680 ;; 2707 ;;
2681 ;; Fontify constructors and destructors inside class declarations. 2708 ;; Fontify constructors and destructors inside class declarations.
2682 '(font-lock-match-c++-structor-declaration 2709 '(font-lock-match-c++-structor-declaration
@@ -2791,45 +2818,44 @@ See also `objc-font-lock-extra-types'.")
2791 (list (concat "\\<\\(" ,objc-type-names "\\)\\>" 2818 (list (concat "\\<\\(" ,objc-type-names "\\)\\>"
2792 "\\([ \t*&]+\\sw+\\>\\)*") 2819 "\\([ \t*&]+\\sw+\\>\\)*")
2793 ;; Fontify each declaration item. 2820 ;; Fontify each declaration item.
2794 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next 2821 `(font-lock-match-c-style-declaration-item-and-skip-to-next
2795 ;; Start with point after all type specifiers. 2822 ;; Start with point after all type specifiers.
2796 (list 'goto-char 2823 (prog1 (progn (skip-chars-forward "^;{}") (point))
2797 (list 'or (list 'match-beginning 2824 (goto-char (or (match-beginning
2798 (+ ,objc-type-names-depth 2)) 2825 ,(+ ,objc-type-names-depth 2))
2799 '(match-end 1))) 2826 (match-end 1))))
2800 ;; Finish with point after first type specifier. 2827 ;; Finish with point after first type specifier.
2801 '(goto-char (match-end 1)) 2828 (goto-char (match-end 1))
2802 ;; Fontify as a variable or function name. 2829 ;; Fontify as a variable or function name.
2803 '(1 (if (match-beginning 2) 2830 (1 (if (match-beginning 2)
2804 font-lock-function-name-face 2831 font-lock-function-name-face
2805 font-lock-variable-name-face))))) 2832 font-lock-variable-name-face)))))
2806 ;; 2833 ;;
2807 ;; Fontify all storage specs and types, plus their items. 2834 ;; Fontify all storage specs and types, plus their items.
2808 `(eval . 2835 `(,(concat "\\<\\(" objc-type-specs "[ \t]*\\)+\\>" "[ \t]*\\(\\sw+\\)?")
2809 (list (concat "\\<\\(" ,objc-type-specs "[ \t]*\\)+\\>" 2836 ;; The name of any type.
2810 "[ \t]*\\(\\sw+\\)?") 2837 (,(+ objc-type-specs-depth 2) font-lock-type-face nil t)
2811 ;; The name of any type. 2838 ;; Fontify each declaration item.
2812 (list ,(+ objc-type-specs-depth 2) 'font-lock-type-face nil t) 2839 (font-lock-match-c++-style-declaration-item-and-skip-to-next
2813 ;; Fontify each declaration item. 2840 (save-excursion (skip-chars-forward "^;{}") (point)) nil
2814 (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next 2841 ;; Fontify as a variable or function name.
2815 nil nil 2842 (1 (if (match-beginning 2)
2816 ;; Fontify as a variable or function name. 2843 font-lock-function-name-face
2817 '(1 (if (match-beginning 2) 2844 font-lock-variable-name-face))))
2818 font-lock-function-name-face
2819 font-lock-variable-name-face)))
2820 ))
2821 ;; 2845 ;;
2822 ;; Fontify structures, or typedef names, plus their items. 2846 ;; Fontify structures, or typedef names, plus their items.
2823 '("\\(}\\)[ \t*]*\\sw" 2847 '("\\(}\\)[ \t*]*\\sw"
2824 (font-lock-match-c-style-declaration-item-and-skip-to-next 2848 (font-lock-match-c-style-declaration-item-and-skip-to-next
2825 (goto-char (match-end 1)) nil 2849 (prog1 (progn (skip-chars-forward "^;{}") (point))
2850 (goto-char (match-end 1))) nil
2826 (1 font-lock-type-face))) 2851 (1 font-lock-type-face)))
2827 ;; 2852 ;;
2828 ;; Fontify anything at beginning of line as a declaration or definition. 2853 ;; Fontify anything at beginning of line as a declaration or definition.
2829 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" 2854 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
2830 (1 font-lock-type-face) 2855 (1 font-lock-type-face)
2831 (font-lock-match-c-style-declaration-item-and-skip-to-next 2856 (font-lock-match-c-style-declaration-item-and-skip-to-next
2832 (goto-char (or (match-beginning 2) (match-end 1))) nil 2857 (prog1 (progn (skip-chars-forward "^;{}") (point))
2858 (goto-char (or (match-beginning 2) (match-end 1)))) nil
2833 (1 (if (match-beginning 2) 2859 (1 (if (match-beginning 2)
2834 font-lock-function-name-face 2860 font-lock-function-name-face
2835 font-lock-variable-name-face)))) 2861 font-lock-variable-name-face))))
@@ -2949,32 +2975,32 @@ See also `java-font-lock-extra-types'.")
2949 "\\([ \t]*\\[[ \t]*\\]\\)*" 2975 "\\([ \t]*\\[[ \t]*\\]\\)*"
2950 "\\([ \t]*\\sw\\)") 2976 "\\([ \t]*\\sw\\)")
2951 ;; Fontify each declaration item. 2977 ;; Fontify each declaration item.
2952 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next 2978 `(font-lock-match-c-style-declaration-item-and-skip-to-next
2953 ;; Start and finish with point after the type specifier. 2979 ;; Start and finish with point after the type specifier.
2954 (list 'goto-char (list 'match-beginning 2980 (prog1 (progn (skip-chars-forward "^;{}") (point))
2955 (+ ,java-type-names-depth 3))) 2981 (goto-char (match-beginning ,(+ ,java-type-names-depth 3))))
2956 (list 'goto-char (list 'match-beginning 2982 (goto-char (match-beginning ,(+ ,java-type-names-depth 3)))
2957 (+ ,java-type-names-depth 3))) 2983 ;; Fontify as a variable or function name.
2958 ;; Fontify as a variable or function name. 2984 (1 (if (match-beginning 2)
2959 '(1 (if (match-beginning 2) 2985 font-lock-function-name-face
2960 font-lock-function-name-face 2986 font-lock-variable-name-face)))))
2961 font-lock-variable-name-face)))))
2962 ;; 2987 ;;
2963 ;; Fontify those that are eventually followed by an item or items. 2988 ;; Fontify those that are eventually followed by an item or items.
2964 (list (concat "\\<\\(" java-type-specs "\\)\\>" 2989 `(,(concat "\\<\\(" java-type-specs "\\)\\>"
2965 "\\([ \t]+\\sw+\\>" 2990 "\\([ \t]+\\sw+\\>"
2966 "\\([ \t]*\\[[ \t]*\\]\\)*" 2991 "\\([ \t]*\\[[ \t]*\\]\\)*"
2967 "\\)*") 2992 "\\)*")
2968 ;; Fontify each declaration item. 2993 ;; Fontify each declaration item.
2969 '(font-lock-match-c-style-declaration-item-and-skip-to-next 2994 (font-lock-match-c-style-declaration-item-and-skip-to-next
2970 ;; Start with point after all type specifiers. 2995 ;; Start with point after all type specifiers.
2971 (goto-char (or (match-beginning 5) (match-end 1))) 2996 (prog1 (progn (skip-chars-forward "^;{}") (point))
2972 ;; Finish with point after first type specifier. 2997 (goto-char (or (match-beginning 5) (match-end 1))))
2973 (goto-char (match-end 1)) 2998 ;; Finish with point after first type specifier.
2974 ;; Fontify as a variable or function name. 2999 (goto-char (match-end 1))
2975 (1 (if (match-beginning 2) 3000 ;; Fontify as a variable or function name.
2976 font-lock-function-name-face 3001 (1 (if (match-beginning 2)
2977 font-lock-variable-name-face)))) 3002 font-lock-function-name-face
3003 font-lock-variable-name-face))))
2978 )) 3004 ))
2979 "Gaudy level highlighting for Java mode. 3005 "Gaudy level highlighting for Java mode.
2980See also `java-font-lock-extra-types'.") 3006See also `java-font-lock-extra-types'.")