aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorSimon Marshall1997-03-15 13:19:12 +0000
committerSimon Marshall1997-03-15 13:19:12 +0000
commit2d63aa6734ae5696e9a15a1ec59a2315abdd6076 (patch)
tree5af5e3df0cbdbae179832e769ef36ab021e1c0fd /lisp
parentfbd441167278e58082003562199e7dad9f6828d9 (diff)
downloademacs-2d63aa6734ae5696e9a15a1ec59a2315abdd6076.tar.gz
emacs-2d63aa6734ae5696e9a15a1ec59a2315abdd6076.zip
Allow arbitrary regexps in *-font-lock-extra-types.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/font-lock.el435
1 files changed, 246 insertions, 189 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 380d41261ae..5186399ba34 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -190,7 +190,7 @@
190If a number, only buffers greater than this size have fontification messages.") 190If a number, only buffers greater than this size have fontification messages.")
191 191
192;;;###autoload 192;;;###autoload
193(defvar font-lock-maximum-decoration nil 193(defvar font-lock-maximum-decoration t
194 "*Maximum decoration level for fontification. 194 "*Maximum decoration level for fontification.
195If nil, use the default decoration (typically the minimum available). 195If nil, use the default decoration (typically the minimum available).
196If t, use the maximum decoration available. 196If t, use the maximum decoration available.
@@ -274,11 +274,12 @@ MATCH-HIGHLIGHT should be of the form:
274 274
275Where MATCHER can be either the regexp to search for, or the function name to 275Where MATCHER can be either the regexp to search for, or the function name to
276call to make the search (called with one argument, the limit of the search). 276call to make the search (called with one argument, the limit of the search).
277MATCH is the subexpression of MATCHER to be highlighted. FACENAME is an 277MATCH is the subexpression of MATCHER to be highlighted. MATCH can be
278calculated via the function `font-lock-keyword-depth'. FACENAME is an
278expression whose value is the face name to use. FACENAME's default attributes 279expression whose value is the face name to use. FACENAME's default attributes
279may be defined in `font-lock-face-attributes'. 280can be defined via the variable `font-lock-face-attributes'.
280 281
281OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may 282OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification can
282be overwritten. If `keep', only parts not already fontified are highlighted. 283be overwritten. If `keep', only parts not already fontified are highlighted.
283If `prepend' or `append', existing fontification is merged with the new, in 284If `prepend' or `append', existing fontification is merged with the new, in
284which the new or existing fontification, respectively, takes precedence. 285which the new or existing fontification, respectively, takes precedence.
@@ -332,16 +333,55 @@ These regular expressions should not match text which spans lines. While
332\\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating 333\\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating
333when you edit the buffer does not, since it considers text one line at a time. 334when you edit the buffer does not, since it considers text one line at a time.
334 335
335Be very careful composing regexps for this list; 336This variable is set by major modes via the variable `font-lock-defaults'.
336the wrong pattern can dramatically slow things down!") 337Be careful when composing regexps for this list; a poorly written pattern can
337(make-variable-buffer-local 'font-lock-keywords) 338dramatically slow things down!")
338 339
339;; This variable is used by mode packages that support Font Lock mode by 340;; This variable is used by mode packages that support Font Lock mode by
340;; defining their own keywords to use for `font-lock-keywords'. (The mode 341;; defining their own keywords to use for `font-lock-keywords'. (The mode
341;; command should make it buffer-local and set it to provide the set up.) 342;; command should make it buffer-local and set it to provide the set up.)
342(defvar font-lock-defaults nil 343(defvar font-lock-defaults nil
343 "If set by a major mode, should be the defaults for Font Lock mode. 344 "Defaults for Font Lock mode specified by the major mode.
344The value should be like the `cdr' of an item in `font-lock-defaults-alist'.") 345Defaults should be of the form:
346
347 (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN ...)
348
349KEYWORDS may be a symbol (a variable or function whose value is the keywords to
350use for fontification) or a list of symbols. If KEYWORDS-ONLY is non-nil,
351syntactic fontification (strings and comments) is not performed.
352If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying.
353If SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form
354\(CHAR-OR-STRING . STRING) used to set the local Font Lock syntax table, for
355keyword and syntactic fontification (see `modify-syntax-entry').
356
357If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move
358backwards outside any enclosing syntactic block, for syntactic fontification.
359Typical values are `beginning-of-line' (i.e., the start of the line is known to
360be outside a syntactic block), or `beginning-of-defun' for programming modes or
361`backward-paragraph' for textual modes (i.e., the mode-dependent function is
362known to move outside a syntactic block). If nil, the beginning of the buffer
363is used as a position outside of a syntactic block, in the worst case.
364
365These item elements are used by Font Lock mode to set the variables
366`font-lock-keywords', `font-lock-keywords-only',
367`font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
368`font-lock-beginning-of-syntax-function', respectively.
369
370Further item elements are alists of the form (VARIABLE . VALUE) and are in no
371particular order. Each VARIABLE is made buffer-local before set to VALUE.
372
373Currently, appropriate variables include `font-lock-mark-block-function'.
374If this is non-nil, it should be a function with no args used to mark any
375enclosing block of text, for fontification via \\[font-lock-fontify-block].
376Typical values are `mark-defun' for programming modes or `mark-paragraph' for
377textual modes (i.e., the mode-dependent function is known to put point and mark
378around a text block relevant to that mode).
379
380Other variables include those for buffer-specialised fontification functions,
381`font-lock-fontify-buffer-function', `font-lock-unfontify-buffer-function',
382`font-lock-fontify-region-function', `font-lock-unfontify-region-function',
383`font-lock-comment-start-regexp', `font-lock-inhibit-thing-lock' and
384`font-lock-maximum-size'.")
345 385
346;; This variable is used where font-lock.el itself supplies the keywords. 386;; This variable is used where font-lock.el itself supplies the keywords.
347(defvar font-lock-defaults-alist 387(defvar font-lock-defaults-alist
@@ -408,48 +448,13 @@ The value should be like the `cdr' of an item in `font-lock-defaults-alist'.")
408 (cons 'scheme-interaction-mode scheme-mode-defaults) 448 (cons 'scheme-interaction-mode scheme-mode-defaults)
409 (cons 'slitex-mode tex-mode-defaults) 449 (cons 'slitex-mode tex-mode-defaults)
410 (cons 'tex-mode tex-mode-defaults))) 450 (cons 'tex-mode tex-mode-defaults)))
411 "Alist of default major mode and Font Lock defaults. 451 "Alist of fall-back Font Lock defaults for major modes.
412Each item should be a list of the form: 452Each item should be a list of the form:
413 453
414 (MAJOR-MODE . (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN 454 (MAJOR-MODE . FONT-LOCK-DEFAULTS)
415 ...))
416
417where MAJOR-MODE is a symbol. KEYWORDS may be a symbol (a variable or function
418whose value is the keywords to use for fontification) or a list of symbols.
419If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and comments) is
420not performed. If CASE-FOLD is non-nil, the case of the keywords is ignored
421when fontifying. If SYNTAX-ALIST is non-nil, it should be a list of cons pairs
422of the form (CHAR-OR-STRING . STRING) used to set the local Font Lock syntax
423table, for keyword and syntactic fontification (see `modify-syntax-entry').
424
425If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move
426backwards outside any enclosing syntactic block, for syntactic fontification.
427Typical values are `beginning-of-line' (i.e., the start of the line is known to
428be outside a syntactic block), or `beginning-of-defun' for programming modes or
429`backward-paragraph' for textual modes (i.e., the mode-dependent function is
430known to move outside a syntactic block). If nil, the beginning of the buffer
431is used as a position outside of a syntactic block, in the worst case.
432
433These item elements are used by Font Lock mode to set the variables
434`font-lock-keywords', `font-lock-keywords-only',
435`font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
436`font-lock-beginning-of-syntax-function', respectively.
437
438Further item elements are alists of the form (VARIABLE . VALUE) and are in no
439particular order. Each VARIABLE is made buffer-local before set to VALUE.
440
441Currently, appropriate variables include `font-lock-mark-block-function'.
442If this is non-nil, it should be a function with no args used to mark any
443enclosing block of text, for fontification via \\[font-lock-fontify-block].
444Typical values are `mark-defun' for programming modes or `mark-paragraph' for
445textual modes (i.e., the mode-dependent function is known to put point and mark
446around a text block relevant to that mode).
447 455
448Other variables include those for buffer-specialised fontification functions, 456where MAJOR-MODE is a symbol and FONT-LOCK-DEFAULTS is a list of default
449`font-lock-fontify-buffer-function', `font-lock-unfontify-buffer-function', 457settings. See the variable `font-lock-defaults', which takes precedence.")
450`font-lock-fontify-region-function', `font-lock-unfontify-region-function',
451`font-lock-comment-start-regexp', `font-lock-inhibit-thing-lock' and
452`font-lock-maximum-size'.")
453 458
454(defvar font-lock-keywords-alist nil 459(defvar font-lock-keywords-alist nil
455 "*Alist of `font-lock-keywords' local to a `major-mode'. 460 "*Alist of `font-lock-keywords' local to a `major-mode'.
@@ -642,8 +647,8 @@ or nil. If nil, highlighting keywords are added for the current buffer.
642KEYWORDS should be a list; see the variable `font-lock-keywords'. 647KEYWORDS should be a list; see the variable `font-lock-keywords'.
643By default they are added at the beginning of the current highlighting list. 648By default they are added at the beginning of the current highlighting list.
644If optional argument APPEND is `set', they are used to replace the current 649If optional argument APPEND is `set', they are used to replace the current
645highlighting list. If APPEND has any other value, e.g., t, they are added at 650highlighting list. If APPEND is any other non-nil value, they are added at the
646the end of the current highlighting list. 651end of the current highlighting list.
647 652
648For example: 653For example:
649 654
@@ -652,7 +657,11 @@ For example:
652 (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" . font-lock-keyword-face))) 657 (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" . font-lock-keyword-face)))
653 658
654adds two fontification patterns for C mode, to fontify `FIXME:' words, even in 659adds two fontification patterns for C mode, to fontify `FIXME:' words, even in
655comments, and to fontify `and', `or' and `not' words as keywords." 660comments, and to fontify `and', `or' and `not' words as keywords.
661
662Note that some modes have specialised support for additional patterns, e.g.,
663see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types',
664`objc-font-lock-extra-types' and `java-font-lock-extra-types'."
656 (cond (major-mode 665 (cond (major-mode
657 ;; If MAJOR-MODE is non-nil, add the KEYWORDS and APPEND spec to 666 ;; If MAJOR-MODE is non-nil, add the KEYWORDS and APPEND spec to
658 ;; `font-lock-keywords-alist' so `font-lock-set-defaults' uses them. 667 ;; `font-lock-keywords-alist' so `font-lock-set-defaults' uses them.
@@ -671,8 +680,8 @@ comments, and to fontify `and', `or' and `not' words as keywords."
671 (append old keywords) 680 (append old keywords)
672 (append keywords old)))))))) 681 (append keywords old))))))))
673 682
674;; Global Font Lock mode. 683;;; Global Font Lock mode.
675;; 684
676;; A few people have hassled in the past for a way to make it easier to turn on 685;; A few people have hassled in the past for a way to make it easier to turn on
677;; Font Lock mode, without the user needing to know for which modes s/he has to 686;; Font Lock mode, without the user needing to know for which modes s/he has to
678;; turn it on, perhaps the same way hilit19.el/hl319.el does. I've always 687;; turn it on, perhaps the same way hilit19.el/hl319.el does. I've always
@@ -794,10 +803,10 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'."
794 803
795(add-hook 'change-major-mode-hook 'font-lock-change-major-mode) 804(add-hook 'change-major-mode-hook 'font-lock-change-major-mode)
796 805
797;; End of Global Font Lock mode. 806;;; End of Global Font Lock mode.
798 807
799;; Font Lock Support mode. 808;;; Font Lock Support mode.
800;; 809
801;; This is the code used to interface font-lock.el with any of its add-on 810;; This is the code used to interface font-lock.el with any of its add-on
802;; packages, and provide the user interface. Packages that have their own 811;; packages, and provide the user interface. Packages that have their own
803;; local buffer fontification functions (see below) may have to call 812;; local buffer fontification functions (see below) may have to call
@@ -848,9 +857,9 @@ The value of this variable is used when Font Lock mode is turned on.")
848 (lazy-lock-mode 857 (lazy-lock-mode
849 (lazy-lock-after-unfontify-buffer)))) 858 (lazy-lock-after-unfontify-buffer))))
850 859
851;; End of Font Lock Support mode. 860;;; End of Font Lock Support mode.
852 861
853;; Fontification functions. 862;;; Fontification functions.
854 863
855;; Rather than the function, e.g., `font-lock-fontify-region' containing the 864;; Rather than the function, e.g., `font-lock-fontify-region' containing the
856;; code to fontify a region, the function runs the function whose name is the 865;; code to fontify a region, the function runs the function whose name is the
@@ -1002,8 +1011,10 @@ delimit the region to fontify."
1002 ((error quit) (message "Fontifying block...%s" error-data))))))) 1011 ((error quit) (message "Fontifying block...%s" error-data)))))))
1003 1012
1004(define-key facemenu-keymap "\M-g" 'font-lock-fontify-block) 1013(define-key facemenu-keymap "\M-g" 'font-lock-fontify-block)
1014
1015;;; End of Fontification functions.
1005 1016
1006;; Syntactic fontification functions. 1017;;; Syntactic fontification functions.
1007 1018
1008;; These record the parse state at a particular position, always the start of a 1019;; These record the parse state at a particular position, always the start of a
1009;; line. Used to make `font-lock-fontify-syntactically-region' faster. 1020;; line. Used to make `font-lock-fontify-syntactically-region' faster.
@@ -1114,6 +1125,8 @@ START should be at the beginning of a line."
1114 (error (goto-char end))) 1125 (error (goto-char end)))
1115 (put-text-property beg (point) 'face font-lock-comment-face) 1126 (put-text-property beg (point) 'face font-lock-comment-face)
1116 (setq state (parse-partial-sexp here (point) nil nil state))))))) 1127 (setq state (parse-partial-sexp here (point) nil nil state)))))))
1128
1129;;; End of Syntactic fontification functions.
1117 1130
1118;;; Additional text property functions. 1131;;; Additional text property functions.
1119 1132
@@ -1193,6 +1206,8 @@ Optional argument OBJECT is the string or buffer containing the text."
1193; (t 1206; (t
1194; (put-text-property start next prop new object)))))) 1207; (put-text-property start next prop new object))))))
1195; (setq start (text-property-not-all next end prop nil object))))) 1208; (setq start (text-property-not-all next end prop nil object)))))
1209
1210;;; End of Additional text property functions.
1196 1211
1197;;; Regexp fontification functions. 1212;;; Regexp fontification functions.
1198 1213
@@ -1277,6 +1292,8 @@ START should be at the beginning of a line."
1277 (font-lock-fontify-anchored-keywords (car highlights) end)) 1292 (font-lock-fontify-anchored-keywords (car highlights) end))
1278 (setq highlights (cdr highlights)))) 1293 (setq highlights (cdr highlights))))
1279 (setq keywords (cdr keywords))))) 1294 (setq keywords (cdr keywords)))))
1295
1296;;; End of Regexp fontification functions.
1280 1297
1281;; Various functions. 1298;; Various functions.
1282 1299
@@ -1349,9 +1366,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1349 (font-lock-value-in-major-mode font-lock-maximum-decoration))) 1366 (font-lock-value-in-major-mode font-lock-maximum-decoration)))
1350 (local (cdr (assq major-mode font-lock-keywords-alist)))) 1367 (local (cdr (assq major-mode font-lock-keywords-alist))))
1351 ;; Regexp fontification? 1368 ;; Regexp fontification?
1352 (setq font-lock-keywords (if (fboundp keywords) 1369 (set (make-local-variable 'font-lock-keywords)
1353 (funcall keywords) 1370 (if (fboundp keywords) (funcall keywords) (eval keywords)))
1354 (eval keywords)))
1355 ;; Local fontification? 1371 ;; Local fontification?
1356 (while local 1372 (while local
1357 (font-lock-add-keywords nil (car (car local)) (cdr (car local))) 1373 (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
@@ -1403,7 +1419,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1403 (set (car (car alist)) (default-value (car (car alist)))) 1419 (set (car (car alist)) (default-value (car (car alist))))
1404 (setq alist (cdr alist))))) 1420 (setq alist (cdr alist)))))
1405 1421
1406;; Colour etc. support. 1422;;; Colour etc. support.
1407 1423
1408;; This section of code is crying out for revision. Come on down, custom.el? 1424;; This section of code is crying out for revision. Come on down, custom.el?
1409 1425
@@ -1612,6 +1628,8 @@ the face is also set; its value is the face name."
1612 (or (funcall set-p face-name "Underline") 1628 (or (funcall set-p face-name "Underline")
1613 (set-face-underline-p face (nth 5 face-attributes))) 1629 (set-face-underline-p face (nth 5 face-attributes)))
1614 (set face face))) 1630 (set face face)))
1631
1632;;; End of Colour etc. support.
1615 1633
1616;;; Menu support. 1634;;; Menu support.
1617 1635
@@ -1713,6 +1731,8 @@ the face is also set; its value is the face name."
1713;(defun font-lock-unset-menu () 1731;(defun font-lock-unset-menu ()
1714; ;; Deactivate less/more fontification entries. 1732; ;; Deactivate less/more fontification entries.
1715; (setq font-lock-fontify-level nil)) 1733; (setq font-lock-fontify-level nil))
1734
1735;;; End of Menu support.
1716 1736
1717;;; Various regexp information shared by several modes. 1737;;; Various regexp information shared by several modes.
1718;;; Information specific to a single mode should go in its load library. 1738;;; Information specific to a single mode should go in its load library.
@@ -1752,10 +1772,19 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1752 (goto-char (match-end 2))) 1772 (goto-char (match-end 2)))
1753 (error t))))) 1773 (error t)))))
1754 1774
1775(defun font-lock-keyword-depth (keyword)
1776 "Return the depth of KEYWORD regexp.
1777This means the number of parenthesized expressions."
1778 (let ((count 0) start)
1779 (while (string-match "\\\\(" keyword start)
1780 (setq start (match-end 0) count (1+ count)))
1781 count))
1782
1755 1783
1756(defconst lisp-font-lock-keywords-1 1784(defconst lisp-font-lock-keywords-1
1757 (eval-when-compile 1785 (eval-when-compile
1758 (list 1786 (list
1787 ;;
1759 ;; Anything not a variable or type declaration is fontified as a function. 1788 ;; Anything not a variable or type declaration is fontified as a function.
1760 ;; It would be cleaner to allow preceding whitespace, but it would also be 1789 ;; It would be cleaner to allow preceding whitespace, but it would also be
1761 ;; about five times slower. 1790 ;; about five times slower.
@@ -1775,6 +1804,11 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1775 ((match-beginning 4) font-lock-type-face) 1804 ((match-beginning 4) font-lock-type-face)
1776 (t font-lock-function-name-face)) 1805 (t font-lock-function-name-face))
1777 nil t)) 1806 nil t))
1807 ;;
1808 ;; Emacs Lisp autoload cookies.
1809 '("^;;;\\(###\\)\\(autoload\\)\\>"
1810 (1 font-lock-reference-face prepend)
1811 (2 font-lock-warning-face prepend))
1778 )) 1812 ))
1779 "Subdued level highlighting for Lisp modes.") 1813 "Subdued level highlighting for Lisp modes.")
1780 1814
@@ -1783,32 +1817,42 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1783 (eval-when-compile 1817 (eval-when-compile
1784 (list 1818 (list
1785 ;; 1819 ;;
1786 ;; Control structures. Common ELisp and CLisp forms combined. 1820 ;; Control structures. Emacs Lisp forms.
1787; (make-regexp
1788; '("cond" "if" "while" "let\\*?" "prog[nv12*]?" "inline" "catch" "throw"
1789; "save-restriction" "save-excursion" "save-window-excursion"
1790; "save-selected-window" "save-match-data" "save-current-buffer"
1791; "unwind-protect" "condition-case" "track-mouse" "dont-compile"
1792; "eval-after-load" "eval-and-compile" "eval-when-compile"
1793; "when" "unless" "do" "flet" "labels" "return" "return-from"
1794; "with-output-to-temp-buffer" "with-timeout" "with-current-buffer"
1795; "with-temp-buffer" "with-temp-file"))
1796 (cons (concat "(\\(" 1821 (cons (concat "(\\("
1797 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|" 1822; '("cond" "if" "while" "let\\*?" "prog[nv12*]?" "inline" "catch" "throw"
1798 "do\\(\\|nt-compile\\)\\|" 1823; "save-restriction" "save-excursion" "save-window-excursion"
1824; "save-selected-window" "save-match-data" "save-current-buffer"
1825; "unwind-protect" "condition-case" "track-mouse" "dont-compile"
1826; "eval-after-load" "eval-and-compile" "eval-when" "eval-when-compile"
1827; "with-output-to-temp-buffer" "with-timeout" "with-current-buffer"
1828; "with-temp-buffer" "with-temp-file")
1829 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|dont-compile\\|"
1799 "eval-\\(a\\(fter-load\\|nd-compile\\)\\|" 1830 "eval-\\(a\\(fter-load\\|nd-compile\\)\\|"
1800 "when-compile\\)\\|flet\\|i\\(f\\|nline\\)\\|" 1831 "when\\(\\|-compile\\)\\)\\|"
1801 "l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|" 1832 "i\\(f\\|nline\\)\\|let\\*?\\|prog[nv12*]?\\|"
1802 "return\\(\\|-from\\)\\|"
1803 "save-\\(current-buffer\\|excursion\\|match-data\\|" 1833 "save-\\(current-buffer\\|excursion\\|match-data\\|"
1804 "restriction\\|selected-window\\|window-excursion\\)\\|" 1834 "restriction\\|selected-window\\|window-excursion\\)\\|"
1805 "t\\(hrow\\|rack-mouse\\)\\|un\\(less\\|wind-protect\\)\\|" 1835 "t\\(hrow\\|rack-mouse\\)\\|unwind-protect\\|"
1806 "w\\(h\\(en\\|ile\\)\\|ith-\\(current-buffer\\|" 1836 "w\\(hile\\|ith-\\(current-buffer\\|"
1807 "output-to-temp-buffer\\|" 1837 "output-to-temp-buffer\\|"
1808 "t\\(emp-\\(buffer\\|file\\)\\|imeout\\)\\)\\)" 1838 "t\\(emp-\\(buffer\\|file\\)\\|imeout\\)\\)\\)"
1809 "\\)\\>") 1839 "\\)\\>")
1810 1) 1840 1)
1811 ;; 1841 ;;
1842 ;; Control structures. Common Lisp forms.
1843 (cons (concat "(\\("
1844; '(make-regexp
1845; '("when" "unless" "case" "ecase" "typecase" "etypecase"
1846; "loop" "do\\*?" "dotimes" "dolist"
1847; "proclaim" "declaim" "declare"
1848; "lexical-let\\*?" "flet" "labels" "return" "return-from"))
1849 "case\\|d\\(ecla\\(im\\|re\\)\\|o\\(\\*?\\|"
1850 "list\\|times\\)\\)\\|e\\(case\\|typecase\\)\\|flet\\|"
1851 "l\\(abels\\|exical-let\\*?\\|oop\\)\\|proclaim\\|"
1852 "return\\(\\|-from\\)\\|typecase\\|unless\\|when"
1853 "\\)\\>")
1854 1)
1855 ;;
1812 ;; Feature symbols as references. 1856 ;; Feature symbols as references.
1813 '("(\\(featurep\\|provide\\|require\\)\\>[ \t']*\\(\\sw+\\)?" 1857 '("(\\(featurep\\|provide\\|require\\)\\>[ \t']*\\(\\sw+\\)?"
1814 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) 1858 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
@@ -1922,25 +1966,25 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1922 1966
1923(defvar c-font-lock-extra-types '("FILE" "\\sw+_t") 1967(defvar c-font-lock-extra-types '("FILE" "\\sw+_t")
1924 "*List of extra types to fontify in C mode. 1968 "*List of extra types to fontify in C mode.
1925Each list item should be a regexp without word-delimiters or parentheses. 1969Each list item should be a regexp without word-delimiters.
1926For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE and words 1970For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE and words
1927ending in _t are treated as type names.") 1971ending in _t are treated as type names.")
1928 1972
1929(defvar c++-font-lock-extra-types nil 1973(defvar c++-font-lock-extra-types nil
1930 "*List of extra types to fontify in C++ mode. 1974 "*List of extra types to fontify in C++ mode.
1931Each list item should be a regexp without word-delimiters or parentheses. 1975Each list item should be a regexp without word-delimiters.
1932For example, a value of (\"String\") means the word String is treated as a type 1976For example, a value of (\"String\") means the word String is treated as a type
1933name.") 1977name.")
1934 1978
1935(defvar objc-font-lock-extra-types '("Class" "BOOL" "IMP" "SEL") 1979(defvar objc-font-lock-extra-types '("Class" "BOOL" "IMP" "SEL")
1936 "*List of extra types to fontify in Objective-C mode. 1980 "*List of extra types to fontify in Objective-C mode.
1937Each list item should be a regexp without word-delimiters or parentheses. 1981Each list item should be a regexp without word-delimiters.
1938For example, a value of (\"Class\" \"BOOL\" \"IMP\" \"SEL\") means the words 1982For example, a value of (\"Class\" \"BOOL\" \"IMP\" \"SEL\") means the words
1939Class, BOOL, IMP and SEL are treated as type names.") 1983Class, BOOL, IMP and SEL are treated as type names.")
1940 1984
1941(defvar java-font-lock-extra-types '("[A-Z\300-\326\330-\337]\\sw+") 1985(defvar java-font-lock-extra-types '("[A-Z\300-\326\330-\337]\\sw+")
1942 "*List of extra types to fontify in Java mode. 1986 "*List of extra types to fontify in Java mode.
1943Each list item should be a regexp without word-delimiters or parentheses. 1987Each list item should be a regexp without word-delimiters.
1944For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw+\") means capitalised 1988For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw+\") means capitalised
1945words (and words conforming to the Java id spec) are treated as type names.") 1989words (and words conforming to the Java id spec) are treated as type names.")
1946 1990
@@ -1971,22 +2015,23 @@ See also `c-font-lock-extra-types'.")
1971 "Gaudy level highlighting for C mode. 2015 "Gaudy level highlighting for C mode.
1972See also `c-font-lock-extra-types'.") 2016See also `c-font-lock-extra-types'.")
1973 2017
1974(let ((c-keywords 2018(let* ((c-keywords
1975; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while") 2019; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while")
1976 "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|switch\\|while") 2020 "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|switch\\|while")
1977 (c-type-types 2021 (c-type-types
1978; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" 2022; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
1979; "signed" "unsigned" "short" "long" "int" "char" "float" "double" 2023; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
1980; "void" "volatile" "const") 2024; "void" "volatile" "const")
1981 `(mapconcat 'identity 2025 `(mapconcat 'identity
1982 (cons 2026 (cons
1983 (,@ (concat "auto\\|c\\(har\\|onst\\)\\|double\\|" ; 6 ()s deep. 2027 (,@ (concat "auto\\|c\\(har\\|onst\\)\\|double\\|"
1984 "e\\(num\\|xtern\\)\\|float\\|int\\|long\\|register\\|" 2028 "e\\(num\\|xtern\\)\\|float\\|int\\|long\\|register\\|"
1985 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|typedef\\|" 2029 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|typedef\\|"
1986 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)")) 2030 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)"))
1987 c-font-lock-extra-types) 2031 c-font-lock-extra-types)
1988 "\\|")) 2032 "\\|"))
1989 ) 2033 (c-type-depth `(font-lock-keyword-depth (,@ c-type-types)))
2034 )
1990 (setq c-font-lock-keywords-1 2035 (setq c-font-lock-keywords-1
1991 (list 2036 (list
1992 ;; 2037 ;;
@@ -2051,15 +2096,17 @@ See also `c-font-lock-extra-types'.")
2051 (list (concat "\\<\\(" (,@ c-type-types) "\\)\\>" 2096 (list (concat "\\<\\(" (,@ c-type-types) "\\)\\>"
2052 "\\([ \t*&]+\\sw+\\>\\)*") 2097 "\\([ \t*&]+\\sw+\\>\\)*")
2053 ;; Fontify each declaration item. 2098 ;; Fontify each declaration item.
2054 '(font-lock-match-c-style-declaration-item-and-skip-to-next 2099 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
2055 ;; Start with point after all type specifiers. 2100 ;; Start with point after all type specifiers.
2056 (goto-char (or (match-beginning 8) (match-end 1))) 2101 (list 'goto-char (list 'or (list 'match-beginning
2057 ;; Finish with point after first type specifier. 2102 (+ (,@ c-type-depth) 2))
2058 (goto-char (match-end 1)) 2103 '(match-end 1)))
2059 ;; Fontify as a variable or function name. 2104 ;; Finish with point after first type specifier.
2060 (1 (if (match-beginning 2) 2105 '(goto-char (match-end 1))
2061 font-lock-function-name-face 2106 ;; Fontify as a variable or function name.
2062 font-lock-variable-name-face))))) 2107 '(1 (if (match-beginning 2)
2108 font-lock-function-name-face
2109 font-lock-variable-name-face)))))
2063 ;; 2110 ;;
2064 ;; Fontify structures, or typedef names, plus their items. 2111 ;; Fontify structures, or typedef names, plus their items.
2065 '("\\(}\\)[ \t*]*\\sw" 2112 '("\\(}\\)[ \t*]*\\sw"
@@ -2109,7 +2156,7 @@ See also `c++-font-lock-extra-types'.")
2109 (when (looking-at (eval-when-compile 2156 (when (looking-at (eval-when-compile
2110 (concat "[ \t*&]*\\(\\sw+\\)" 2157 (concat "[ \t*&]*\\(\\sw+\\)"
2111 "\\(<\\(\\sw+\\)[ \t*&]*>\\)?" 2158 "\\(<\\(\\sw+\\)[ \t*&]*>\\)?"
2112 "\\(::\\*?\\(\\sw+\\)\\)?" 2159 "\\([ \t]*::[ \t*]*\\(\\sw+\\)\\)?"
2113 "[ \t]*\\((\\)?"))) 2160 "[ \t]*\\((\\)?")))
2114 (save-match-data 2161 (save-match-data
2115 (condition-case nil 2162 (condition-case nil
@@ -2161,9 +2208,12 @@ See also `c++-font-lock-extra-types'.")
2161 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 12 ()s deep. 2208 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 12 ()s deep.
2162 c++-font-lock-extra-types) 2209 c++-font-lock-extra-types)
2163 "\\|")) 2210 "\\|"))
2164 (c++-type-suffix "\\(<\\(\\sw+\\)[ \t*&]*>\\)?\\(::\\*?\\(\\sw+\\)\\)?") 2211 (c++-type-suffix (concat "\\(<\\(\\sw+\\)[ \t*&]*>\\)?"
2212 "\\([ \t]*::[ \t*]*\\(\\sw+\\)\\)?"))
2213 (c++-type-depth `(font-lock-keyword-depth
2214 (concat (,@ c++-type-types) (,@ c++-type-suffix))))
2165 (c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix)) 2215 (c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix))
2166 ) 2216 )
2167 (setq c++-font-lock-keywords-1 2217 (setq c++-font-lock-keywords-1
2168 (append 2218 (append
2169 ;; 2219 ;;
@@ -2229,20 +2279,22 @@ See also `c++-font-lock-extra-types'.")
2229 (list (concat "\\<\\(" (,@ c++-type-types) "\\)\\>" (,@ c++-type-suffix) 2279 (list (concat "\\<\\(" (,@ c++-type-types) "\\)\\>" (,@ c++-type-suffix)
2230 "\\([ \t*&]+" (,@ c++-type-spec) "\\)*") 2280 "\\([ \t*&]+" (,@ c++-type-spec) "\\)*")
2231 ;; Fontify each declaration item. 2281 ;; Fontify each declaration item.
2232 '(font-lock-match-c++-style-declaration-item-and-skip-to-next 2282 (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next
2233 ;; Start with point after all type specifiers. 2283 ;; Start with point after all type specifiers.
2234 (goto-char (or (match-beginning 18) (match-end 1))) 2284 (list 'goto-char (list 'or (list 'match-beginning
2235 ;; Finish with point after first type specifier. 2285 (+ (,@ c++-type-depth) 2))
2236 (goto-char (match-end 1)) 2286 '(match-end 1)))
2237 ;; Fontify as a variable or function name. 2287 ;; Finish with point after first type specifier.
2238 (1 (cond ((or (match-beginning 2) (match-beginning 4)) 2288 '(goto-char (match-end 1))
2239 font-lock-type-face) 2289 ;; Fontify as a variable or function name.
2240 ((match-beginning 6) font-lock-function-name-face) 2290 '(1 (cond ((or (match-beginning 2) (match-beginning 4))
2241 (t font-lock-variable-name-face))) 2291 font-lock-type-face)
2242 (3 font-lock-function-name-face nil t) 2292 ((match-beginning 6) font-lock-function-name-face)
2243 (5 (if (match-beginning 6) 2293 (t font-lock-variable-name-face)))
2244 font-lock-function-name-face 2294 '(3 font-lock-function-name-face nil t)
2245 font-lock-variable-name-face) nil t)))) 2295 '(5 (if (match-beginning 6)
2296 font-lock-function-name-face
2297 font-lock-variable-name-face) nil t))))
2246 ;; 2298 ;;
2247 ;; Fontify structures, or typedef names, plus their items. 2299 ;; Fontify structures, or typedef names, plus their items.
2248 '("\\(}\\)[ \t*]*\\sw" 2300 '("\\(}\\)[ \t*]*\\sw"
@@ -2287,28 +2339,28 @@ See also `objc-font-lock-extra-types'.")
2287 2339
2288;; Regexps written with help from Stephen Peters <speters@us.oracle.com> and 2340;; Regexps written with help from Stephen Peters <speters@us.oracle.com> and
2289;; Jacques Duthen Prestataire <duthen@cegelec-red.fr>. 2341;; Jacques Duthen Prestataire <duthen@cegelec-red.fr>.
2290(let ((objc-keywords 2342(let* ((objc-keywords
2291; (make-regexp
2292; '("break" "continue" "do" "else" "for" "if" "return" "switch" "while" 2343; '("break" "continue" "do" "else" "for" "if" "return" "switch" "while"
2293; "sizeof" "self" "super")) 2344; "sizeof" "self" "super")
2294 (concat "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|" 2345 (concat "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|"
2295 "s\\(elf\\|izeof\\|uper\\|witch\\)\\|while")) 2346 "s\\(elf\\|izeof\\|uper\\|witch\\)\\|while"))
2296 (objc-type-types 2347 (objc-type-types
2297 `(mapconcat 'identity 2348 `(mapconcat 'identity
2298 (cons 2349 (cons
2299; '("auto" "extern" "register" "static" "typedef" "struct" "union" 2350; '("auto" "extern" "register" "static" "typedef" "struct" "union"
2300; "enum" "signed" "unsigned" "short" "long" "int" "char" 2351; "enum" "signed" "unsigned" "short" "long" "int" "char"
2301; "float" "double" "void" "volatile" "const" 2352; "float" "double" "void" "volatile" "const"
2302; "id" "oneway" "in" "out" "inout" "bycopy" "byref") 2353; "id" "oneway" "in" "out" "inout" "bycopy" "byref")
2303 (,@ (concat "auto\\|by\\(copy\\|ref\\)\\|c\\(har\\|onst\\)\\|" 2354 (,@ (concat "auto\\|by\\(copy\\|ref\\)\\|c\\(har\\|onst\\)\\|"
2304 "double\\|e\\(num\\|xtern\\)\\|float\\|" 2355 "double\\|e\\(num\\|xtern\\)\\|float\\|"
2305 "i\\([dn]\\|n\\(out\\|t\\)\\)\\|long\\|" 2356 "i\\([dn]\\|n\\(out\\|t\\)\\)\\|long\\|"
2306 "o\\(neway\\|ut\\)\\|register\\|s\\(hort\\|igned\\|" 2357 "o\\(neway\\|ut\\)\\|register\\|s\\(hort\\|igned\\|"
2307 "t\\(atic\\|ruct\\)\\)\\|typedef\\|" 2358 "t\\(atic\\|ruct\\)\\)\\|typedef\\|"
2308 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)")) 2359 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)"))
2309 objc-font-lock-extra-types) 2360 objc-font-lock-extra-types)
2310 "\\|")) 2361 "\\|"))
2311 ) 2362 (objc-type-depth `(font-lock-keyword-depth (,@ objc-type-types)))
2363 )
2312 (setq objc-font-lock-keywords-1 2364 (setq objc-font-lock-keywords-1
2313 (append 2365 (append
2314 ;; 2366 ;;
@@ -2379,15 +2431,17 @@ See also `objc-font-lock-extra-types'.")
2379 (list (concat "\\<\\(" (,@ objc-type-types) "\\)\\>" 2431 (list (concat "\\<\\(" (,@ objc-type-types) "\\)\\>"
2380 "\\([ \t*&]+\\sw+\\>\\)*") 2432 "\\([ \t*&]+\\sw+\\>\\)*")
2381 ;; Fontify each declaration item. 2433 ;; Fontify each declaration item.
2382 '(font-lock-match-c-style-declaration-item-and-skip-to-next 2434 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
2383 ;; Start with point after all type specifiers. 2435 ;; Start with point after all type specifiers.
2384 (goto-char (or (match-beginning 2) (match-end 1))) 2436 (list 'goto-char (list 'or (list 'match-beginning
2385 ;; Finish with point after first type specifier. 2437 (+ (,@ objc-type-depth) 2))
2386 (goto-char (match-end 1)) 2438 '(match-end 1)))
2387 ;; Fontify as a variable or function name. 2439 ;; Finish with point after first type specifier.
2388 (1 (if (match-beginning 2) 2440 '(goto-char (match-end 1))
2389 font-lock-function-name-face 2441 ;; Fontify as a variable or function name.
2390 font-lock-variable-name-face))))) 2442 '(1 (if (match-beginning 2)
2443 font-lock-function-name-face
2444 font-lock-variable-name-face)))))
2391 ;; 2445 ;;
2392 ;; Fontify structures, or typedef names, plus their items. 2446 ;; Fontify structures, or typedef names, plus their items.
2393 '("\\(}\\)[ \t*]*\\sw" 2447 '("\\(}\\)[ \t*]*\\sw"
@@ -2427,40 +2481,40 @@ See also `java-font-lock-extra-types'.")
2427 2481
2428;; Regexps written with help from Fred White <fwhite@bbn.com> and 2482;; Regexps written with help from Fred White <fwhite@bbn.com> and
2429;; Anders Lindgren <andersl@csd.uu.se>. 2483;; Anders Lindgren <andersl@csd.uu.se>.
2430(let ((java-keywords 2484(let* ((java-keywords
2431 (concat "\\<\\(" 2485 (concat "\\<\\("
2432; (make-regexp
2433; '("catch" "do" "else" "super" "this" "finally" "for" "if" 2486; '("catch" "do" "else" "super" "this" "finally" "for" "if"
2434;; ;; Anders Lindgren <andersl@csd.uu.se> says these have gone. 2487;; ;; Anders Lindgren <andersl@csd.uu.se> says these have gone.
2435;; "cast" "byvalue" "future" "generic" "operator" "var" 2488;; "cast" "byvalue" "future" "generic" "operator" "var"
2436;; "inner" "outer" "rest" 2489;; "inner" "outer" "rest"
2437; "interface" "return" "switch" "throw" "try" "while") 2490; "interface" "return" "switch" "throw" "try" "while")
2438 "catch\\|do\\|else\\|f\\(inally\\|or\\)\\|" 2491 "catch\\|do\\|else\\|f\\(inally\\|or\\)\\|"
2439 "i\\(f\\|nterface\\)\\|return\\|s\\(uper\\|witch\\)\\|" 2492 "i\\(f\\|nterface\\)\\|return\\|s\\(uper\\|witch\\)\\|"
2440 "t\\(h\\(is\\|row\\)\\|ry\\)\\|while" 2493 "t\\(h\\(is\\|row\\)\\|ry\\)\\|while"
2441 "\\)\\>")) 2494 "\\)\\>"))
2442 ;; 2495 ;;
2443 ;; These are immediately followed by an object name. 2496 ;; These are immediately followed by an object name.
2444 (java-minor-types 2497 (java-minor-types
2445 (mapconcat 'identity 2498 (mapconcat 'identity
2446 '("boolean" "char" "byte" "short" "int" "long" "float" "double" "void") 2499 '("boolean" "char" "byte" "short" "int" "long"
2447 "\\|")) 2500 "float" "double" "void")
2448 ;; 2501 "\\|"))
2449 ;; These are eventually followed by an object name. 2502 ;;
2450 (java-major-types 2503 ;; These are eventually followed by an object name.
2451; (make-regexp 2504 (java-major-types
2452; '("abstract" "const" "final" "synchronized" "transient" "static" 2505; '("abstract" "const" "final" "synchronized" "transient" "static"
2453;; ;; Anders Lindgren <andersl@csd.uu.se> says this has gone. 2506;; ;; Anders Lindgren <andersl@csd.uu.se> says this has gone.
2454;; "threadsafe" 2507;; "threadsafe"
2455; "volatile" "public" "private" "protected" "native") 2508; "volatile" "public" "private" "protected" "native")
2456 (concat "abstract\\|const\\|final\\|native\\|" 2509 (concat "abstract\\|const\\|final\\|native\\|"
2457 "p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|" 2510 "p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|"
2458 "s\\(tatic\\|ynchronized\\)\\|transient\\|volatile")) 2511 "s\\(tatic\\|ynchronized\\)\\|transient\\|volatile"))
2459 ;; 2512 ;;
2460 ;; Random types immediately followed by an object name. 2513 ;; Random types immediately followed by an object name.
2461 (java-other-types 2514 (java-other-types
2462 '(mapconcat 'identity (cons "\\sw+\\.\\sw+" java-font-lock-extra-types) 2515 '(mapconcat 'identity (cons "\\sw+\\.\\sw+" java-font-lock-extra-types)
2463 "\\|")) 2516 "\\|"))
2517 (java-other-depth `(font-lock-keyword-depth (,@ java-other-types)))
2464 ) 2518 )
2465 (setq java-font-lock-keywords-1 2519 (setq java-font-lock-keywords-1
2466 (list 2520 (list
@@ -2539,13 +2593,16 @@ See also `java-font-lock-extra-types'.")
2539 "\\([ \t]*\\[[ \t]*\\]\\)*" 2593 "\\([ \t]*\\[[ \t]*\\]\\)*"
2540 "\\([ \t]*\\sw\\)") 2594 "\\([ \t]*\\sw\\)")
2541 ;; Fontify each declaration item. 2595 ;; Fontify each declaration item.
2542 '(font-lock-match-c-style-declaration-item-and-skip-to-next 2596 (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
2543 ;; Start and finish with point after the type specifier. 2597 ;; Start and finish with point after the type specifier.
2544 (goto-char (match-beginning 3)) (goto-char (match-beginning 3)) 2598 (list 'goto-char (list 'match-beginning
2545 ;; Fontify as a variable or function name. 2599 (+ (,@ java-other-depth) 3)))
2546 (1 (if (match-beginning 2) 2600 (list 'goto-char (list 'match-beginning
2547 font-lock-function-name-face 2601 (+ (,@ java-other-depth) 3)))
2548 font-lock-variable-name-face))))) 2602 ;; Fontify as a variable or function name.
2603 '(1 (if (match-beginning 2)
2604 font-lock-function-name-face
2605 font-lock-variable-name-face)))))
2549 ;; 2606 ;;
2550 ;; Fontify those that are immediately followed by an item or items. 2607 ;; Fontify those that are immediately followed by an item or items.
2551 (list (concat "\\<\\(" java-minor-types "\\)\\>" 2608 (list (concat "\\<\\(" java-minor-types "\\)\\>"
@@ -2567,7 +2624,7 @@ See also `java-font-lock-extra-types'.")
2567 ;; Fontify each declaration item. 2624 ;; Fontify each declaration item.
2568 '(font-lock-match-c-style-declaration-item-and-skip-to-next 2625 '(font-lock-match-c-style-declaration-item-and-skip-to-next
2569 ;; Start with point after all type specifiers. 2626 ;; Start with point after all type specifiers.
2570 (goto-char (or (match-beginning 2) (match-end 1))) 2627 (goto-char (or (match-beginning 5) (match-end 1)))
2571 ;; Finish with point after first type specifier. 2628 ;; Finish with point after first type specifier.
2572 (goto-char (match-end 1)) 2629 (goto-char (match-end 1))
2573 ;; Fontify as a variable or function name. 2630 ;; Fontify as a variable or function name.