\f
;; User variables.
-(defcustom font-lock-maximum-size (* 250 1024)
+(defcustom font-lock-maximum-size 256000
"*Maximum size of a buffer for buffer fontification.
Only buffers less than this can be fontified when Font Lock mode is turned on.
If nil, means size is irrelevant.
(integer :tag "level" 1)))))
:group 'font-lock)
-(defcustom font-lock-verbose (* 0 1024)
+(defcustom font-lock-verbose 0
"*If non-nil, means show status messages for buffer fontification.
If a number, only buffers greater than this size have fontification messages."
:type '(choice (const :tag "never" nil)
- (const :tag "always" t)
+ (other :tag "always" t)
(integer :tag "size"))
:group 'font-lock)
\f
textual modes (i.e., the mode-dependent function is known to put point and mark
around a text block relevant to that mode).
-Other variables include those for buffer-specialised fontification functions,
+Other variables include that for syntactic keyword fontification,
+`font-lock-syntactic-keywords'
+and those for buffer-specialised fontification functions,
`font-lock-fontify-buffer-function', `font-lock-unfontify-buffer-function',
`font-lock-fontify-region-function', `font-lock-unfontify-region-function',
`font-lock-inhibit-thing-lock' and `font-lock-maximum-size'.")
'((c-font-lock-keywords c-font-lock-keywords-1
c-font-lock-keywords-2 c-font-lock-keywords-3)
nil nil ((?_ . "w")) beginning-of-defun
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . "/[*/]")
(font-lock-mark-block-function . mark-defun)))
(c++-mode-defaults
'((c++-font-lock-keywords c++-font-lock-keywords-1
c++-font-lock-keywords-2 c++-font-lock-keywords-3)
nil nil ((?_ . "w")) beginning-of-defun
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . "/[*/]")
(font-lock-mark-block-function . mark-defun)))
(objc-mode-defaults
'((objc-font-lock-keywords objc-font-lock-keywords-1
objc-font-lock-keywords-2 objc-font-lock-keywords-3)
nil nil ((?_ . "w") (?$ . "w")) nil
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . "/[*/]")
(font-lock-mark-block-function . mark-defun)))
(java-mode-defaults
'((java-font-lock-keywords java-font-lock-keywords-1
java-font-lock-keywords-2 java-font-lock-keywords-3)
nil nil ((?_ . "w") (?$ . "w") (?. . "w")) nil
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . "/[*/]")
(font-lock-mark-block-function . mark-defun)))
(lisp-mode-defaults
'((lisp-font-lock-keywords
lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . ";")
- (font-lock-mark-block-function . mark-defun)))
- (scheme-mode-defaults
- '((scheme-font-lock-keywords
- scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
- nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . ";")
(font-lock-mark-block-function . mark-defun)))
;; For TeX modes we could use `backward-paragraph' for the same reason.
;; But we don't, because paragraph breaks are arguably likely enough to
;; occur within a genuine syntactic block to make it too risky.
;; However, we do specify a MARK-BLOCK function as that cannot result
- ;; in a mis-fontification even if it might not fontify enough. --sm.
+ ;; in a mis-fontification even if it might not fontify enough. sm.
(tex-mode-defaults
'((tex-font-lock-keywords
tex-font-lock-keywords-1 tex-font-lock-keywords-2)
nil nil ((?$ . "\"")) nil
- ;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
- ;(font-lock-comment-start-regexp . "%")
(font-lock-mark-block-function . mark-paragraph)))
)
(list
(cons 'objc-mode objc-mode-defaults)
(cons 'java-mode java-mode-defaults)
(cons 'emacs-lisp-mode lisp-mode-defaults)
- (cons 'inferior-scheme-mode scheme-mode-defaults)
(cons 'latex-mode tex-mode-defaults)
(cons 'lisp-mode lisp-mode-defaults)
(cons 'lisp-interaction-mode lisp-mode-defaults)
(cons 'plain-tex-mode tex-mode-defaults)
- (cons 'scheme-mode scheme-mode-defaults)
- (cons 'scheme-interaction-mode scheme-mode-defaults)
(cons 'slitex-mode tex-mode-defaults)
(cons 'tex-mode tex-mode-defaults)))
"Alist of fall-back Font Lock defaults for major modes.
enclosing textual block and mark at the end.
This is normally set via `font-lock-defaults'.")
-;; Obsoleted by Emacs 20 parse-partial-sexp's COMMENTSTOP.
-;(defvar font-lock-comment-start-regexp nil
-; "*Regexp to match the start of a comment.
-;This need not discriminate between genuine comments and quoted comment
-;characters or comment characters within strings.
-;If nil, `comment-start-skip' is used instead; see that variable for more info.
-;This is normally set via `font-lock-defaults'.")
-
(defvar font-lock-fontify-buffer-function 'font-lock-default-fontify-buffer
"Function to use for fontifying the buffer.
This is normally set via `font-lock-defaults'.")
(radio :tag "Mode"
(const :tag "all" t)
(symbol :tag "name"))
- (radio :tag "Decoration"
+ (radio :tag "Support"
+ (const :tag "none" nil)
(const :tag "fast lock" fast-lock-mode)
(const :tag "lazy lock" lazy-lock-mode)))
))
(let ((verbose (if (numberp font-lock-verbose)
(> (buffer-size) font-lock-verbose)
font-lock-verbose)))
- (when verbose
- (message "Fontifying %s..." (buffer-name)))
- ;; Make sure we have the right `font-lock-keywords' etc.
- (unless font-lock-mode
- (font-lock-set-defaults))
- ;; Make sure we fontify etc. in the whole buffer.
- (save-restriction
- (widen)
- (condition-case nil
- (save-excursion
- (save-match-data
- (font-lock-fontify-region (point-min) (point-max) verbose)
- (font-lock-after-fontify-buffer)
- (setq font-lock-fontified t)))
- ;; We don't restore the old fontification, so it's best to unfontify.
- (quit (font-lock-unfontify-buffer))))
- ;; Make sure we undo `font-lock-keywords' etc.
- (unless font-lock-mode
- (font-lock-unset-defaults))
- (if verbose (message "Fontifying %s...%s" (buffer-name)
- (if font-lock-fontified "done" "quit")))))
+ (with-temp-message
+ (when verbose
+ (format "Fontifying %s..." (buffer-name)))
+ ;; Make sure we have the right `font-lock-keywords' etc.
+ (unless font-lock-mode
+ (font-lock-set-defaults))
+ ;; Make sure we fontify etc. in the whole buffer.
+ (save-restriction
+ (widen)
+ (condition-case nil
+ (save-excursion
+ (save-match-data
+ (font-lock-fontify-region (point-min) (point-max) verbose)
+ (font-lock-after-fontify-buffer)
+ (setq font-lock-fontified t)))
+ ;; We don't restore the old fontification, so it's best to unfontify.
+ (quit (font-lock-unfontify-buffer))))
+ ;; Make sure we undo `font-lock-keywords' etc.
+ (unless font-lock-mode
+ (font-lock-unset-defaults)))))
(defun font-lock-default-unfontify-buffer ()
;; Make sure we unfontify etc. in the whole buffer.
"Face name to use for variable names.")
(defvar font-lock-type-face 'font-lock-type-face
- "Face name to use for type names.")
+ "Face name to use for type and class names.")
-(defvar font-lock-reference-face 'font-lock-reference-face
- "Face name to use for reference names.")
+(defvar font-lock-constant-face 'font-lock-constant-face
+ "Face name to use for constant and label names.")
(defvar font-lock-warning-face 'font-lock-warning-face
"Face name to use for things that should stand out.")
+(defvar font-lock-reference-face 'font-lock-constant-face
+ "This variable is obsolete. Use font-lock-constant-face.")
+
;; Originally face attributes were specified via `font-lock-face-attributes'.
;; Users then changed the default face attributes by setting that variable.
;; However, we try and be back-compatible and respect its value if set except
(((class color) (background light)) (:foreground "ForestGreen"))
(((class color) (background dark)) (:foreground "PaleGreen"))
(t (:bold t :underline t)))
- "Font Lock mode face used to highlight types."
+ "Font Lock mode face used to highlight type and classes."
:group 'font-lock-highlighting-faces)
-(defface font-lock-reference-face
+(defface font-lock-constant-face
'((((class grayscale) (background light))
(:foreground "LightGray" :bold t :underline t))
(((class grayscale) (background dark))
(((class color) (background light)) (:foreground "CadetBlue"))
(((class color) (background dark)) (:foreground "Aquamarine"))
(t (:bold t :underline t)))
- "Font Lock mode face used to highlight references."
+ "Font Lock mode face used to highlight constants and labels."
:group 'font-lock-highlighting-faces)
(defface font-lock-warning-face
(list (concat "(\\(def\\("
;; Function declarations.
"\\(advice\\|alias\\|generic\\|macro\\*?\\|method\\|"
- "setf\\|subst\\*?\\|un\\*?\\|"
- "ine-\\(derived-mode\\|function\\|"
- "skeleton\\|widget\\)\\)\\|"
+ "setf\\|subst\\*?\\|un\\*?\\|"
+ "ine-\\(condition\\|derived-mode\\|function\\|"
+ "method-combination\\|setf-expander\\|skeleton\\|widget\\|"
+ "\\(compiler\\|modify\\|symbol\\)-macro\\)\\)\\|"
;; Variable declarations.
- "\\(const\\|custom\\|face\\|var\\)\\|"
+ "\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|"
;; Structure declarations.
- "\\(class\\|group\\|struct\\|type\\)"
+ "\\(class\\|group\\|package\\|struct\\|type\\)"
"\\)\\)\\>"
;; Any whitespace and defined object.
"[ \t'\(]*"
"\\(\\sw+\\)?")
'(1 font-lock-keyword-face)
- '(7 (cond ((match-beginning 3) font-lock-function-name-face)
- ((match-beginning 5) font-lock-variable-name-face)
+ '(9 (cond ((match-beginning 3) font-lock-function-name-face)
+ ((match-beginning 6) font-lock-variable-name-face)
(t font-lock-type-face))
nil t))
;;
;; Emacs Lisp autoload cookies.
- '("^;;;\\(###\\)\\(autoload\\)\\>"
- (1 font-lock-reference-face prepend)
- (2 font-lock-warning-face prepend))
+ '("^;;;###\\(autoload\\)\\>" 1 font-lock-warning-face prepend)
))
"Subdued level highlighting for Lisp modes.")
;; Control structures. Emacs Lisp forms.
(cons (concat
"(" (regexp-opt
- '("cond" "if" "while" "catch" "throw" "let" "let*"
+ '("cond" "if" "while" "let" "let*"
"prog" "progn" "progv" "prog1" "prog2" "prog*"
- "inline" "save-restriction" "save-excursion"
+ "inline" "lambda" "save-restriction" "save-excursion"
"save-window-excursion" "save-selected-window"
"save-match-data" "save-current-buffer" "unwind-protect"
"condition-case" "track-mouse"
"eval-when"
"with-current-buffer" "with-electric-help"
"with-output-to-string" "with-output-to-temp-buffer"
- "with-temp-buffer" "with-temp-file"
+ "with-temp-buffer" "with-temp-file" "with-temp-message"
"with-timeout") t)
"\\>")
1)
(cons (concat
"(" (regexp-opt
'("when" "unless" "case" "ecase" "typecase" "etypecase"
- "loop" "do" "do*" "dotimes" "dolist"
- "proclaim" "declaim" "declare"
- "lexical-let" "lexical-let*" "flet" "labels"
+ "ccase" "ctypecase" "handler-case" "handler-bind"
+ "restart-bind" "restart-case" "in-package"
+ "cerror" "break" "ignore-errors"
+ "loop" "do" "do*" "dotimes" "dolist" "the" "locally"
+ "proclaim" "declaim" "declare" "symbol-macrolet"
+ "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
+ "destructuring-bind" "macrolet" "tagbody" "block"
"return" "return-from") t)
"\\>")
1)
;;
- ;; Feature symbols as references.
- '("(\\(featurep\\|provide\\|require\\)\\>[ \t']*\\(\\sw+\\)?"
- (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
+ ;; Exit/Feature symbols as constants.
+ (list (concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\>"
+ "[ \t']*\\(\\sw+\\)?")
+ '(1 font-lock-keyword-face)
+ '(2 font-lock-constant-face nil t))
+ ;;
+ ;; Erroneous structures.
+ '("(\\(abort\\|assert\\|error\\|signal\\)\\>" 1 font-lock-warning-face)
;;
;; Words inside \\[] tend to be for `substitute-command-keys'.
- '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend)
+ '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-constant-face prepend)
;;
;; Words inside `' tend to be symbol names.
- '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend)
+ '("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend)
;;
;; Constant values.
'("\\<:\\sw\\sw+\\>" 0 font-lock-builtin-face)
(defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
"Default expressions to highlight in Lisp modes.")
\f
-;; Scheme.
-
-(defconst scheme-font-lock-keywords-1
- (eval-when-compile
- (list
- ;;
- ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says
- ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS.
- (list (concat "(\\(define\\("
- ;; Function names.
- "\\(\\|-method\\|-generic\\(-procedure\\)?\\)\\|"
- ;; Macro names, as variable names. A bit dubious, this.
- "\\(-syntax\\)\\|"
- ;; Class names.
- "-class"
- "\\)\\)\\>"
- ;; Any whitespace and declared object.
- "[ \t]*(?"
- "\\(\\sw+\\)?")
- '(1 font-lock-keyword-face)
- '(6 (cond ((match-beginning 3) font-lock-function-name-face)
- ((match-beginning 5) font-lock-variable-name-face)
- (t font-lock-type-face))
- nil t))
- ))
- "Subdued expressions to highlight in Scheme modes.")
-
-(defconst scheme-font-lock-keywords-2
- (append scheme-font-lock-keywords-1
- (eval-when-compile
- (list
- ;;
- ;; Control structures.
- (cons
- (concat
- "(" (regexp-opt
- '("begin" "call-with-current-continuation" "call/cc"
- "call-with-input-file" "call-with-output-file" "case" "cond"
- "do" "else" "for-each" "if" "lambda"
- "let" "let*" "let-syntax" "letrec" "letrec-syntax"
- ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants:
- "and" "or" "delay"
- ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother:
- ;;"quasiquote" "quote" "unquote" "unquote-splicing"
- "map" "syntax" "syntax-rules") t)
- "\\>") 1)
- ;;
- ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers.
- '("\\<<\\sw+>\\>" . font-lock-type-face)
- ;;
- ;; Scheme `:' keywords as builtins.
- '("\\<:\\sw+\\>" . font-lock-builtin-face)
- )))
- "Gaudy expressions to highlight in Scheme modes.")
-
-(defvar scheme-font-lock-keywords scheme-font-lock-keywords-1
- "Default expressions to highlight in Scheme modes.")
-\f
;; TeX.
;(defvar tex-font-lock-keywords
; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
; 2 font-lock-function-name-face)
; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
-; 2 font-lock-reference-face)
+; 2 font-lock-constant-face)
; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
; ;; not be able to display those fonts.
; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
; 2 font-lock-function-name-face)
; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
-; 2 font-lock-reference-face)
+; 2 font-lock-constant-face)
; ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face)
; "\\\\\\([a-zA-Z@]+\\|.\\)"
; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
'("label" "ref" "pageref" "vref" "eqref")
t))
(citations-opt (regexp-opt
- '("cite" "caption" "index" "glossary"
+ '("cite" "nocite" "caption" "index" "glossary"
"footnote" "footnotemark" "footnotetext")
- t))
+ t))
;;
;; Names of commands that should be fontified.
(specials (regexp-opt
;; Citation args.
(list (concat slash citations arg)
(+ (regexp-opt-depth citations) arg-depth)
- 'font-lock-reference-face)
+ 'font-lock-constant-face)
(list (concat slash citations-opt opt arg)
(+ (regexp-opt-depth citations-opt) opt-depth arg-depth)
- 'font-lock-reference-face)
+ 'font-lock-constant-face)
;;
;; Command names, special and general.
(cons (concat slash specials) 'font-lock-warning-face)
:group 'font-lock-extra-types)
(defcustom c++-font-lock-extra-types
- '("\\([iof]\\|str\\)+stream\\(buf\\)?" "ios"
+ '("\\sw+_t"
+ "\\([iof]\\|str\\)+stream\\(buf\\)?" "ios"
"string" "rope"
"list" "slist"
"deque" "vector" "bit_vector"
"map" "multimap"
"hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?"
"stack" "queue" "priority_queue"
- "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator")
+ "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator"
+ "reference" "const_reference")
"*List of extra types to fontify in C++ mode.
Each list item should be a regexp not containing word-delimiters.
For example, a value of (\"string\") means the word string is treated as a type
(let* ((c-keywords
(eval-when-compile
(regexp-opt '("break" "continue" "do" "else" "for" "if" "return"
- "switch" "while") t)))
- (c-type-types
+ "switch" "while" "sizeof"
+ ;; Type related, but we don't do anything special.
+ "typedef" "extern" "auto" "register" "static"
+ "volatile" "const") t)))
+ (c-type-specs
+ (eval-when-compile
+ (regexp-opt '("enum" "struct" "union") t)))
+ (c-type-specs-depth
+ (regexp-opt-depth c-type-specs))
+ (c-type-names
`(mapconcat 'identity
(cons
(,@ (eval-when-compile
(regexp-opt
- '("auto" "extern" "register" "static" "typedef" "struct"
- "union" "enum" "signed" "unsigned" "short" "long"
- "int" "char" "float" "double" "void" "volatile" "const"))))
+ '("char" "short" "int" "long" "signed" "unsigned"
+ "float" "double" "void"))))
c-font-lock-extra-types)
"\\|"))
- (c-type-depth `(regexp-opt-depth (,@ c-type-types)))
+ (c-type-names-depth
+ `(regexp-opt-depth (,@ c-type-names)))
)
(setq c-font-lock-keywords-1
(list
;;
;; Simple regexps for speed.
;;
- ;; Fontify all type specifiers.
+ ;; Fontify all type names.
`(eval .
- (cons (concat "\\<\\(" (,@ c-type-types) "\\)\\>") 'font-lock-type-face))
+ (cons (concat "\\<\\(" (,@ c-type-names) "\\)\\>") 'font-lock-type-face))
;;
;; Fontify all builtin keywords (except case, default and goto; see below).
- (concat "\\<" c-keywords "\\>")
+ (concat "\\<\\(" c-keywords "\\|" c-type-specs "\\)\\>")
;;
;; Fontify case/goto keywords and targets, and case default/goto tags.
'("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
- (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
;; Anders Lindgren <andersl@csd.uu.se> points out that it is quicker to use
;; MATCH-ANCHORED to effectively anchor the regexp on the left.
;; This must come after the one for keywords and targets.
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:"
(beginning-of-line) (end-of-line)
- (1 font-lock-reference-face)))
+ (1 font-lock-constant-face)))
)))
(setq c-font-lock-keywords-3
;; We still have to fontify type specifiers individually, as C is so hairy.
(list
;;
- ;; Fontify all storage classes and type specifiers, plus their items.
+ ;; Fontify all storage types, plus their items.
`(eval .
- (list (concat "\\<\\(" (,@ c-type-types) "\\)\\>"
+ (list (concat "\\<\\(" (,@ c-type-names) "\\)\\>"
"\\([ \t*&]+\\sw+\\>\\)*")
;; Fontify each declaration item.
(list 'font-lock-match-c-style-declaration-item-and-skip-to-next
;; Start with point after all type specifiers.
- (list 'goto-char (list 'or (list 'match-beginning
- (+ (,@ c-type-depth) 2))
+ (list 'goto-char (list 'or
+ (list 'match-beginning
+ (+ (,@ c-type-names-depth) 2))
'(match-end 1)))
;; Finish with point after first type specifier.
'(goto-char (match-end 1))
font-lock-function-name-face
font-lock-variable-name-face)))))
;;
+ ;; Fontify all storage specs and types, plus their items.
+ `(eval .
+ (list (concat "\\<\\(" (,@ c-type-specs) "\\)\\>"
+ "[ \t]*\\(\\sw+\\)?")
+ (list 1 'font-lock-keyword-face)
+ (list (+ (,@ c-type-specs-depth) 2) 'font-lock-type-face nil t)
+ (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
+ nil nil
+ ;; Fontify as a variable or function name.
+ '(1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face) nil t))))
+ ;;
;; Fontify structures, or typedef names, plus their items.
'("\\(}\\)[ \t*]*\\sw"
(font-lock-match-c-style-declaration-item-and-skip-to-next
(goto-char (match-end 1)) nil
- (1 (if (match-beginning 2)
- font-lock-function-name-face
- font-lock-variable-name-face))))
+ (1 font-lock-type-face)))
;;
;; Fontify anything at beginning of line as a declaration or definition.
'("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
(regexp-opt
'("break" "continue" "do" "else" "for" "if" "return" "switch"
"while" "asm" "catch" "delete" "new" "sizeof" "this" "throw" "try"
- ;; Eric Hopper <hopper@omnifarious.mn.org> says these are new.
- "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t)))
+ ;; Branko Cibej <branko.cibej@hermes.si> says this is new.
+ "export"
+ ;; Mark Mitchell <mmitchell@usa.net> says these are new.
+ "mutable" "explicit"
+ ;; Alain Picard <ap@abelard.apana.org.au> suggests treating these
+ ;; as keywords not types.
+ "typedef" "template"
+ "extern" "auto" "register" "const" "volatile" "static"
+ "inline" "friend" "virtual") t)))
(c++-operators
(eval-when-compile
(regexp-opt
'("+" "-" "*" "/" "%" "^" "&" "|" "~" "!" "=" "<" ">" "+=" "-="
"*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" ">>=" "<<=" "==" "!="
"<=" ">=" "&&" "||" "++" "--" "->*" "," "->" "[]" "()"))))
- (c++-type-types
+ (c++-type-specs
+ (eval-when-compile
+ (regexp-opt
+ '("class" "public" "private" "protected" "typename"
+ "struct" "union" "enum" "namespace" "using"
+ ;; Eric Hopper <hopper@omnifarious.mn.org> says these are new.
+ "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t)))
+ (c++-type-specs-depth
+ (regexp-opt-depth c++-type-specs))
+ (c++-type-names
`(mapconcat 'identity
(cons
(,@ (eval-when-compile
(regexp-opt
- '("auto" "extern" "register" "static" "typedef" "struct"
- "union" "enum" "signed" "unsigned" "short" "long"
- "int" "char" "float" "double" "void" "volatile" "const"
- "inline" "friend" "bool" "virtual" "complex" "template"
- "namespace" "using"
- ;; Mark Mitchell <mmitchell@usa.net> says these are new.
- "explicit" "mutable"))))
+ '("signed" "unsigned" "short" "long"
+ "int" "char" "float" "double" "void"
+ "bool" "complex"))))
c++-font-lock-extra-types)
"\\|"))
+ (c++-type-names-depth `(regexp-opt-depth (,@ c++-type-names)))
;;
;; A brave attempt to match templates following a type and/or match
;; class membership. See and sync the above function
;; `font-lock-match-c++-style-declaration-item-and-skip-to-next'.
(c++-type-suffix (concat "\\([ \t]*<\\([^>\n]+\\)[ \t*&]*>\\)?"
"\\([ \t]*::[ \t*~]*\\(\\sw+\\)\\)*"))
+ (c++-type-suffix-depth (regexp-opt-depth c++-type-suffix))
;; If the string is a type, it may be followed by the cruft above.
(c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix))
+ (c++-type-spec-depth (regexp-opt-depth c++-type-spec))
;;
;; Parenthesis depth of user-defined types not forgetting their cruft.
(c++-type-depth `(regexp-opt-depth
- (concat (,@ c++-type-types) (,@ c++-type-suffix))))
+ (concat (,@ c++-type-names) (,@ c++-type-suffix))))
)
(setq c++-font-lock-keywords-1
(append
(cdr c-font-lock-keywords-1)
(list
;;
- ;; Class names etc.
- (list (concat "\\<\\(class\\|public\\|private\\|protected\\)\\>[ \t]*"
- "\\(" c++-type-spec "\\)?")
- '(1 font-lock-type-face)
- '(3 (if (match-beginning 6)
- font-lock-type-face
- font-lock-function-name-face) nil t)
- '(5 font-lock-function-name-face nil t)
- '(7 font-lock-function-name-face nil t))
- ;;
;; Fontify function name definitions, possibly incorporating class names.
(list (concat "^" c++-type-spec "[ \t]*(")
'(1 (if (or (match-beginning 2) (match-beginning 4))
font-lock-type-face
font-lock-function-name-face))
- '(3 font-lock-function-name-face nil t)
+ '(3 font-lock-type-face nil t)
'(5 font-lock-function-name-face nil t))
)))
;;
;; The list `c-font-lock-keywords-2' for C++ plus operator overloading.
`(eval .
- (cons (concat "\\<\\(" (,@ c++-type-types) "\\)\\>")
+ (cons (concat "\\<\\(" (,@ c++-type-names) "\\)\\>")
'font-lock-type-face))
;;
;; Fontify operator overloading.
;;
;; Fontify case/goto keywords and targets, and case default/goto tags.
'("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
- (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
;; This must come after the one for keywords and targets.
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:\\($\\|[^:]\\)"
(beginning-of-line) (end-of-line)
- (1 font-lock-reference-face)))
+ (1 font-lock-constant-face)))
;;
;; Fontify other builtin keywords.
- (concat "\\<" c++-keywords "\\>")
+ (concat "\\<\\(" c++-keywords "\\|" c++-type-specs "\\)\\>")
;;
;; Eric Hopper <hopper@omnifarious.mn.org> says `true' and `false' are new.
- '("\\<\\(false\\|true\\)\\>" . font-lock-reference-face)
+ '("\\<\\(false\\|true\\)\\>" . font-lock-constant-face)
)))
(setq c++-font-lock-keywords-3
;;
;; Fontify all storage classes and type specifiers, plus their items.
`(eval .
- (list (concat "\\<\\(" (,@ c++-type-types) "\\)\\>" (,@ c++-type-suffix)
+ (list (concat "\\<\\(" (,@ c++-type-names) "\\)\\>" (,@ c++-type-suffix)
"\\([ \t*&]+" (,@ c++-type-spec) "\\)*")
+ ;; The name of any template type.
+ (list (+ (,@ c++-type-names-depth) 3) 'font-lock-type-face nil t)
;; Fontify each declaration item.
(list 'font-lock-match-c++-style-declaration-item-and-skip-to-next
;; Start with point after all type specifiers.
font-lock-type-face)
((match-beginning 6) font-lock-function-name-face)
(t font-lock-variable-name-face)))
- '(3 font-lock-function-name-face nil t)
+ '(3 font-lock-type-face nil t)
'(5 (if (match-beginning 6)
font-lock-function-name-face
font-lock-variable-name-face) nil t))))
;;
+ ;; Fontify all storage specs and types, plus their items.
+ `(eval .
+ (list (concat "\\<" (,@ c++-type-specs) "\\>" (,@ c++-type-suffix)
+ "[ \t]*\\(" (,@ c++-type-spec) "\\)?")
+ ;; The name of any template type.
+ (list (+ (,@ c++-type-specs-depth) 2) 'font-lock-type-face nil t)
+ ;; The name of any type.
+ (list (+ (,@ c++-type-specs-depth) (,@ c++-type-suffix-depth) 2)
+ 'font-lock-type-face nil t)
+ ;; Fontify each declaration item.
+ (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next
+ ;; Start with point after all type specifiers.
+ nil
+ ;; Finish with point after first type specifier.
+ nil
+ ;; Fontify as a variable or function name.
+ '(1 (cond ((or (match-beginning 2) (match-beginning 4))
+ font-lock-type-face)
+ ((match-beginning 6) font-lock-function-name-face)
+ (t font-lock-variable-name-face)))
+ '(3 font-lock-type-face nil t)
+ '(5 (if (match-beginning 6)
+ font-lock-function-name-face
+ font-lock-variable-name-face) nil t))
+ ))
+ ;;
;; Fontify structures, or typedef names, plus their items.
'("\\(}\\)[ \t*]*\\sw"
(font-lock-match-c++-style-declaration-item-and-skip-to-next
(goto-char (match-end 1)) nil
- (1 (if (match-beginning 6)
- font-lock-function-name-face
- font-lock-variable-name-face))))
+ (1 font-lock-type-face)))
;;
;; Fontify anything at beginning of line as a declaration or definition.
(list (concat "^\\(" c++-type-spec "[ \t*&]*\\)+")
font-lock-type-face)
((match-beginning 6) font-lock-function-name-face)
(t font-lock-variable-name-face)))
- (3 font-lock-function-name-face nil t)
+ (3 font-lock-type-face nil t)
(5 (if (match-beginning 6)
font-lock-function-name-face
font-lock-variable-name-face) nil t)))
(let* ((objc-keywords
(eval-when-compile
(regexp-opt '("break" "continue" "do" "else" "for" "if" "return"
- "switch" "while" "sizeof" "self" "super") t)))
- (objc-type-types
+ "switch" "while" "sizeof" "self" "super"
+ "typedef" "auto" "extern" "static"
+ "volatile" "const") t)))
+ (objc-type-specs
+ (eval-when-compile
+ (regexp-opt
+ '("register" "struct" "union" "enum"
+ "oneway" "in" "out" "inout" "bycopy" "byref") t)))
+ (objc-type-specs-depth
+ (regexp-opt-depth objc-type-specs))
+ (objc-type-names
`(mapconcat 'identity
(cons
(,@ (eval-when-compile
(regexp-opt
- '("auto" "extern" "register" "static" "typedef" "struct"
- "union" "enum" "signed" "unsigned" "short" "long"
- "int" "char" "float" "double" "void" "volatile" "const"
- "id" "oneway" "in" "out" "inout" "bycopy" "byref"))))
+ '("signed" "unsigned" "short" "long"
+ "int" "char" "float" "double" "void"
+ "id"))))
objc-font-lock-extra-types)
"\\|"))
- (objc-type-depth `(regexp-opt-depth (,@ objc-type-types)))
+ (objc-type-names-depth
+ `(regexp-opt-depth (,@ objc-type-names)))
)
(setq objc-font-lock-keywords-1
(append
;; Fontify compiler directives.
'("@\\(\\sw+\\)\\>"
(1 font-lock-keyword-face)
- ("\\=[ \t:<(,]*\\(\\sw+\\)" nil nil
- (1 font-lock-function-name-face)))
+ ("\\=[ \t:<,]*\\(\\sw+\\)" nil nil
+ (1 font-lock-type-face)))
;;
;; Fontify method names and arguments. Oh Lordy!
;; First, on the same line as the function declaration.
- '("^[+-][ \t]*\\(PRIVATE\\)?[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
- (1 font-lock-type-face nil t)
- (3 font-lock-type-face nil t)
- (4 font-lock-function-name-face)
- ("\\=[ \t]*\\(\\sw+\\)?:[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
+ '("^[+-][ \t]*\\(PRIVATE\\>\\)?[ \t]*\\(([^)\n]+)\\)?[ \t]*\\(\\sw+\\)"
+ (1 font-lock-keyword-face nil t)
+ (3 font-lock-function-name-face)
+ ("\\=[ \t]*\\(\\sw+\\)?:[ \t]*\\(([^)\n]+)\\)?[ \t]*\\(\\sw+\\)"
nil nil
(1 font-lock-function-name-face nil t)
- (3 font-lock-type-face nil t)
- (4 font-lock-variable-name-face)))
+ (3 font-lock-variable-name-face)))
;; Second, on lines following the function declaration.
- '(":" ("^[ \t]*\\(\\sw+\\)?:[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
+ '(":" ("^[ \t]*\\(\\sw+\\)?:[ \t]*\\(([^)\n]+)\\)?[ \t]*\\(\\sw+\\)"
(beginning-of-line) (end-of-line)
(1 font-lock-function-name-face nil t)
- (3 font-lock-type-face nil t)
- (4 font-lock-variable-name-face)))
+ (3 font-lock-variable-name-face)))
)))
(setq objc-font-lock-keywords-2
;;
;; Fontify all type specifiers.
`(eval .
- (cons (concat "\\<\\(" (,@ objc-type-types) "\\)\\>")
+ (cons (concat "\\<\\(" (,@ objc-type-names) "\\)\\>")
'font-lock-type-face))
;;
;; Fontify all builtin keywords (except case, default and goto; see below).
- (concat "\\<" objc-keywords "\\>")
+ (concat "\\<\\(" objc-keywords "\\|" objc-type-specs "\\)\\>")
;;
;; Fontify case/goto keywords and targets, and case default/goto tags.
'("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
- (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
;; Fontify tags iff sole statement on line, otherwise we detect selectors.
;; This must come after the one for keywords and targets.
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
(beginning-of-line) (end-of-line)
- (1 font-lock-reference-face)))
+ (1 font-lock-constant-face)))
;;
;; Fontify null object pointers.
- '("\\<[Nn]il\\>" . font-lock-reference-face)
+ '("\\<[Nn]il\\>" . font-lock-constant-face)
)))
(setq objc-font-lock-keywords-3
;;
;; Fontify all storage classes and type specifiers, plus their items.
`(eval .
- (list (concat "\\<\\(" (,@ objc-type-types) "\\)\\>"
+ (list (concat "\\<\\(" (,@ objc-type-names) "\\)\\>"
"\\([ \t*&]+\\sw+\\>\\)*")
;; Fontify each declaration item.
(list 'font-lock-match-c-style-declaration-item-and-skip-to-next
;; Start with point after all type specifiers.
- (list 'goto-char (list 'or (list 'match-beginning
- (+ (,@ objc-type-depth) 2))
- '(match-end 1)))
+ (list 'goto-char
+ (list 'or (list 'match-beginning
+ (+ (,@ objc-type-names-depth) 2))
+ '(match-end 1)))
;; Finish with point after first type specifier.
'(goto-char (match-end 1))
;; Fontify as a variable or function name.
font-lock-function-name-face
font-lock-variable-name-face)))))
;;
+ ;; Fontify all storage specs and types, plus their items.
+ `(eval .
+ (list (concat "\\<\\(" (,@ objc-type-specs) "[ \t]*\\)+\\>"
+ "[ \t]*\\(\\sw+\\)?")
+ ;; The name of any type.
+ (list (+ (,@ objc-type-specs-depth) 2) 'font-lock-type-face nil t)
+ ;; Fontify each declaration item.
+ (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next
+ nil nil
+ ;; Fontify as a variable or function name.
+ '(1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face)))
+ ))
+ ;;
;; Fontify structures, or typedef names, plus their items.
'("\\(}\\)[ \t*]*\\sw"
(font-lock-match-c-style-declaration-item-and-skip-to-next
(goto-char (match-end 1)) nil
- (1 (if (match-beginning 2)
- font-lock-function-name-face
- font-lock-variable-name-face))))
+ (1 font-lock-type-face)))
;;
;; Fontify anything at beginning of line as a declaration or definition.
'("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
(java-other-types
'(mapconcat 'identity (cons "\\sw+\\.\\sw+" java-font-lock-extra-types)
"\\|"))
- (java-other-depth `(regexp-opt-depth (,@ java-other-types)))
+ (java-other-depth
+ `(regexp-opt-depth (,@ java-other-types)))
)
(setq java-font-lock-keywords-1
(list
;;
;; Fontify package names in import directives.
'("\\<\\(import\\|package\\)\\>[ \t]*\\(\\sw+\\)?"
- (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
))
(setq java-font-lock-keywords-2
(list
;;
;; Fontify all builtin type specifiers.
- (cons (concat "\\<\\(" java-minor-types "\\|" java-major-types "\\)\\>")
- 'font-lock-type-face)
+ (cons (concat "\\<\\(" java-minor-types "\\)\\>") 'font-lock-type-face)
;;
;; Fontify all builtin keywords (except below).
- (concat "\\<" java-keywords "\\>")
+ (concat "\\<\\(" java-keywords "\\|" java-major-types "\\)\\>")
;;
;; Fontify keywords and targets, and case default/goto tags.
(list "\\<\\(break\\|case\\|continue\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
- '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
+ '(1 font-lock-keyword-face) '(2 font-lock-constant-face nil t))
;; This must come after the one for keywords and targets.
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:"
(beginning-of-line) (end-of-line)
- (1 font-lock-reference-face)))
+ (1 font-lock-constant-face)))
;;
;; Fontify keywords and types; the first can be followed by a type list.
(list (concat "\\<\\("
(1 font-lock-type-face)))
;;
;; Fontify all constants.
- '("\\<\\(false\\|null\\|true\\)\\>" . font-lock-reference-face)
+ '("\\<\\(false\\|null\\|true\\)\\>" . font-lock-constant-face)
;;
;; Javadoc tags within comments.
'("@\\(author\\|exception\\|return\\|see\\|version\\)\\>"
- (1 font-lock-reference-face prepend))
+ (1 font-lock-constant-face prepend))
'("@\\(param\\)\\>[ \t]*\\(\\sw+\\)?"
- (1 font-lock-reference-face prepend)
+ (1 font-lock-constant-face prepend)
(2 font-lock-variable-name-face prepend t))
)))