diff options
| author | Simon Marshall | 1997-06-27 06:59:30 +0000 |
|---|---|---|
| committer | Simon Marshall | 1997-06-27 06:59:30 +0000 |
| commit | 46f26fcf29c75548e793e6625d7b3b1f73db1d05 (patch) | |
| tree | 18c8733ad2edd0d635333c4a8c0086a6e36450a4 | |
| parent | 1e85093646e2b7745d938d5e8eb7a7b4a594d299 (diff) | |
| download | emacs-46f26fcf29c75548e793e6625d7b3b1f73db1d05.tar.gz emacs-46f26fcf29c75548e793e6625d7b3b1f73db1d05.zip | |
split up scheme and tex support; wrap inhibit-point-motion-hooks where nec.
| -rw-r--r-- | lisp/font-lock.el | 294 |
1 files changed, 176 insertions, 118 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 8d5256c8403..6007c1869c1 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -469,7 +469,8 @@ Other variables include those for buffer-specialised fontification functions, | |||
| 469 | ;(font-lock-comment-start-regexp . ";") | 469 | ;(font-lock-comment-start-regexp . ";") |
| 470 | (font-lock-mark-block-function . mark-defun))) | 470 | (font-lock-mark-block-function . mark-defun))) |
| 471 | (scheme-mode-defaults | 471 | (scheme-mode-defaults |
| 472 | '(scheme-font-lock-keywords | 472 | '((scheme-font-lock-keywords |
| 473 | scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) | ||
| 473 | nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun | 474 | nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun |
| 474 | ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. | 475 | ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
| 475 | ;(font-lock-comment-start-regexp . ";") | 476 | ;(font-lock-comment-start-regexp . ";") |
| @@ -480,7 +481,9 @@ Other variables include those for buffer-specialised fontification functions, | |||
| 480 | ;; However, we do specify a MARK-BLOCK function as that cannot result | 481 | ;; However, we do specify a MARK-BLOCK function as that cannot result |
| 481 | ;; in a mis-fontification even if it might not fontify enough. --sm. | 482 | ;; in a mis-fontification even if it might not fontify enough. --sm. |
| 482 | (tex-mode-defaults | 483 | (tex-mode-defaults |
| 483 | '(tex-font-lock-keywords nil nil ((?$ . "\"")) nil | 484 | '((tex-font-lock-keywords |
| 485 | tex-font-lock-keywords-1 tex-font-lock-keywords-2) | ||
| 486 | nil nil ((?$ . "\"")) nil | ||
| 484 | ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. | 487 | ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
| 485 | ;(font-lock-comment-start-regexp . "%") | 488 | ;(font-lock-comment-start-regexp . "%") |
| 486 | (font-lock-mark-block-function . mark-paragraph))) | 489 | (font-lock-mark-block-function . mark-paragraph))) |
| @@ -1081,12 +1084,13 @@ The value of this variable is used when Font Lock mode is turned on." | |||
| 1081 | 1084 | ||
| 1082 | ;; Called when any modification is made to buffer text. | 1085 | ;; Called when any modification is made to buffer text. |
| 1083 | (defun font-lock-after-change-function (beg end old-len) | 1086 | (defun font-lock-after-change-function (beg end old-len) |
| 1084 | (save-excursion | 1087 | (let ((inhibit-point-motion-hooks t)) |
| 1085 | (save-match-data | 1088 | (save-excursion |
| 1086 | ;; Rescan between start of lines enclosing the region. | 1089 | (save-match-data |
| 1087 | (font-lock-fontify-region | 1090 | ;; Rescan between start of lines enclosing the region. |
| 1088 | (progn (goto-char beg) (beginning-of-line) (point)) | 1091 | (font-lock-fontify-region |
| 1089 | (progn (goto-char end) (forward-line 1) (point)))))) | 1092 | (progn (goto-char beg) (beginning-of-line) (point)) |
| 1093 | (progn (goto-char end) (forward-line 1) (point))))))) | ||
| 1090 | 1094 | ||
| 1091 | (defun font-lock-fontify-block (&optional arg) | 1095 | (defun font-lock-fontify-block (&optional arg) |
| 1092 | "Fontify some lines the way `font-lock-fontify-buffer' would. | 1096 | "Fontify some lines the way `font-lock-fontify-buffer' would. |
| @@ -1096,7 +1100,8 @@ no ARG is given and `font-lock-mark-block-function' is nil. | |||
| 1096 | If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to | 1100 | If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to |
| 1097 | delimit the region to fontify." | 1101 | delimit the region to fontify." |
| 1098 | (interactive "P") | 1102 | (interactive "P") |
| 1099 | (let (font-lock-beginning-of-syntax-function deactivate-mark) | 1103 | (let ((inhibit-point-motion-hooks t) font-lock-beginning-of-syntax-function |
| 1104 | deactivate-mark) | ||
| 1100 | ;; Make sure we have the right `font-lock-keywords' etc. | 1105 | ;; Make sure we have the right `font-lock-keywords' etc. |
| 1101 | (if (not font-lock-mode) (font-lock-set-defaults)) | 1106 | (if (not font-lock-mode) (font-lock-set-defaults)) |
| 1102 | (save-excursion | 1107 | (save-excursion |
| @@ -1467,11 +1472,11 @@ START should be at the beginning of a line." | |||
| 1467 | 1472 | ||
| 1468 | (defun font-lock-eval-keywords (keywords) | 1473 | (defun font-lock-eval-keywords (keywords) |
| 1469 | ;; Evalulate KEYWORDS if a function (funcall) or variable (eval) name. | 1474 | ;; Evalulate KEYWORDS if a function (funcall) or variable (eval) name. |
| 1470 | (if (symbolp keywords) | 1475 | (if (listp keywords) |
| 1471 | (font-lock-eval-keywords (if (fboundp keywords) | 1476 | keywords |
| 1472 | (funcall keywords) | 1477 | (font-lock-eval-keywords (if (fboundp keywords) |
| 1473 | (eval keywords))) | 1478 | (funcall keywords) |
| 1474 | keywords)) | 1479 | (eval keywords))))) |
| 1475 | 1480 | ||
| 1476 | (defun font-lock-value-in-major-mode (alist) | 1481 | (defun font-lock-value-in-major-mode (alist) |
| 1477 | ;; Return value in ALIST for `major-mode', or ALIST if it is not an alist. | 1482 | ;; Return value in ALIST for `major-mode', or ALIST if it is not an alist. |
| @@ -1693,7 +1698,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using | |||
| 1693 | (defface font-lock-type-face | 1698 | (defface font-lock-type-face |
| 1694 | '((((class grayscale) (background light)) (:foreground "Gray90" :bold t)) | 1699 | '((((class grayscale) (background light)) (:foreground "Gray90" :bold t)) |
| 1695 | (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | 1700 | (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) |
| 1696 | (((class color) (background light)) (:foreground "DarkOliveGreen")) | 1701 | (((class color) (background light)) (:foreground "ForestGreen")) |
| 1697 | (((class color) (background dark)) (:foreground "PaleGreen")) | 1702 | (((class color) (background dark)) (:foreground "PaleGreen")) |
| 1698 | (t (:bold t :underline t))) | 1703 | (t (:bold t :underline t))) |
| 1699 | "Font Lock mode face used to highlight types." | 1704 | "Font Lock mode face used to highlight types." |
| @@ -1860,7 +1865,8 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1860 | (goto-char (or (scan-sexps (point) 1) (point-max)))) | 1865 | (goto-char (or (scan-sexps (point) 1) (point-max)))) |
| 1861 | (goto-char (match-end 2))) | 1866 | (goto-char (match-end 2))) |
| 1862 | (error t))))) | 1867 | (error t))))) |
| 1863 | 1868 | ||
| 1869 | ;; Lisp. | ||
| 1864 | 1870 | ||
| 1865 | (defconst lisp-font-lock-keywords-1 | 1871 | (defconst lisp-font-lock-keywords-1 |
| 1866 | (eval-when-compile | 1872 | (eval-when-compile |
| @@ -1944,12 +1950,12 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1944 | ))) | 1950 | ))) |
| 1945 | "Gaudy level highlighting for Lisp modes.") | 1951 | "Gaudy level highlighting for Lisp modes.") |
| 1946 | 1952 | ||
| 1947 | |||
| 1948 | (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1 | 1953 | (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1 |
| 1949 | "Default expressions to highlight in Lisp modes.") | 1954 | "Default expressions to highlight in Lisp modes.") |
| 1955 | |||
| 1956 | ;; Scheme. | ||
| 1950 | 1957 | ||
| 1951 | 1958 | (defconst scheme-font-lock-keywords-1 | |
| 1952 | (defvar scheme-font-lock-keywords | ||
| 1953 | (eval-when-compile | 1959 | (eval-when-compile |
| 1954 | (list | 1960 | (list |
| 1955 | ;; | 1961 | ;; |
| @@ -1971,32 +1977,43 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1971 | ((match-beginning 6) font-lock-variable-name-face) | 1977 | ((match-beginning 6) font-lock-variable-name-face) |
| 1972 | (t font-lock-type-face)) | 1978 | (t font-lock-type-face)) |
| 1973 | nil t)) | 1979 | nil t)) |
| 1974 | ;; | ||
| 1975 | ;; Control structures. | ||
| 1976 | (cons | ||
| 1977 | (concat | ||
| 1978 | "(" (regexp-opt | ||
| 1979 | '("begin" "call-with-current-continuation" "call/cc" | ||
| 1980 | "call-with-input-file" "call-with-output-file" "case" "cond" | ||
| 1981 | "do" "else" "for-each" "if" "lambda" | ||
| 1982 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" | ||
| 1983 | ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: | ||
| 1984 | "and" "or" "delay" | ||
| 1985 | ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: | ||
| 1986 | ;;"quasiquote" "quote" "unquote" "unquote-splicing" | ||
| 1987 | "map" "syntax" "syntax-rules") t) | ||
| 1988 | "\\>") 1) | ||
| 1989 | ;; | ||
| 1990 | ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. | ||
| 1991 | '("\\<<\\sw+>\\>" . font-lock-type-face) | ||
| 1992 | ;; | ||
| 1993 | ;; Scheme `:' keywords as references. | ||
| 1994 | '("\\<:\\sw+\\>" . font-lock-reference-face) | ||
| 1995 | )) | 1980 | )) |
| 1996 | "Default expressions to highlight in Scheme modes.") | 1981 | "Subdued expressions to highlight in Scheme modes.") |
| 1997 | 1982 | ||
| 1983 | (defconst scheme-font-lock-keywords-2 | ||
| 1984 | (append scheme-font-lock-keywords-1 | ||
| 1985 | (eval-when-compile | ||
| 1986 | (list | ||
| 1987 | ;; | ||
| 1988 | ;; Control structures. | ||
| 1989 | (cons | ||
| 1990 | (concat | ||
| 1991 | "(" (regexp-opt | ||
| 1992 | '("begin" "call-with-current-continuation" "call/cc" | ||
| 1993 | "call-with-input-file" "call-with-output-file" "case" "cond" | ||
| 1994 | "do" "else" "for-each" "if" "lambda" | ||
| 1995 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" | ||
| 1996 | ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: | ||
| 1997 | "and" "or" "delay" | ||
| 1998 | ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: | ||
| 1999 | ;;"quasiquote" "quote" "unquote" "unquote-splicing" | ||
| 2000 | "map" "syntax" "syntax-rules") t) | ||
| 2001 | "\\>") 1) | ||
| 2002 | ;; | ||
| 2003 | ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. | ||
| 2004 | '("\\<<\\sw+>\\>" . font-lock-type-face) | ||
| 2005 | ;; | ||
| 2006 | ;; Scheme `:' keywords as references. | ||
| 2007 | '("\\<:\\sw+\\>" . font-lock-reference-face) | ||
| 2008 | ))) | ||
| 2009 | "Gaudy expressions to highlight in Scheme modes.") | ||
| 2010 | |||
| 2011 | (defvar scheme-font-lock-keywords scheme-font-lock-keywords-1 | ||
| 2012 | "Default expressions to highlight in Scheme modes.") | ||
| 2013 | |||
| 2014 | ;; TeX. | ||
| 1998 | 2015 | ||
| 1999 | (defvar tex-font-lock-keywords | 2016 | ;(defvar tex-font-lock-keywords |
| 2000 | ; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>. | 2017 | ; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>. |
| 2001 | ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" | 2018 | ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" |
| 2002 | ; 2 font-lock-function-name-face) | 2019 | ; 2 font-lock-function-name-face) |
| @@ -2025,100 +2042,142 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 2025 | ; ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. | 2042 | ; ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. |
| 2026 | ; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" | 2043 | ; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" |
| 2027 | ; 3 (if (match-beginning 2) 'bold 'italic) keep)) | 2044 | ; 3 (if (match-beginning 2) 'bold 'italic) keep)) |
| 2028 | ;; | 2045 | |
| 2029 | ;; Rewritten with the help of Alexandra Bac <abac@welcome.disi.unige.it>. | 2046 | ;; Rewritten with the help of Alexandra Bac <abac@welcome.disi.unige.it>. |
| 2047 | (defconst tex-font-lock-keywords-1 | ||
| 2030 | (eval-when-compile | 2048 | (eval-when-compile |
| 2031 | (let (;; | 2049 | (let* (;; |
| 2032 | ;; Names of commands whose arg should be fontified with fonts. | 2050 | ;; Names of commands whose arg should be fontified as heading, etc. |
| 2033 | (bold (regexp-opt '("bf" "textbf" "textsc" "textup" | 2051 | (headings (regexp-opt '("title" "begin" "end") t)) |
| 2034 | "boldsymbol" "pmb") t)) | 2052 | ;; These commands have optional args. |
| 2035 | (italic (regexp-opt '("it" "textit" "textsl" "emph") t)) | 2053 | (headings-opt (regexp-opt |
| 2036 | (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t)) | 2054 | '("chapter" "part" |
| 2037 | ;; | 2055 | "section" "subsection" "subsubsection" |
| 2038 | ;; Names of commands whose arg should be fontified as a heading, etc. | 2056 | "section*" "subsection*" "subsubsection*" |
| 2039 | (headings (regexp-opt | 2057 | "paragraph" "subparagraph" "subsubparagraph" |
| 2040 | '("title" "chapter" "part" "begin" "end" | 2058 | "paragraph*" "subparagraph*" "subsubparagraph*" |
| 2041 | "section" "subsection" "subsubsection" | 2059 | "newcommand" "renewcommand" "newenvironment" |
| 2042 | "section*" "subsection*" "subsubsection*" | 2060 | "newtheorem" |
| 2043 | "paragraph" "subparagraph" "subsubparagraph" | 2061 | "newcommand*" "renewcommand*" "newenvironment*" |
| 2044 | "newcommand" "renewcommand" "newenvironment" | 2062 | "newtheorem*") |
| 2045 | "newtheorem" | 2063 | t)) |
| 2046 | "newcommand*" "renewcommand*" "newenvironment*" | 2064 | (variables (regexp-opt |
| 2047 | "newtheorem*") | 2065 | '("newcounter" "newcounter*" "setcounter" "addtocounter" |
| 2048 | t)) | 2066 | "setlength" "addtolength" "settowidth") |
| 2049 | (variables (regexp-opt | 2067 | t)) |
| 2050 | '("newcounter" "newcounter*" "setcounter" "addtocounter" | 2068 | (includes (regexp-opt |
| 2051 | "setlength" "addtolength" "settowidth") | 2069 | '("input" "include" "includeonly" "bibliography" |
| 2052 | t)) | 2070 | "epsfig" "psfig" "epsf") |
| 2053 | (citations (regexp-opt | ||
| 2054 | '("cite" "label" "index" "glossary" | ||
| 2055 | "footnote" "footnotemark" "footnotetext" | ||
| 2056 | "ref" "pageref" "vref" "eqref" "caption") | ||
| 2057 | t)) | 2071 | t)) |
| 2058 | (includes (regexp-opt | 2072 | (includes-opt (regexp-opt |
| 2059 | '("input" "include" "includeonly" "nofiles" | 2073 | '("nofiles" "usepackage" |
| 2060 | "includegraphics" "includegraphics*" "usepackage" | 2074 | "includegraphics" "includegraphics*") |
| 2061 | "bibliography" "epsfig" "psfig" "epsf") | 2075 | t)) |
| 2062 | t)) | 2076 | ;; Miscellany. |
| 2063 | ;; | 2077 | (slash "\\\\") |
| 2064 | ;; Names of commands that should be fontified. | 2078 | (opt "\\(\\[[^]]*\\]\\)?") |
| 2065 | (specials (regexp-opt | 2079 | (arg "{\\([^}]+\\)") |
| 2066 | '("\\" "linebreak" "nolinebreak" "pagebreak" "nopagebreak" | 2080 | (opt-depth (regexp-opt-depth opt)) |
| 2067 | "newline" "newpage" "clearpage" "cleardoublepage" | 2081 | (arg-depth (regexp-opt-depth arg)) |
| 2068 | "displaybreak" "allowdisplaybreaks" "enlargethispage") | 2082 | ) |
| 2069 | t)) | ||
| 2070 | (general "\\([a-zA-Z@]+\\|[^ \t\n]\\)") | ||
| 2071 | ;; | ||
| 2072 | ;; Miscellany. | ||
| 2073 | (slash "\\\\") | ||
| 2074 | (arg "\\(\\[[^]]*\\]\\)?{\\([^}]+\\)") | ||
| 2075 | ) | ||
| 2076 | (list | 2083 | (list |
| 2077 | ;; | 2084 | ;; |
| 2078 | ;; Heading args. | 2085 | ;; Heading args. |
| 2079 | (list (concat slash headings arg) | 2086 | (list (concat slash headings arg) |
| 2080 | (+ (regexp-opt-depth headings) (regexp-opt-depth arg)) | 2087 | (+ (regexp-opt-depth headings) arg-depth) |
| 2088 | 'font-lock-function-name-face) | ||
| 2089 | (list (concat slash headings-opt opt arg) | ||
| 2090 | (+ (regexp-opt-depth headings-opt) opt-depth arg-depth) | ||
| 2081 | 'font-lock-function-name-face) | 2091 | 'font-lock-function-name-face) |
| 2082 | ;; | 2092 | ;; |
| 2083 | ;; Variable args. | 2093 | ;; Variable args. |
| 2084 | (list (concat slash variables arg) | 2094 | (list (concat slash variables arg) |
| 2085 | (+ (regexp-opt-depth variables) (regexp-opt-depth arg)) | 2095 | (+ (regexp-opt-depth variables) arg-depth) |
| 2086 | 'font-lock-variable-name-face) | 2096 | 'font-lock-variable-name-face) |
| 2087 | ;; | 2097 | ;; |
| 2088 | ;; Citation args. | ||
| 2089 | (list (concat slash citations arg) | ||
| 2090 | (+ (regexp-opt-depth citations) (regexp-opt-depth arg)) | ||
| 2091 | 'font-lock-reference-face) | ||
| 2092 | ;; | ||
| 2093 | ;; Include args. | 2098 | ;; Include args. |
| 2094 | (list (concat slash includes arg) | 2099 | (list (concat slash includes arg) |
| 2095 | (+ (regexp-opt-depth includes) (regexp-opt-depth arg)) | 2100 | (+ (regexp-opt-depth includes) arg-depth) |
| 2101 | 'font-lock-builtin-face) | ||
| 2102 | (list (concat slash includes-opt opt arg) | ||
| 2103 | (+ (regexp-opt-depth includes-opt) opt-depth arg-depth) | ||
| 2096 | 'font-lock-builtin-face) | 2104 | 'font-lock-builtin-face) |
| 2097 | ;; | 2105 | ;; |
| 2098 | ;; Definitions. I think. | 2106 | ;; Definitions. I think. |
| 2099 | '("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" | 2107 | '("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" |
| 2100 | 1 font-lock-function-name-face) | 2108 | 1 font-lock-function-name-face) |
| 2101 | ;; | ||
| 2102 | ;; Command names, special and general. | ||
| 2103 | (cons (concat slash specials) 'font-lock-warning-face) | ||
| 2104 | (concat slash general) | ||
| 2105 | ;; | ||
| 2106 | ;; Font environments. It seems a bit dubious to use `bold' and `italic' | ||
| 2107 | ;; faces since we might not be able to display those fonts. | ||
| 2108 | (list (concat slash bold arg) | ||
| 2109 | (+ (regexp-opt-depth bold) (regexp-opt-depth arg)) | ||
| 2110 | '(quote bold) 'keep) | ||
| 2111 | (list (concat slash italic arg) | ||
| 2112 | (+ (regexp-opt-depth italic) (regexp-opt-depth arg)) | ||
| 2113 | '(quote italic) 'keep) | ||
| 2114 | (list (concat slash type arg) | ||
| 2115 | (+ (regexp-opt-depth type) (regexp-opt-depth arg)) | ||
| 2116 | '(quote bold-italic) 'keep) | ||
| 2117 | ;; | ||
| 2118 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. | ||
| 2119 | '("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" | ||
| 2120 | 3 (if (match-beginning 2) 'bold 'italic) keep) | ||
| 2121 | ))) | 2109 | ))) |
| 2110 | "Subdued expressions to highlight in TeX modes.") | ||
| 2111 | |||
| 2112 | (defconst tex-font-lock-keywords-2 | ||
| 2113 | (append tex-font-lock-keywords-1 | ||
| 2114 | (eval-when-compile | ||
| 2115 | (let* (;; | ||
| 2116 | ;; Names of commands whose arg should be fontified with fonts. | ||
| 2117 | (bold (regexp-opt '("bf" "textbf" "textsc" "textup" | ||
| 2118 | "boldsymbol" "pmb") t)) | ||
| 2119 | (italic (regexp-opt '("it" "textit" "textsl" "emph") t)) | ||
| 2120 | (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t)) | ||
| 2121 | ;; | ||
| 2122 | ;; Names of commands whose arg should be fontified as a citation. | ||
| 2123 | (citations (regexp-opt | ||
| 2124 | '("label" "ref" "pageref" "vref" "eqref") | ||
| 2125 | t)) | ||
| 2126 | (citations-opt (regexp-opt | ||
| 2127 | '("cite" "caption" "index" "glossary" | ||
| 2128 | "footnote" "footnotemark" "footnotetext") | ||
| 2129 | t)) | ||
| 2130 | ;; | ||
| 2131 | ;; Names of commands that should be fontified. | ||
| 2132 | (specials (regexp-opt | ||
| 2133 | '("\\" | ||
| 2134 | "linebreak" "nolinebreak" "pagebreak" "nopagebreak" | ||
| 2135 | "newline" "newpage" "clearpage" "cleardoublepage" | ||
| 2136 | "displaybreak" "allowdisplaybreaks" "enlargethispage") | ||
| 2137 | t)) | ||
| 2138 | (general "\\([a-zA-Z@]+\\**\\|[^ \t\n]\\)") | ||
| 2139 | ;; | ||
| 2140 | ;; Miscellany. | ||
| 2141 | (slash "\\\\") | ||
| 2142 | (opt "\\(\\[[^]]*\\]\\)?") | ||
| 2143 | (arg "{\\([^}]+\\)") | ||
| 2144 | (opt-depth (regexp-opt-depth opt)) | ||
| 2145 | (arg-depth (regexp-opt-depth arg)) | ||
| 2146 | ) | ||
| 2147 | (list | ||
| 2148 | ;; | ||
| 2149 | ;; Citation args. | ||
| 2150 | (list (concat slash citations arg) | ||
| 2151 | (+ (regexp-opt-depth citations) arg-depth) | ||
| 2152 | 'font-lock-reference-face) | ||
| 2153 | (list (concat slash citations-opt opt arg) | ||
| 2154 | (+ (regexp-opt-depth citations-opt) opt-depth arg-depth) | ||
| 2155 | 'font-lock-reference-face) | ||
| 2156 | ;; | ||
| 2157 | ;; Command names, special and general. | ||
| 2158 | (cons (concat slash specials) 'font-lock-warning-face) | ||
| 2159 | (concat slash general) | ||
| 2160 | ;; | ||
| 2161 | ;; Font environments. It seems a bit dubious to use `bold' etc. faces | ||
| 2162 | ;; since we might not be able to display those fonts. | ||
| 2163 | (list (concat slash bold arg) | ||
| 2164 | (+ (regexp-opt-depth bold) arg-depth) | ||
| 2165 | '(quote bold) 'keep) | ||
| 2166 | (list (concat slash italic arg) | ||
| 2167 | (+ (regexp-opt-depth italic) arg-depth) | ||
| 2168 | '(quote italic) 'keep) | ||
| 2169 | (list (concat slash type arg) | ||
| 2170 | (+ (regexp-opt-depth type) arg-depth) | ||
| 2171 | '(quote bold-italic) 'keep) | ||
| 2172 | ;; | ||
| 2173 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. | ||
| 2174 | (list (concat "\\\\\\(\\(bf\\)\\|em\\|it\\(em\\)?\\|sl\\)\\>" | ||
| 2175 | "\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)") | ||
| 2176 | 4 '(if (match-beginning 2) 'bold 'italic) 'keep) | ||
| 2177 | )))) | ||
| 2178 | "Gaudy expressions to highlight in TeX modes.") | ||
| 2179 | |||
| 2180 | (defvar tex-font-lock-keywords tex-font-lock-keywords-1 | ||
| 2122 | "Default expressions to highlight in TeX modes.") | 2181 | "Default expressions to highlight in TeX modes.") |
| 2123 | 2182 | ||
| 2124 | ;;; User choices. | 2183 | ;;; User choices. |
| @@ -2131,8 +2190,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 2131 | "Widget `:type' for members of the custom group `font-lock-extra-types'. | 2190 | "Widget `:type' for members of the custom group `font-lock-extra-types'. |
| 2132 | Members should `:load' the package `font-lock' to use this widget." | 2191 | Members should `:load' the package `font-lock' to use this widget." |
| 2133 | :args '((const :tag "none" nil) | 2192 | :args '((const :tag "none" nil) |
| 2134 | (repeat :tag "types" | 2193 | (repeat :tag "types" regexp))) |
| 2135 | (string :tag "regexp")))) | ||
| 2136 | 2194 | ||
| 2137 | (defcustom c-font-lock-extra-types '("FILE" "\\sw+_t") | 2195 | (defcustom c-font-lock-extra-types '("FILE" "\\sw+_t") |
| 2138 | "*List of extra types to fontify in C mode. | 2196 | "*List of extra types to fontify in C mode. |