339 |
(defvar font-lock-warning-face 'font-lock-warning-face |
(defvar font-lock-warning-face 'font-lock-warning-face |
340 |
"Face name to use for things that should stand out.") |
"Face name to use for things that should stand out.") |
341 |
|
|
342 |
(defvar font-lock-reference-face 'font-lock-constant-face |
(defvar font-lock-reference-face 'font-lock-constant-face) |
343 |
"This variable is obsolete. Use `font-lock-constant-face'.") |
(make-obsolete-variable 'font-lock-reference-face 'font-lock-constant-face) |
344 |
|
|
345 |
;; Fontification variables: |
;; Fontification variables: |
346 |
|
|
519 |
This is normally set via `font-lock-defaults'.") |
This is normally set via `font-lock-defaults'.") |
520 |
|
|
521 |
(defvar font-lock-beginning-of-syntax-function nil |
(defvar font-lock-beginning-of-syntax-function nil |
522 |
"*Non-nil means use this function to move back outside of a syntactic block. |
"*Non-nil means use this function to move back outside all constructs. |
523 |
When called with no args it should leave point at the beginning of any |
When called with no args it should move point backward to a place which |
524 |
enclosing syntactic block. |
is not in a string or comment and not within any bracket-pairs (or else, |
525 |
If this is nil, the beginning of the buffer is used (in the worst case). |
a place such that any bracket-pairs outside it can be ignored for Emacs |
526 |
|
syntax analysis and fontification). |
527 |
|
|
528 |
|
If this is nil, the beginning of the buffer is used, which is |
529 |
|
always correct but tends to be slow. |
530 |
This is normally set via `font-lock-defaults'. |
This is normally set via `font-lock-defaults'. |
531 |
It is preferable to set `syntax-begin-function' instead.") |
This variable is semi-obsolete; we recommend setting |
532 |
|
`syntax-begin-function' instead.") |
533 |
|
|
534 |
(defvar font-lock-mark-block-function nil |
(defvar font-lock-mark-block-function nil |
535 |
"*Non-nil means use this function to mark a block of text. |
"*Non-nil means use this function to mark a block of text. |
618 |
to use nil for MODE (and place the call in a loop or on a hook) to avoid |
to use nil for MODE (and place the call in a loop or on a hook) to avoid |
619 |
subtle problems due to details of the implementation. |
subtle problems due to details of the implementation. |
620 |
|
|
621 |
Note that some modes have specialised support for additional patterns, e.g., |
Note that some modes have specialized support for additional patterns, e.g., |
622 |
see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types', |
see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types', |
623 |
`objc-font-lock-extra-types' and `java-font-lock-extra-types'." |
`objc-font-lock-extra-types' and `java-font-lock-extra-types'." |
624 |
(cond (mode |
(cond (mode |
788 |
:version "21.1" |
:version "21.1" |
789 |
:group 'font-lock) |
:group 'font-lock) |
790 |
|
|
791 |
(defvar fast-lock-mode nil) |
(defvar fast-lock-mode) |
792 |
(defvar lazy-lock-mode nil) |
(defvar lazy-lock-mode) |
793 |
(defvar jit-lock-mode nil) |
(defvar jit-lock-mode) |
794 |
|
|
795 |
(defun font-lock-turn-on-thing-lock () |
(defun font-lock-turn-on-thing-lock () |
796 |
(let ((thing-mode (font-lock-value-in-major-mode font-lock-support-mode))) |
(let ((thing-mode (font-lock-value-in-major-mode font-lock-support-mode))) |
811 |
(not font-lock-keywords-only)))))) |
(not font-lock-keywords-only)))))) |
812 |
|
|
813 |
(defun font-lock-turn-off-thing-lock () |
(defun font-lock-turn-off-thing-lock () |
814 |
(cond (fast-lock-mode |
(cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
815 |
(fast-lock-mode -1)) |
(fast-lock-mode -1)) |
816 |
(jit-lock-mode |
((and (boundp 'jit-lock-mode) jit-lock-mode) |
817 |
(jit-lock-unregister 'font-lock-fontify-region) |
(jit-lock-unregister 'font-lock-fontify-region) |
818 |
;; Reset local vars to the non-jit-lock case. |
;; Reset local vars to the non-jit-lock case. |
819 |
(kill-local-variable 'font-lock-fontify-buffer-function)) |
(kill-local-variable 'font-lock-fontify-buffer-function)) |
820 |
(lazy-lock-mode |
((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
821 |
(lazy-lock-mode -1)))) |
(lazy-lock-mode -1)))) |
822 |
|
|
823 |
(defun font-lock-after-fontify-buffer () |
(defun font-lock-after-fontify-buffer () |
824 |
(cond (fast-lock-mode |
(cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
825 |
(fast-lock-after-fontify-buffer)) |
(fast-lock-after-fontify-buffer)) |
826 |
;; Useless now that jit-lock intercepts font-lock-fontify-buffer. -sm |
;; Useless now that jit-lock intercepts font-lock-fontify-buffer. -sm |
827 |
;; (jit-lock-mode |
;; (jit-lock-mode |
828 |
;; (jit-lock-after-fontify-buffer)) |
;; (jit-lock-after-fontify-buffer)) |
829 |
(lazy-lock-mode |
((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
830 |
(lazy-lock-after-fontify-buffer)))) |
(lazy-lock-after-fontify-buffer)))) |
831 |
|
|
832 |
(defun font-lock-after-unfontify-buffer () |
(defun font-lock-after-unfontify-buffer () |
833 |
(cond (fast-lock-mode |
(cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
834 |
(fast-lock-after-unfontify-buffer)) |
(fast-lock-after-unfontify-buffer)) |
835 |
;; Useless as well. It's only called when: |
;; Useless as well. It's only called when: |
836 |
;; - turning off font-lock: it does not matter if we leave spurious |
;; - turning off font-lock: it does not matter if we leave spurious |
840 |
;; |
;; |
841 |
;; (jit-lock-mode |
;; (jit-lock-mode |
842 |
;; (jit-lock-after-unfontify-buffer)) |
;; (jit-lock-after-unfontify-buffer)) |
843 |
(lazy-lock-mode |
((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
844 |
(lazy-lock-after-unfontify-buffer)))) |
(lazy-lock-after-unfontify-buffer)))) |
845 |
|
|
846 |
;;; End of Font Lock Support mode. |
;;; End of Font Lock Support mode. |
932 |
(font-lock-after-unfontify-buffer) |
(font-lock-after-unfontify-buffer) |
933 |
(setq font-lock-fontified nil))) |
(setq font-lock-fontified nil))) |
934 |
|
|
935 |
|
(defvar font-lock-dont-widen nil |
936 |
|
"If non-nil, font-lock will work on the non-widened buffer. |
937 |
|
Useful for things like RMAIL and Info where the whole buffer is not |
938 |
|
a very meaningful entity to highlight.") |
939 |
|
|
940 |
(defun font-lock-default-fontify-region (beg end loudly) |
(defun font-lock-default-fontify-region (beg end loudly) |
941 |
(save-buffer-state |
(save-buffer-state |
942 |
((parse-sexp-lookup-properties font-lock-syntactic-keywords) |
((parse-sexp-lookup-properties font-lock-syntactic-keywords) |
943 |
(old-syntax-table (syntax-table))) |
(old-syntax-table (syntax-table))) |
944 |
(unwind-protect |
(unwind-protect |
945 |
(save-restriction |
(save-restriction |
946 |
(widen) |
(unless font-lock-dont-widen (widen)) |
947 |
;; Use the fontification syntax table, if any. |
;; Use the fontification syntax table, if any. |
948 |
(when font-lock-syntax-table |
(when font-lock-syntax-table |
949 |
(set-syntax-table font-lock-syntax-table)) |
(set-syntax-table font-lock-syntax-table)) |
985 |
(defvar font-lock-extra-managed-props nil |
(defvar font-lock-extra-managed-props nil |
986 |
"Additional text properties managed by font-lock. |
"Additional text properties managed by font-lock. |
987 |
This is used by `font-lock-default-unfontify-region' to decide |
This is used by `font-lock-default-unfontify-region' to decide |
988 |
what properties to clear before refontifying a region. |
what properties to clear before refontifying a region.") |
|
Since it is more or less directly passed to `remove-text-properties', |
|
|
it should have the shape of a property list (i.e. every other element |
|
|
is ignored).") |
|
989 |
|
|
990 |
(defun font-lock-default-unfontify-region (beg end) |
(defun font-lock-default-unfontify-region (beg end) |
991 |
(save-buffer-state nil |
(save-buffer-state nil |
992 |
(remove-text-properties |
(remove-list-of-text-properties |
993 |
beg end (append |
beg end (append |
994 |
font-lock-extra-managed-props |
font-lock-extra-managed-props |
995 |
(if font-lock-syntactic-keywords |
(if font-lock-syntactic-keywords |
996 |
'(face nil syntax-table nil font-lock-multiline nil) |
'(syntax-table face font-lock-multiline) |
997 |
'(face nil font-lock-multiline nil)))))) |
'(face font-lock-multiline)))))) |
998 |
|
|
999 |
;; Called when any modification is made to buffer text. |
;; Called when any modification is made to buffer text. |
1000 |
(defun font-lock-after-change-function (beg end old-len) |
(defun font-lock-after-change-function (beg end old-len) |
1030 |
(font-lock-fontify-region (point) (mark))) |
(font-lock-fontify-region (point) (mark))) |
1031 |
((error quit) (message "Fontifying block...%s" error-data))))))) |
((error quit) (message "Fontifying block...%s" error-data))))))) |
1032 |
|
|
1033 |
(define-key facemenu-keymap "\M-g" 'font-lock-fontify-block) |
(if (boundp 'facemenu-keymap) |
1034 |
|
(define-key facemenu-keymap "\M-g" 'font-lock-fontify-block)) |
1035 |
|
|
1036 |
;;; End of Fontification functions. |
;;; End of Fontification functions. |
1037 |
|
|
1318 |
|
|
1319 |
(defun font-lock-fontify-keywords-region (start end &optional loudly) |
(defun font-lock-fontify-keywords-region (start end &optional loudly) |
1320 |
"Fontify according to `font-lock-keywords' between START and END. |
"Fontify according to `font-lock-keywords' between START and END. |
1321 |
START should be at the beginning of a line." |
START should be at the beginning of a line. |
1322 |
|
LOUDLY, if non-nil, allows progress-meter bar." |
1323 |
(unless (eq (car font-lock-keywords) t) |
(unless (eq (car font-lock-keywords) t) |
1324 |
(setq font-lock-keywords |
(setq font-lock-keywords |
1325 |
(font-lock-compile-keywords font-lock-keywords t))) |
(font-lock-compile-keywords font-lock-keywords t))) |
1474 |
(when (nth 4 defaults) |
(when (nth 4 defaults) |
1475 |
(set (make-local-variable 'font-lock-beginning-of-syntax-function) |
(set (make-local-variable 'font-lock-beginning-of-syntax-function) |
1476 |
(nth 4 defaults))) |
(nth 4 defaults))) |
1477 |
;; The variable alist is set in font-core.el. |
;; Variable alist? |
1478 |
|
(dolist (x (nthcdr 5 defaults)) |
1479 |
|
(set (make-local-variable (car x)) (cdr x))) |
1480 |
;; Setup `font-lock-keywords' last because its value might depend |
;; Setup `font-lock-keywords' last because its value might depend |
1481 |
;; on other settings (e.g. font-lock-compile-keywords uses |
;; on other settings (e.g. font-lock-compile-keywords uses |
1482 |
;; font-lock-beginning-of-syntax-function). |
;; font-lock-beginning-of-syntax-function). |
1740 |
The expected syntax of a declaration/definition item is `word' (preceded by |
The expected syntax of a declaration/definition item is `word' (preceded by |
1741 |
optional whitespace and `*' characters and proceeded by optional whitespace) |
optional whitespace and `*' characters and proceeded by optional whitespace) |
1742 |
optionally followed by a `('. Everything following the item (but belonging to |
optionally followed by a `('. Everything following the item (but belonging to |
1743 |
it) is expected to by skip-able by `scan-sexps', and items are expected to be |
it) is expected to be skip-able by `scan-sexps', and items are expected to be |
1744 |
separated with a `,' and to be terminated with a `;'. |
separated with a `,' and to be terminated with a `;'. |
1745 |
|
|
1746 |
Thus the regexp matches after point: word ( |
Thus the regexp matches after point: word ( |
1759 |
(let ((pos (point))) |
(let ((pos (point))) |
1760 |
(skip-chars-backward " \t\n") |
(skip-chars-backward " \t\n") |
1761 |
(skip-syntax-backward "w") |
(skip-syntax-backward "w") |
1762 |
(unless (looking-at "\\(\\sw+\\)[ \t\n]*\\sw*_\\sw*[ \t\n]*\\((\\)?") |
(unless (looking-at "\\(\\sw+\\)[ \t\n]*\\sw+[ \t\n]*\\(((?\\)?") |
1763 |
;; Looks like it was something else, so go back to where we |
;; Looks like it was something else, so go back to where we |
1764 |
;; were and reset the match data by rematching. |
;; were and reset the match data by rematching. |
1765 |
(goto-char pos) |
(goto-char pos) |
1793 |
;; Variable declarations. |
;; Variable declarations. |
1794 |
"\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|" |
"\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|" |
1795 |
;; Structure declarations. |
;; Structure declarations. |
1796 |
"\\(class\\|group\\|package\\|struct\\|type\\)" |
"\\(class\\|group\\|theme\\|package\\|struct\\|type\\)" |
1797 |
"\\)\\)\\>" |
"\\)\\)\\>" |
1798 |
;; Any whitespace and defined object. |
;; Any whitespace and defined object. |
1799 |
"[ \t'\(]*" |
"[ \t'\(]*" |
1900 |
|
|
1901 |
(defcustom c++-font-lock-extra-types |
(defcustom c++-font-lock-extra-types |
1902 |
'("\\sw+_t" |
'("\\sw+_t" |
1903 |
"\\([iof]\\|str\\)+stream\\(buf\\)?" "ios" |
|
1904 |
"string" "rope" |
"string" "rope" |
1905 |
|
|
1906 |
"list" "slist" |
"list" "slist" |
1907 |
"deque" "vector" "bit_vector" |
"deque" "vector" "bit_vector" |
1908 |
|
|
1909 |
"set" "multiset" |
"set" "multiset" |
1910 |
"map" "multimap" |
"map" "multimap" |
|
"hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?" |
|
1911 |
"stack" "queue" "priority_queue" |
"stack" "queue" "priority_queue" |
1912 |
"type_info" |
"type_info" |
1913 |
"iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator" |
|
1914 |
"reference" "const_reference") |
;; (regexp-opt '("ios_base" "ios" "istream" "ostream" "istringstream" "ifstream" "iostream" "ofstream" "ostringstream" "fstream" "stringstream")) |
1915 |
|
"fstream\\|i\\(?:fstream\\|os\\(?:_base\\|tream\\)?\\|str\\(?:\\(?:ingstr\\)?eam\\)\\)\\|\\(?:o\\(?:f\\|string\\)?\\|string\\)stream" |
1916 |
|
|
1917 |
|
;; (regexp-opt '("hash" "hash_set" "hash_map" "hash_multiset" "hash_multimap")) |
1918 |
|
"hash\\(?:_\\(?:m\\(?:ap\\|ulti\\(?:map\\|set\\)\\)\\|set\\)\\)?" |
1919 |
|
|
1920 |
|
;; (regexp-opt '("pointer" "const_pointer" "reference" "const_reference" "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator" "size_type" "difference_type" "allocator_type")) |
1921 |
|
"allocator_type\\|const_\\(?:iterator\\|pointer\\|re\\(?:ference\\|verse_iterator\\)\\)\\|difference_type\\|iterator\\|pointer\\|re\\(?:ference\\|verse_iterator\\)\\|size_type" |
1922 |
|
) |
1923 |
"*List of extra types to fontify in C++ mode. |
"*List of extra types to fontify in C++ mode. |
1924 |
Each list item should be a regexp not containing word-delimiters. |
Each list item should be a regexp not containing word-delimiters. |
1925 |
For example, a value of (\"string\") means the word string is treated as a type |
For example, a value of (\"string\") means the word string is treated as a type |
2003 |
"ifndef" "include" "line" "pragma" "undef")))) |
"ifndef" "include" "line" "pragma" "undef")))) |
2004 |
(c-preprocessor-directives-depth |
(c-preprocessor-directives-depth |
2005 |
(regexp-opt-depth c-preprocessor-directives))) |
(regexp-opt-depth c-preprocessor-directives))) |
2006 |
|
|
2007 |
(defconst c-font-lock-keywords-1 |
(defconst c-font-lock-keywords-1 |
2008 |
(list |
(list |
2009 |
;; |
;; |
2208 |
"typeid" |
"typeid" |
2209 |
;; Branko Cibej <branko.cibej@hermes.si> says this is new. |
;; Branko Cibej <branko.cibej@hermes.si> says this is new. |
2210 |
"export" |
"export" |
2211 |
|
;; Copied from C. wsnyder@wsnyder.org says C++ needs it too. |
2212 |
|
"restrict" |
2213 |
;; Mark Mitchell <mmitchell@usa.net> says these are new. |
;; Mark Mitchell <mmitchell@usa.net> says these are new. |
2214 |
"mutable" "explicit" |
"mutable" "explicit" |
2215 |
;; Alain Picard <ap@abelard.apana.org.au> suggests treating these |
;; Alain Picard <ap@abelard.apana.org.au> suggests treating these |