Variable: cpp-font-lock-keywords

cpp-font-lock-keywords is a variable defined in font-lock.el.gz.

Value

(("^#[  ]*\\(?:error\\|warning\\)[      ]+\\(.+\\)" 1
  font-lock-warning-face prepend)
 ("^#[  ]*\\(?:import\\|include\\)[     ]*\\(<[^>\"\n]*>?\\)" 1
  font-lock-string-face prepend)
 ("^#[  ]*define[       ]+\\([[:alpha:]_][[:alnum:]_$]*\\)("
  (1 font-lock-function-name-face prepend)
  ((lambda (limit)
     (re-search-forward "\\(?:\\([[:alpha:]_][[:alnum:]_]*\\)[,]?\\)"
			(or
			 (save-excursion
			   (re-search-forward ")" limit t))
			 limit)
			t))
   nil nil (1 font-lock-variable-name-face prepend)))
 ("^#[  ]*\\(?:elif\\|if\\)\\>"
  ("\\<\\(defined\\)\\>[  ]*(?\\([[:alpha:]_][[:alnum:]_]*\\)?"
   nil nil (1 font-lock-builtin-face prepend)
   (2 font-lock-variable-name-face prepend t)))
 ("^\\(#[       ]*\\(?:define\\|e\\(?:l\\(?:if\\|se\\)\\|ndif\\|rror\\)\\|file\\|i\\(?:f\\(?:n?def\\)?\\|mport\\|nclude\\)\\|line\\|pragma\\|undef\\|warning\\)\\)\\>[       !]*\\([[:alpha:]_][[:alnum:]_]*\\)?"
  (1 font-lock-preprocessor-face prepend)
  (2 font-lock-variable-name-face nil t)))

Documentation

Font lock keywords for C preprocessor directives.

c-mode, c++-mode and objc-mode have their own font lock keywords for C preprocessor directives. This definition is for the other modes in which C preprocessor directives are used, e.g. asm-mode and ld-script-mode.

Source Code

;; Defined in /usr/src/emacs/lisp/font-lock.el.gz
(defconst cpp-font-lock-keywords
  (let* ((directives cpp-font-lock-keywords-source-directives)
	 (directives-depth cpp-font-lock-keywords-source-depth))
    (list
     ;;
     ;; Fontify error directives.
     '("^#[ \t]*\\(?:error\\|warning\\)[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend)
     ;;
     ;; Fontify filenames in #include <...> preprocessor directives as strings.
     '("^#[ \t]*\\(?:import\\|include\\)[ \t]*\\(<[^>\"\n]*>?\\)"
       1 font-lock-string-face prepend)
     ;;
     ;; Fontify function macro names.
     '("^#[ \t]*define[ \t]+\\([[:alpha:]_][[:alnum:]_$]*\\)("
       (1 font-lock-function-name-face prepend)
       ;;
       ;; Macro arguments.
       ((lambda (limit)
	  (re-search-forward
	   "\\(?:\\([[:alpha:]_][[:alnum:]_]*\\)[,]?\\)"
	   (or (save-excursion (re-search-forward ")" limit t))
	       limit)
	   t))
	nil nil (1 font-lock-variable-name-face prepend)))
     ;;
     ;; Fontify symbol names in #elif or #if ... defined preprocessor directives.
     '("^#[ \t]*\\(?:elif\\|if\\)\\>"
       ("\\<\\(defined\\)\\>[ \t]*(?\\([[:alpha:]_][[:alnum:]_]*\\)?" nil nil
	(1 font-lock-builtin-face prepend) (2 font-lock-variable-name-face prepend t)))
     ;;
     ;; Fontify otherwise as symbol names, and the preprocessor directive names.
     (list
      (concat "^\\(#[ \t]*\\(?:" directives
	      "\\)\\)\\>[ \t!]*\\([[:alpha:]_][[:alnum:]_]*\\)?")
      '(1 font-lock-preprocessor-face prepend)
      (list (+ 2 directives-depth)
	    'font-lock-variable-name-face nil t))))
  "Font lock keywords for C preprocessor directives.
`c-mode', `c++-mode' and `objc-mode' have their own font lock keywords
for C preprocessor directives.  This definition is for the other modes
in which C preprocessor directives are used, e.g. `asm-mode' and
`ld-script-mode'.")