Mercurial > emacs
comparison lisp/font-lock.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 2f877ed80fa6 |
children | 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
1 ;;; font-lock.el --- Electric font lock mode | 1 ;;; font-lock.el --- Electric font lock mode |
2 | 2 |
3 ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003 | 3 ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003, 2004 |
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: jwz, then rms, then sm | 6 ;; Author: jwz, then rms, then sm |
7 ;; Maintainer: FSF | 7 ;; Maintainer: FSF |
8 ;; Keywords: languages, faces | 8 ;; Keywords: languages, faces |
208 ;;; Code: | 208 ;;; Code: |
209 | 209 |
210 (require 'syntax) | 210 (require 'syntax) |
211 | 211 |
212 ;; Define core `font-lock' group. | 212 ;; Define core `font-lock' group. |
213 (defgroup font-lock nil | 213 (defgroup font-lock '((jit-lock custom-group)) |
214 "Font Lock mode text highlighting package." | 214 "Font Lock mode text highlighting package." |
215 :link '(custom-manual "(emacs)Font Lock") | 215 :link '(custom-manual "(emacs)Font Lock") |
216 :link '(custom-manual "(elisp)Font Lock Mode") | 216 :link '(custom-manual "(elisp)Font Lock Mode") |
217 :group 'faces) | 217 :group 'faces) |
218 | 218 |
226 :group 'font-lock) | 226 :group 'font-lock) |
227 | 227 |
228 ;; Define support mode groups here to impose `font-lock' group order. | 228 ;; Define support mode groups here to impose `font-lock' group order. |
229 (defgroup fast-lock nil | 229 (defgroup fast-lock nil |
230 "Font Lock support mode to cache fontification." | 230 "Font Lock support mode to cache fontification." |
231 :link '(custom-manual "(emacs)Support Modes") | |
232 :load 'fast-lock | 231 :load 'fast-lock |
233 :group 'font-lock) | 232 :group 'font-lock) |
234 | 233 |
235 (defgroup lazy-lock nil | 234 (defgroup lazy-lock nil |
236 "Font Lock support mode to fontify lazily." | 235 "Font Lock support mode to fontify lazily." |
237 :link '(custom-manual "(emacs)Support Modes") | |
238 :load 'lazy-lock | 236 :load 'lazy-lock |
239 :group 'font-lock) | |
240 | |
241 (defgroup jit-lock nil | |
242 "Font Lock support mode to fontify just-in-time." | |
243 :link '(custom-manual "(emacs)Support Modes") | |
244 :version "21.1" | |
245 :load 'jit-lock | |
246 :group 'font-lock) | 237 :group 'font-lock) |
247 | 238 |
248 ;; User variables. | 239 ;; User variables. |
249 | 240 |
250 (defcustom font-lock-maximum-size 256000 | 241 (defcustom font-lock-maximum-size 256000 |
1029 '(syntax-table face font-lock-multiline) | 1020 '(syntax-table face font-lock-multiline) |
1030 '(face font-lock-multiline)))))) | 1021 '(face font-lock-multiline)))))) |
1031 | 1022 |
1032 ;; Called when any modification is made to buffer text. | 1023 ;; Called when any modification is made to buffer text. |
1033 (defun font-lock-after-change-function (beg end old-len) | 1024 (defun font-lock-after-change-function (beg end old-len) |
1034 (let ((inhibit-point-motion-hooks t)) | 1025 (let ((inhibit-point-motion-hooks t) |
1026 (inhibit-quit t)) | |
1035 (save-excursion | 1027 (save-excursion |
1036 (save-match-data | 1028 (save-match-data |
1037 ;; Rescan between start of lines enclosing the region. | 1029 ;; Rescan between start of lines enclosing the region. |
1038 (font-lock-fontify-region | 1030 (font-lock-fontify-region |
1039 (progn (goto-char beg) (beginning-of-line) (point)) | 1031 (progn (goto-char beg) (beginning-of-line) (point)) |
1564 (custom-declare-face face (list (list t face-spec)) nil))))))) | 1556 (custom-declare-face face (list (list t face-spec)) nil))))))) |
1565 | 1557 |
1566 ;; But now we do it the custom way. Note that `defface' will not overwrite any | 1558 ;; But now we do it the custom way. Note that `defface' will not overwrite any |
1567 ;; faces declared above via `custom-declare-face'. | 1559 ;; faces declared above via `custom-declare-face'. |
1568 (defface font-lock-comment-face | 1560 (defface font-lock-comment-face |
1569 '((((type tty pc) (class color) (background light)) (:foreground "red")) | 1561 '((((class grayscale) (background light)) |
1570 (((type tty pc) (class color) (background dark)) (:foreground "red1")) | |
1571 (((class grayscale) (background light)) | |
1572 (:foreground "DimGray" :weight bold :slant italic)) | 1562 (:foreground "DimGray" :weight bold :slant italic)) |
1573 (((class grayscale) (background dark)) | 1563 (((class grayscale) (background dark)) |
1574 (:foreground "LightGray" :weight bold :slant italic)) | 1564 (:foreground "LightGray" :weight bold :slant italic)) |
1575 (((class color) (background light)) (:foreground "Firebrick")) | 1565 (((class color) (min-colors 88) (background light)) |
1576 (((class color) (background dark)) (:foreground "chocolate1")) | 1566 (:foreground "Firebrick")) |
1567 (((class color) (min-colors 88) (background dark)) | |
1568 (:foreground "chocolate1")) | |
1569 (((class color) (min-colors 16) (background light)) | |
1570 (:foreground "red")) | |
1571 (((class color) (min-colors 16) (background dark)) | |
1572 (:foreground "red1")) | |
1573 (((class color) (min-colors 8) (background light)) | |
1574 (:foreground "red")) | |
1575 (((class color) (min-colors 8) (background dark)) | |
1576 (:foreground "red1")) | |
1577 (t (:weight bold :slant italic))) | 1577 (t (:weight bold :slant italic))) |
1578 "Font Lock mode face used to highlight comments." | 1578 "Font Lock mode face used to highlight comments." |
1579 :group 'font-lock-highlighting-faces) | 1579 :group 'font-lock-highlighting-faces) |
1580 | 1580 |
1581 (defface font-lock-string-face | 1581 (defface font-lock-string-face |
1582 '((((type tty) (class color)) (:foreground "green")) | 1582 '((((class grayscale) (background light)) (:foreground "DimGray" :slant italic)) |
1583 (((class grayscale) (background light)) (:foreground "DimGray" :slant italic)) | |
1584 (((class grayscale) (background dark)) (:foreground "LightGray" :slant italic)) | 1583 (((class grayscale) (background dark)) (:foreground "LightGray" :slant italic)) |
1585 (((class color) (background light)) (:foreground "RosyBrown")) | 1584 (((class color) (min-colors 88) (background light)) (:foreground "RosyBrown")) |
1586 (((class color) (background dark)) (:foreground "LightSalmon")) | 1585 (((class color) (min-colors 88) (background dark)) (:foreground "LightSalmon")) |
1586 (((class color) (min-colors 16) (background light)) (:foreground "RosyBrown")) | |
1587 (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon")) | |
1588 (((class color) (min-colors 8)) (:foreground "green")) | |
1587 (t (:slant italic))) | 1589 (t (:slant italic))) |
1588 "Font Lock mode face used to highlight strings." | 1590 "Font Lock mode face used to highlight strings." |
1589 :group 'font-lock-highlighting-faces) | 1591 :group 'font-lock-highlighting-faces) |
1590 | 1592 |
1591 (defface font-lock-doc-face | 1593 (defface font-lock-doc-face |
1592 '((t :inherit font-lock-string-face)) | 1594 '((t :inherit font-lock-string-face)) |
1593 "Font Lock mode face used to highlight documentation." | 1595 "Font Lock mode face used to highlight documentation." |
1594 :group 'font-lock-highlighting-faces) | 1596 :group 'font-lock-highlighting-faces) |
1595 | 1597 |
1596 (defface font-lock-keyword-face | 1598 (defface font-lock-keyword-face |
1597 '((((type tty) (class color)) (:foreground "cyan" :weight bold)) | 1599 '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) |
1598 (((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) | |
1599 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) | 1600 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) |
1600 (((class color) (background light)) (:foreground "Purple")) | 1601 (((class color) (min-colors 88) (background light)) (:foreground "Purple")) |
1601 (((class color) (background dark)) (:foreground "Cyan")) | 1602 (((class color) (min-colors 88) (background dark)) (:foreground "Cyan")) |
1603 (((class color) (min-colors 16) (background light)) (:foreground "Purple")) | |
1604 (((class color) (min-colors 16) (background dark)) (:foreground "Cyan")) | |
1605 (((class color) (min-colors 8)) (:foreground "cyan" :weight bold)) | |
1602 (t (:weight bold))) | 1606 (t (:weight bold))) |
1603 "Font Lock mode face used to highlight keywords." | 1607 "Font Lock mode face used to highlight keywords." |
1604 :group 'font-lock-highlighting-faces) | 1608 :group 'font-lock-highlighting-faces) |
1605 | 1609 |
1606 (defface font-lock-builtin-face | 1610 (defface font-lock-builtin-face |
1607 '((((type tty) (class color)) (:foreground "blue" :weight light)) | 1611 '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) |
1608 (((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) | |
1609 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) | 1612 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) |
1610 (((class color) (background light)) (:foreground "Orchid")) | 1613 (((class color) (min-colors 88) (background light)) (:foreground "Orchid")) |
1611 (((class color) (background dark)) (:foreground "LightSteelBlue")) | 1614 (((class color) (min-colors 88) (background dark)) (:foreground "LightSteelBlue")) |
1615 (((class color) (min-colors 16) (background light)) (:foreground "Orchid")) | |
1616 (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue")) | |
1617 (((class color) (min-colors 8)) (:foreground "blue" :weight bold)) | |
1612 (t (:weight bold))) | 1618 (t (:weight bold))) |
1613 "Font Lock mode face used to highlight builtins." | 1619 "Font Lock mode face used to highlight builtins." |
1614 :group 'font-lock-highlighting-faces) | 1620 :group 'font-lock-highlighting-faces) |
1615 | 1621 |
1616 (defface font-lock-function-name-face | 1622 (defface font-lock-function-name-face |
1617 '((((type tty) (class color)) (:foreground "blue" :weight bold)) | 1623 '((((class color) (min-colors 88) (background light)) (:foreground "Blue")) |
1618 (((class color) (background light)) (:foreground "Blue")) | 1624 (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue")) |
1619 (((class color) (background dark)) (:foreground "LightSkyBlue")) | 1625 (((class color) (min-colors 16) (background light)) (:foreground "Blue")) |
1626 (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue")) | |
1627 (((class color) (min-colors 8)) (:foreground "blue" :weight bold)) | |
1620 (t (:inverse-video t :weight bold))) | 1628 (t (:inverse-video t :weight bold))) |
1621 "Font Lock mode face used to highlight function names." | 1629 "Font Lock mode face used to highlight function names." |
1622 :group 'font-lock-highlighting-faces) | 1630 :group 'font-lock-highlighting-faces) |
1623 | 1631 |
1624 (defface font-lock-variable-name-face | 1632 (defface font-lock-variable-name-face |
1625 '((((type tty) (class color)) (:foreground "yellow" :weight light)) | 1633 '((((class grayscale) (background light)) |
1626 (((class grayscale) (background light)) | |
1627 (:foreground "Gray90" :weight bold :slant italic)) | 1634 (:foreground "Gray90" :weight bold :slant italic)) |
1628 (((class grayscale) (background dark)) | 1635 (((class grayscale) (background dark)) |
1629 (:foreground "DimGray" :weight bold :slant italic)) | 1636 (:foreground "DimGray" :weight bold :slant italic)) |
1630 (((class color) (background light)) (:foreground "DarkGoldenrod")) | 1637 (((class color) (min-colors 88) (background light)) (:foreground "DarkGoldenrod")) |
1631 (((class color) (background dark)) (:foreground "LightGoldenrod")) | 1638 (((class color) (min-colors 88) (background dark)) (:foreground "LightGoldenrod")) |
1639 (((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) | |
1640 (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) | |
1641 (((class color) (min-colors 8)) (:foreground "yellow" :weight light)) | |
1632 (t (:weight bold :slant italic))) | 1642 (t (:weight bold :slant italic))) |
1633 "Font Lock mode face used to highlight variable names." | 1643 "Font Lock mode face used to highlight variable names." |
1634 :group 'font-lock-highlighting-faces) | 1644 :group 'font-lock-highlighting-faces) |
1635 | 1645 |
1636 (defface font-lock-type-face | 1646 (defface font-lock-type-face |
1637 '((((type tty) (class color)) (:foreground "green")) | 1647 '((((class grayscale) (background light)) (:foreground "Gray90" :weight bold)) |
1638 (((class grayscale) (background light)) (:foreground "Gray90" :weight bold)) | |
1639 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) | 1648 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) |
1640 (((class color) (background light)) (:foreground "ForestGreen")) | 1649 (((class color) (min-colors 88) (background light)) (:foreground "ForestGreen")) |
1641 (((class color) (background dark)) (:foreground "PaleGreen")) | 1650 (((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen")) |
1651 (((class color) (min-colors 16) (background light)) (:foreground "ForestGreen")) | |
1652 (((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen")) | |
1653 (((class color) (min-colors 8)) (:foreground "green")) | |
1642 (t (:weight bold :underline t))) | 1654 (t (:weight bold :underline t))) |
1643 "Font Lock mode face used to highlight type and classes." | 1655 "Font Lock mode face used to highlight type and classes." |
1644 :group 'font-lock-highlighting-faces) | 1656 :group 'font-lock-highlighting-faces) |
1645 | 1657 |
1646 (defface font-lock-constant-face | 1658 (defface font-lock-constant-face |
1647 '((((type tty) (class color)) (:foreground "magenta")) | 1659 '((((class grayscale) (background light)) |
1648 (((class grayscale) (background light)) | |
1649 (:foreground "LightGray" :weight bold :underline t)) | 1660 (:foreground "LightGray" :weight bold :underline t)) |
1650 (((class grayscale) (background dark)) | 1661 (((class grayscale) (background dark)) |
1651 (:foreground "Gray50" :weight bold :underline t)) | 1662 (:foreground "Gray50" :weight bold :underline t)) |
1652 (((class color) (background light)) (:foreground "CadetBlue")) | 1663 (((class color) (min-colors 88) (background light)) (:foreground "CadetBlue")) |
1653 (((class color) (background dark)) (:foreground "Aquamarine")) | 1664 (((class color) (min-colors 88) (background dark)) (:foreground "Aquamarine")) |
1665 (((class color) (min-colors 16) (background light)) (:foreground "CadetBlue")) | |
1666 (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine")) | |
1667 (((class color) (min-colors 8)) (:foreground "magenta")) | |
1654 (t (:weight bold :underline t))) | 1668 (t (:weight bold :underline t))) |
1655 "Font Lock mode face used to highlight constants and labels." | 1669 "Font Lock mode face used to highlight constants and labels." |
1656 :group 'font-lock-highlighting-faces) | 1670 :group 'font-lock-highlighting-faces) |
1657 | 1671 |
1658 (defface font-lock-warning-face | 1672 (defface font-lock-warning-face |
1659 '((((type tty) (class color)) (:foreground "red")) | 1673 '((((class color) (min-colors 88) (background light)) (:foreground "Red" :weight bold)) |
1660 (((class color) (background light)) (:foreground "Red" :weight bold)) | 1674 (((class color) (min-colors 88) (background dark)) (:foreground "Pink" :weight bold)) |
1661 (((class color) (background dark)) (:foreground "Pink" :weight bold)) | 1675 (((class color) (min-colors 16) (background light)) (:foreground "Red" :weight bold)) |
1676 (((class color) (min-colors 16) (background dark)) (:foreground "Pink" :weight bold)) (((class color) (min-colors 8)) (:foreground "red")) | |
1662 (t (:inverse-video t :weight bold))) | 1677 (t (:inverse-video t :weight bold))) |
1663 "Font Lock mode face used to highlight warnings." | 1678 "Font Lock mode face used to highlight warnings." |
1664 :group 'font-lock-highlighting-faces) | 1679 :group 'font-lock-highlighting-faces) |
1665 | 1680 |
1666 (defface font-lock-preprocessor-face | 1681 (defface font-lock-preprocessor-face |
1872 "save-window-excursion" "save-selected-window" | 1887 "save-window-excursion" "save-selected-window" |
1873 "save-match-data" "save-current-buffer" "unwind-protect" | 1888 "save-match-data" "save-current-buffer" "unwind-protect" |
1874 "condition-case" "track-mouse" | 1889 "condition-case" "track-mouse" |
1875 "eval-after-load" "eval-and-compile" "eval-when-compile" | 1890 "eval-after-load" "eval-and-compile" "eval-when-compile" |
1876 "eval-when" | 1891 "eval-when" |
1892 "with-category-table" | |
1877 "with-current-buffer" "with-electric-help" | 1893 "with-current-buffer" "with-electric-help" |
1894 "with-local-quit" "with-no-warnings" | |
1878 "with-output-to-string" "with-output-to-temp-buffer" | 1895 "with-output-to-string" "with-output-to-temp-buffer" |
1896 "with-selected-window" "with-syntax-table" | |
1879 "with-temp-buffer" "with-temp-file" "with-temp-message" | 1897 "with-temp-buffer" "with-temp-file" "with-temp-message" |
1880 "with-timeout") t) | 1898 "with-timeout" "with-timeout-handler") t) |
1881 "\\>") | 1899 "\\>") |
1882 1) | 1900 1) |
1883 ;; | 1901 ;; |
1884 ;; Control structures. Common Lisp forms. | 1902 ;; Control structures. Common Lisp forms. |
1885 (cons (concat | 1903 (cons (concat |
1890 "cerror" "break" "ignore-errors" | 1908 "cerror" "break" "ignore-errors" |
1891 "loop" "do" "do*" "dotimes" "dolist" "the" "locally" | 1909 "loop" "do" "do*" "dotimes" "dolist" "the" "locally" |
1892 "proclaim" "declaim" "declare" "symbol-macrolet" | 1910 "proclaim" "declaim" "declare" "symbol-macrolet" |
1893 "lexical-let" "lexical-let*" "flet" "labels" "compiler-let" | 1911 "lexical-let" "lexical-let*" "flet" "labels" "compiler-let" |
1894 "destructuring-bind" "macrolet" "tagbody" "block" | 1912 "destructuring-bind" "macrolet" "tagbody" "block" |
1895 "return" "return-from") t) | 1913 "return" "return-from" |
1914 "with-accessors" "with-compilation-unit" | |
1915 "with-condition-restarts" "with-hash-table-iterator" | |
1916 "with-input-from-string" "with-open-file" | |
1917 "with-open-stream" "with-output-to-string" | |
1918 "with-package-iterator" "with-simple-restart" | |
1919 "with-slots" "with-standard-io-syntax") t) | |
1896 "\\>") | 1920 "\\>") |
1897 1) | 1921 1) |
1898 ;; | 1922 ;; |
1899 ;; Exit/Feature symbols as constants. | 1923 ;; Exit/Feature symbols as constants. |
1900 (list (concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\>" | 1924 (list (concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\>" |
1915 '("\\<:\\sw+\\>" 0 font-lock-builtin-face) | 1939 '("\\<:\\sw+\\>" 0 font-lock-builtin-face) |
1916 ;; | 1940 ;; |
1917 ;; ELisp and CLisp `&' keywords as types. | 1941 ;; ELisp and CLisp `&' keywords as types. |
1918 '("\\&\\sw+\\>" . font-lock-type-face) | 1942 '("\\&\\sw+\\>" . font-lock-type-face) |
1919 ;; | 1943 ;; |
1920 ;; CL `with-' and `do-' constructs | 1944 ;;; This is too general -- rms. |
1921 '("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face) | 1945 ;;; A user complained that he has functions whose names start with `do' |
1946 ;;; and that they get the wrong color. | |
1947 ;;; ;; CL `with-' and `do-' constructs | |
1948 ;;; '("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face) | |
1922 ))) | 1949 ))) |
1923 "Gaudy level highlighting for Lisp modes.") | 1950 "Gaudy level highlighting for Lisp modes.") |
1924 | 1951 |
1925 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1 | 1952 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1 |
1926 "Default expressions to highlight in Lisp modes.") | 1953 "Default expressions to highlight in Lisp modes.") |
1927 | 1954 |
1928 (provide 'font-lock) | 1955 (provide 'font-lock) |
1929 | 1956 |
1930 (when (eq font-lock-support-mode 'jit-lock-mode) | 1957 ;;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c |
1931 (require 'jit-lock)) | |
1932 | |
1933 ;;; font-lock.el ends here | 1958 ;;; font-lock.el ends here |