aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1997-06-19 08:49:04 +0000
committerSimon Marshall1997-06-19 08:49:04 +0000
commit23a0e11b3bf8f0c8c63ab24ed76c9b849d4c79f8 (patch)
tree8db8510265e9526630f52ec86908b642a0968ffd
parent0ceb91c18bec6c085e6934b0e06bade4fa46ab0c (diff)
downloademacs-23a0e11b3bf8f0c8c63ab24ed76c9b849d4c79f8.tar.gz
emacs-23a0e11b3bf8f0c8c63ab24ed76c9b849d4c79f8.zip
Rearrange custom options. Also enable custom control of Global Font Lock mode.
-rw-r--r--lisp/font-lock.el249
1 files changed, 177 insertions, 72 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index f6db74a5384..8d5256c8403 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -236,12 +236,26 @@
236 236
237;; User variables. 237;; User variables.
238 238
239(defcustom font-lock-verbose (* 0 1024) 239(defcustom font-lock-maximum-size (* 250 1024)
240 "*If non-nil, means show status messages for buffer fontification. 240 "*Maximum size of a buffer for buffer fontification.
241If a number, only buffers greater than this size have fontification messages." 241Only buffers less than this can be fontified when Font Lock mode is turned on.
242 :type '(choice (const :tag "never" nil) 242If nil, means size is irrelevant.
243 (const :tag "always" t) 243If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
244 (integer :tag "size")) 244where MAJOR-MODE is a symbol or t (meaning the default). For example:
245 ((c-mode . 256000) (c++-mode . 256000) (rmail-mode . 1048576))
246means that the maximum size is 250K for buffers in C or C++ modes, one megabyte
247for buffers in Rmail mode, and size is irrelevant otherwise."
248 :type '(choice (const :tag "none" nil)
249 (integer :tag "size")
250 (repeat :menu-tag "mode specific" :tag "mode specific"
251 :value ((t . nil))
252 (cons :tag "Instance"
253 (radio :tag "Mode"
254 (const :tag "all" t)
255 (symbol :tag "name"))
256 (radio :tag "Size"
257 (const :tag "none" nil)
258 (integer :tag "size")))))
245 :group 'font-lock) 259 :group 'font-lock)
246 260
247(defcustom font-lock-maximum-decoration t 261(defcustom font-lock-maximum-decoration t
@@ -269,26 +283,12 @@ decoration for buffers in C++ mode, and level 1 decoration otherwise."
269 (integer :tag "level" 1))))) 283 (integer :tag "level" 1)))))
270 :group 'font-lock) 284 :group 'font-lock)
271 285
272(defcustom font-lock-maximum-size (* 250 1024) 286(defcustom font-lock-verbose (* 0 1024)
273 "*Maximum size of a buffer for buffer fontification. 287 "*If non-nil, means show status messages for buffer fontification.
274Only buffers less than this can be fontified when Font Lock mode is turned on. 288If a number, only buffers greater than this size have fontification messages."
275If nil, means size is irrelevant. 289 :type '(choice (const :tag "never" nil)
276If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), 290 (const :tag "always" t)
277where MAJOR-MODE is a symbol or t (meaning the default). For example: 291 (integer :tag "size"))
278 ((c-mode . 256000) (c++-mode . 256000) (rmail-mode . 1048576))
279means that the maximum size is 250K for buffers in C or C++ modes, one megabyte
280for buffers in Rmail mode, and size is irrelevant otherwise."
281 :type '(choice (const :tag "none" nil)
282 (integer :tag "size")
283 (repeat :menu-tag "mode specific" :tag "mode specific"
284 :value ((t . nil))
285 (cons :tag "Instance"
286 (radio :tag "Mode"
287 (const :tag "all" t)
288 (symbol :tag "name"))
289 (radio :tag "Size"
290 (const :tag "none" nil)
291 (integer :tag "size")))))
292 :group 'font-lock) 292 :group 'font-lock)
293 293
294;; Fontification variables: 294;; Fontification variables:
@@ -799,25 +799,6 @@ see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types',
799;; would also be contrary to the Principle of Least Surprise. sm. 799;; would also be contrary to the Principle of Least Surprise. sm.
800 800
801(defvar font-lock-buffers nil) ; For remembering buffers. 801(defvar font-lock-buffers nil) ; For remembering buffers.
802(defvar global-font-lock-mode nil)
803
804(defcustom font-lock-global-modes t
805 "*Modes for which Font Lock mode is automagically turned on.
806Global Font Lock mode is controlled by the `global-font-lock-mode' command.
807If nil, means no modes have Font Lock mode automatically turned on.
808If t, all modes that support Font Lock mode have it automatically turned on.
809If a list, it should be a list of `major-mode' symbol names for which Font Lock
810mode should be automatically turned on. The sense of the list is negated if it
811begins with `not'. For example:
812 (c-mode c++-mode)
813means that Font Lock mode is turned on for buffers in C and C++ modes only."
814 :type '(choice (const :tag "none" nil)
815 (const :tag "all" t)
816 (set :menu-tag "mode specific" :tag "modes"
817 :value (not)
818 (const :tag "Except" not)
819 (repeat :inline t (symbol :tag "mode"))))
820 :group 'font-lock)
821 802
822;;;###autoload 803;;;###autoload
823(defun global-font-lock-mode (&optional arg message) 804(defun global-font-lock-mode (&optional arg message)
@@ -841,6 +822,38 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'."
841 (message "Global Font Lock mode is now %s." (if off-p "OFF" "ON"))) 822 (message "Global Font Lock mode is now %s." (if off-p "OFF" "ON")))
842 (setq global-font-lock-mode (not off-p)))) 823 (setq global-font-lock-mode (not off-p))))
843 824
825;; Naughty hack. This variable was originally a `defvar' to keep track of
826;; whether Global Font Lock mode was turned on or not. As a `defcustom' with
827;; special `:set' and `:require' forms, we can provide custom mode control.
828(defcustom global-font-lock-mode nil
829 "Toggle Global Font Lock mode.
830When Global Font Lock mode is enabled, Font Lock mode is automagically
831turned on in a buffer if its major mode is one of `font-lock-global-modes'.
832You must modify via \\[customize] for this variable to have an effect."
833 :set (lambda (symbol value)
834 (global-font-lock-mode (or value 0)))
835 :type 'boolean
836 :group 'font-lock
837 :require 'font-lock)
838
839(defcustom font-lock-global-modes t
840 "*Modes for which Font Lock mode is automagically turned on.
841Global Font Lock mode is controlled by the `global-font-lock-mode' command.
842If nil, means no modes have Font Lock mode automatically turned on.
843If t, all modes that support Font Lock mode have it automatically turned on.
844If a list, it should be a list of `major-mode' symbol names for which Font Lock
845mode should be automatically turned on. The sense of the list is negated if it
846begins with `not'. For example:
847 (c-mode c++-mode)
848means that Font Lock mode is turned on for buffers in C and C++ modes only."
849 :type '(choice (const :tag "none" nil)
850 (const :tag "all" t)
851 (set :menu-tag "mode specific" :tag "modes"
852 :value (not)
853 (const :tag "Except" not)
854 (repeat :inline t (symbol :tag "mode"))))
855 :group 'font-lock)
856
844(defun font-lock-change-major-mode () 857(defun font-lock-change-major-mode ()
845 ;; Turn off Font Lock mode if it's on. 858 ;; Turn off Font Lock mode if it's on.
846 (when font-lock-mode 859 (when font-lock-mode
@@ -1591,7 +1604,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1591 "Face name to use for things that should stand out.") 1604 "Face name to use for things that should stand out.")
1592 1605
1593;; Originally face attributes were specified via `font-lock-face-attributes'. 1606;; Originally face attributes were specified via `font-lock-face-attributes'.
1594;; Users then changed the default face attributes by setting this variable. 1607;; Users then changed the default face attributes by setting that variable.
1595;; However, we try and be back-compatible and respect its value if set except 1608;; However, we try and be back-compatible and respect its value if set except
1596;; for faces where M-x customize has been used to save changes for the face. 1609;; for faces where M-x customize has been used to save changes for the face.
1597(when (boundp 'font-lock-face-attributes) 1610(when (boundp 'font-lock-face-attributes)
@@ -1890,6 +1903,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1890 "(" (regexp-opt 1903 "(" (regexp-opt
1891 '("cond" "if" "while" "catch" "throw" "let" "let*" 1904 '("cond" "if" "while" "catch" "throw" "let" "let*"
1892 "prog" "progn" "progv" "prog1" "prog2" "prog*" 1905 "prog" "progn" "progv" "prog1" "prog2" "prog*"
1906 "closure" "preparse-closure" "make-closure"
1893 "inline" "save-restriction" "save-excursion" 1907 "inline" "save-restriction" "save-excursion"
1894 "save-window-excursion" "save-selected-window" 1908 "save-window-excursion" "save-selected-window"
1895 "save-match-data" "save-current-buffer" "unwind-protect" 1909 "save-match-data" "save-current-buffer" "unwind-protect"
@@ -1994,23 +2008,117 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
1994; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep) 2008; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
1995; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face) 2009; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
1996; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep)) 2010; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
1997 ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>. 2011; ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>.
1998 '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" 2012; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
1999 2 font-lock-function-name-face) 2013; 2 font-lock-function-name-face)
2000 ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}" 2014; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
2001 2 font-lock-reference-face) 2015; 2 font-lock-reference-face)
2002 ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face) 2016; ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face)
2003 "\\\\\\([a-zA-Z@]+\\|.\\)" 2017; "\\\\\\([a-zA-Z@]+\\|.\\)"
2004 ;; It seems a bit dubious to use `bold' and `italic' faces since we might 2018; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
2005 ;; not be able to display those fonts. 2019; ;; not be able to display those fonts.
2006 ;; LaTeX2e: \emph{This is emphasized}. 2020; ;; LaTeX2e: \emph{This is emphasized}.
2007 ("\\\\emph{\\([^}]+\\)}" 1 'italic keep) 2021; ("\\\\emph{\\([^}]+\\)}" 1 'italic keep)
2008 ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...} 2022; ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...}
2009 ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}" 2023; ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}"
2010 3 (if (match-beginning 2) 'bold 'italic) keep) 2024; 3 (if (match-beginning 2) 'bold 'italic) keep)
2011 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables. 2025; ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables.
2012 ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" 2026; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
2013 3 (if (match-beginning 2) 'bold 'italic) keep)) 2027; 3 (if (match-beginning 2) 'bold 'italic) keep))
2028 ;;
2029 ;; Rewritten with the help of Alexandra Bac <abac@welcome.disi.unige.it>.
2030 (eval-when-compile
2031 (let (;;
2032 ;; Names of commands whose arg should be fontified with fonts.
2033 (bold (regexp-opt '("bf" "textbf" "textsc" "textup"
2034 "boldsymbol" "pmb") t))
2035 (italic (regexp-opt '("it" "textit" "textsl" "emph") t))
2036 (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t))
2037 ;;
2038 ;; Names of commands whose arg should be fontified as a heading, etc.
2039 (headings (regexp-opt
2040 '("title" "chapter" "part" "begin" "end"
2041 "section" "subsection" "subsubsection"
2042 "section*" "subsection*" "subsubsection*"
2043 "paragraph" "subparagraph" "subsubparagraph"
2044 "newcommand" "renewcommand" "newenvironment"
2045 "newtheorem"
2046 "newcommand*" "renewcommand*" "newenvironment*"
2047 "newtheorem*")
2048 t))
2049 (variables (regexp-opt
2050 '("newcounter" "newcounter*" "setcounter" "addtocounter"
2051 "setlength" "addtolength" "settowidth")
2052 t))
2053 (citations (regexp-opt
2054 '("cite" "label" "index" "glossary"
2055 "footnote" "footnotemark" "footnotetext"
2056 "ref" "pageref" "vref" "eqref" "caption")
2057 t))
2058 (includes (regexp-opt
2059 '("input" "include" "includeonly" "nofiles"
2060 "includegraphics" "includegraphics*" "usepackage"
2061 "bibliography" "epsfig" "psfig" "epsf")
2062 t))
2063 ;;
2064 ;; Names of commands that should be fontified.
2065 (specials (regexp-opt
2066 '("\\" "linebreak" "nolinebreak" "pagebreak" "nopagebreak"
2067 "newline" "newpage" "clearpage" "cleardoublepage"
2068 "displaybreak" "allowdisplaybreaks" "enlargethispage")
2069 t))
2070 (general "\\([a-zA-Z@]+\\|[^ \t\n]\\)")
2071 ;;
2072 ;; Miscellany.
2073 (slash "\\\\")
2074 (arg "\\(\\[[^]]*\\]\\)?{\\([^}]+\\)")
2075 )
2076 (list
2077 ;;
2078 ;; Heading args.
2079 (list (concat slash headings arg)
2080 (+ (regexp-opt-depth headings) (regexp-opt-depth arg))
2081 'font-lock-function-name-face)
2082 ;;
2083 ;; Variable args.
2084 (list (concat slash variables arg)
2085 (+ (regexp-opt-depth variables) (regexp-opt-depth arg))
2086 'font-lock-variable-name-face)
2087 ;;
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.
2094 (list (concat slash includes arg)
2095 (+ (regexp-opt-depth includes) (regexp-opt-depth arg))
2096 'font-lock-builtin-face)
2097 ;;
2098 ;; Definitions. I think.
2099 '("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)"
2100 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 )))
2014 "Default expressions to highlight in TeX modes.") 2122 "Default expressions to highlight in TeX modes.")
2015 2123
2016;;; User choices. 2124;;; User choices.
@@ -2261,15 +2369,12 @@ See also `c++-font-lock-extra-types'.")
2261 ;; Eric Hopper <hopper@omnifarious.mn.org> says these are new. 2369 ;; Eric Hopper <hopper@omnifarious.mn.org> says these are new.
2262 "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t))) 2370 "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t)))
2263 (c++-operators 2371 (c++-operators
2264 (mapconcat 'identity 2372 (eval-when-compile
2265 (mapcar 'regexp-quote 2373 (regexp-opt
2266 ;; Taken from Stroustrup, minus keywords otherwise fontified. 2374 ;; Taken from Stroustrup, minus keywords otherwise fontified.
2267 (sort '("+" "-" "*" "/" "%" "^" "&" "|" "~" "!" "=" "<" ">" 2375 '("+" "-" "*" "/" "%" "^" "&" "|" "~" "!" "=" "<" ">" "+=" "-="
2268 "+=" "-=" "*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" 2376 "*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" ">>=" "<<=" "==" "!="
2269 ">>=" "<<=" "==" "!=" "<=" ">=" "&&" "||" "++" "--" 2377 "<=" ">=" "&&" "||" "++" "--" "->*" "," "->" "[]" "()"))))
2270 "->*" "," "->" "[]" "()")
2271 #'(lambda (a b) (> (length a) (length b)))))
2272 "\\|"))
2273 (c++-type-types 2378 (c++-type-types
2274 `(mapconcat 'identity 2379 `(mapconcat 'identity
2275 (cons 2380 (cons