Mercurial > emacs
comparison lisp/font-lock.el @ 26620:ca5397ec67cb
Doc fixes.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 26 Nov 1999 17:41:55 +0000 |
parents | 56f5519d4750 |
children | d22cd599a91a |
comparison
equal
deleted
inserted
replaced
26619:53b7c03dd560 | 26620:ca5397ec67cb |
---|---|
285 (radio :tag "Mode" | 285 (radio :tag "Mode" |
286 (const :tag "all" t) | 286 (const :tag "all" t) |
287 (symbol :tag "name")) | 287 (symbol :tag "name")) |
288 (radio :tag "Decoration" | 288 (radio :tag "Decoration" |
289 (const :tag "default" nil) | 289 (const :tag "default" nil) |
290 (const :tag "maximum" t) | 290 (const :tag "maximum" t) |
291 (integer :tag "level" 1))))) | 291 (integer :tag "level" 1))))) |
292 :group 'font-lock) | 292 :group 'font-lock) |
293 | 293 |
294 (defcustom font-lock-verbose 0 | 294 (defcustom font-lock-verbose 0 |
295 "*If non-nil, means show status messages for buffer fontification. | 295 "*If non-nil, means show status messages for buffer fontification. |
452 '((c-font-lock-keywords c-font-lock-keywords-1 | 452 '((c-font-lock-keywords c-font-lock-keywords-1 |
453 c-font-lock-keywords-2 c-font-lock-keywords-3) | 453 c-font-lock-keywords-2 c-font-lock-keywords-3) |
454 nil nil ((?_ . "w")) beginning-of-defun | 454 nil nil ((?_ . "w")) beginning-of-defun |
455 (font-lock-mark-block-function . mark-defun))) | 455 (font-lock-mark-block-function . mark-defun))) |
456 (c++-mode-defaults | 456 (c++-mode-defaults |
457 '((c++-font-lock-keywords c++-font-lock-keywords-1 | 457 '((c++-font-lock-keywords c++-font-lock-keywords-1 |
458 c++-font-lock-keywords-2 c++-font-lock-keywords-3) | 458 c++-font-lock-keywords-2 c++-font-lock-keywords-3) |
459 nil nil ((?_ . "w")) beginning-of-defun | 459 nil nil ((?_ . "w")) beginning-of-defun |
460 (font-lock-mark-block-function . mark-defun))) | 460 (font-lock-mark-block-function . mark-defun))) |
461 (objc-mode-defaults | 461 (objc-mode-defaults |
462 '((objc-font-lock-keywords objc-font-lock-keywords-1 | 462 '((objc-font-lock-keywords objc-font-lock-keywords-1 |
591 It should take two args, the beginning and end of the region. | 591 It should take two args, the beginning and end of the region. |
592 This is normally set via `font-lock-defaults'.") | 592 This is normally set via `font-lock-defaults'.") |
593 | 593 |
594 (defvar font-lock-inhibit-thing-lock nil | 594 (defvar font-lock-inhibit-thing-lock nil |
595 "List of Font Lock mode related modes that should not be turned on. | 595 "List of Font Lock mode related modes that should not be turned on. |
596 Currently, valid mode names as `fast-lock-mode', `jit-lock-mode' and | 596 Currently, valid mode names are `fast-lock-mode', `jit-lock-mode' and |
597 `lazy-lock-mode'. This is normally set via `font-lock-defaults'.") | 597 `lazy-lock-mode'. This is normally set via `font-lock-defaults'.") |
598 | 598 |
599 (defvar font-lock-mode nil) ; Whether we are turned on/modeline. | 599 (defvar font-lock-mode nil) ; Whether we are turned on/modeline. |
600 (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. | 600 (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. |
601 | 601 |
860 :group 'font-lock | 860 :group 'font-lock |
861 :require 'font-lock) | 861 :require 'font-lock) |
862 | 862 |
863 (defcustom font-lock-global-modes t | 863 (defcustom font-lock-global-modes t |
864 "*Modes for which Font Lock mode is automagically turned on. | 864 "*Modes for which Font Lock mode is automagically turned on. |
865 Global Font Lock mode is controlled by the `global-font-lock-mode' command. | 865 Global Font Lock mode is controlled by the command `global-font-lock-mode'. |
866 If nil, means no modes have Font Lock mode automatically turned on. | 866 If nil, means no modes have Font Lock mode automatically turned on. |
867 If t, all modes that support Font Lock mode have it automatically turned on. | 867 If t, all modes that support Font Lock mode have it automatically turned on. |
868 If a list, it should be a list of `major-mode' symbol names for which Font Lock | 868 If a list, it should be a list of `major-mode' symbol names for which Font Lock |
869 mode should be automatically turned on. The sense of the list is negated if it | 869 mode should be automatically turned on. The sense of the list is negated if it |
870 begins with `not'. For example: | 870 begins with `not'. For example: |
1034 ;; directives correctly and cleanly. (It is the same problem as fontifying | 1034 ;; directives correctly and cleanly. (It is the same problem as fontifying |
1035 ;; multi-line strings and comments; regexps are not appropriate for the job.) | 1035 ;; multi-line strings and comments; regexps are not appropriate for the job.) |
1036 | 1036 |
1037 ;;;###autoload | 1037 ;;;###autoload |
1038 (defun font-lock-fontify-buffer () | 1038 (defun font-lock-fontify-buffer () |
1039 "Fontify the current buffer the way `font-lock-mode' would." | 1039 "Fontify the current buffer the way the function `font-lock-mode' would." |
1040 (interactive) | 1040 (interactive) |
1041 (let ((font-lock-verbose (or font-lock-verbose (interactive-p)))) | 1041 (let ((font-lock-verbose (or font-lock-verbose (interactive-p)))) |
1042 (funcall font-lock-fontify-buffer-function))) | 1042 (funcall font-lock-fontify-buffer-function))) |
1043 | 1043 |
1044 (defun font-lock-unfontify-buffer () | 1044 (defun font-lock-unfontify-buffer () |
1114 (set-syntax-table old-syntax-table)))) | 1114 (set-syntax-table old-syntax-table)))) |
1115 | 1115 |
1116 ;; The following must be rethought, since keywords can override fontification. | 1116 ;; The following must be rethought, since keywords can override fontification. |
1117 ; ;; Now scan for keywords, but not if we are inside a comment now. | 1117 ; ;; Now scan for keywords, but not if we are inside a comment now. |
1118 ; (or (and (not font-lock-keywords-only) | 1118 ; (or (and (not font-lock-keywords-only) |
1119 ; (let ((state (parse-partial-sexp beg end nil nil | 1119 ; (let ((state (parse-partial-sexp beg end nil nil |
1120 ; font-lock-cache-state))) | 1120 ; font-lock-cache-state))) |
1121 ; (or (nth 4 state) (nth 7 state)))) | 1121 ; (or (nth 4 state) (nth 7 state)))) |
1122 ; (font-lock-fontify-keywords-region beg end)) | 1122 ; (font-lock-fontify-keywords-region beg end)) |
1123 | 1123 |
1124 (defun font-lock-default-unfontify-region (beg end) | 1124 (defun font-lock-default-unfontify-region (beg end) |
1380 ;; | 1380 ;; |
1381 ;; If the region starts inside a string or comment, show the extent of it. | 1381 ;; If the region starts inside a string or comment, show the extent of it. |
1382 (when (or (nth 3 state) (nth 4 state)) | 1382 (when (or (nth 3 state) (nth 4 state)) |
1383 (setq string (nth 3 state) beg (point)) | 1383 (setq string (nth 3 state) beg (point)) |
1384 (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) | 1384 (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) |
1385 (put-text-property beg (point) 'face | 1385 (put-text-property beg (point) 'face |
1386 (if string | 1386 (if string |
1387 font-lock-string-face | 1387 font-lock-string-face |
1388 font-lock-comment-face))) | 1388 font-lock-comment-face))) |
1389 ;; | 1389 ;; |
1390 ;; Find each interesting place between here and `end'. | 1390 ;; Find each interesting place between here and `end'. |
1391 (while (and (< (point) end) | 1391 (while (and (< (point) end) |
1393 (setq state (parse-partial-sexp (point) end nil nil state | 1393 (setq state (parse-partial-sexp (point) end nil nil state |
1394 'syntax-table)) | 1394 'syntax-table)) |
1395 (or (nth 3 state) (nth 4 state)))) | 1395 (or (nth 3 state) (nth 4 state)))) |
1396 (setq string (nth 3 state) beg (nth 8 state)) | 1396 (setq string (nth 3 state) beg (nth 8 state)) |
1397 (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) | 1397 (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) |
1398 (put-text-property beg (point) 'face | 1398 (put-text-property beg (point) 'face |
1399 (if string | 1399 (if string |
1400 font-lock-string-face | 1400 font-lock-string-face |
1401 font-lock-comment-face))))) | 1401 font-lock-comment-face))))) |
1402 | 1402 |
1403 ;;; End of Syntactic fontification functions. | 1403 ;;; End of Syntactic fontification functions. |
1404 | 1404 |
1501 ;;; End of Keyword regexp fontification functions. | 1501 ;;; End of Keyword regexp fontification functions. |
1502 | 1502 |
1503 ;; Various functions. | 1503 ;; Various functions. |
1504 | 1504 |
1505 (defun font-lock-compile-keywords (keywords) | 1505 (defun font-lock-compile-keywords (keywords) |
1506 ;; Compile KEYWORDS into the form (t KEYWORD ...) where KEYWORD is of the | 1506 "Compile KEYWORDS into the form (t KEYWORD ...). |
1507 ;; form (MATCHER HIGHLIGHT ...) as shown in `font-lock-keywords' doc string. | 1507 Here KEYWORD is of the form (MATCHER HIGHLIGHT ...) as shown in the |
1508 `font-lock-keywords' doc string." | |
1508 (if (eq (car-safe keywords) t) | 1509 (if (eq (car-safe keywords) t) |
1509 keywords | 1510 keywords |
1510 (cons t (mapcar 'font-lock-compile-keyword keywords)))) | 1511 (cons t (mapcar 'font-lock-compile-keyword keywords)))) |
1511 | 1512 |
1512 (defun font-lock-compile-keyword (keyword) | 1513 (defun font-lock-compile-keyword (keyword) |
1527 (list (car keyword) (cdr keyword))) | 1528 (list (car keyword) (cdr keyword))) |
1528 (t ; (MATCHER HIGHLIGHT ...) | 1529 (t ; (MATCHER HIGHLIGHT ...) |
1529 keyword))) | 1530 keyword))) |
1530 | 1531 |
1531 (defun font-lock-eval-keywords (keywords) | 1532 (defun font-lock-eval-keywords (keywords) |
1532 ;; Evalulate KEYWORDS if a function (funcall) or variable (eval) name. | 1533 "Evalulate KEYWORDS if a function (funcall) or variable (eval) name." |
1533 (if (listp keywords) | 1534 (if (listp keywords) |
1534 keywords | 1535 keywords |
1535 (font-lock-eval-keywords (if (fboundp keywords) | 1536 (font-lock-eval-keywords (if (fboundp keywords) |
1536 (funcall keywords) | 1537 (funcall keywords) |
1537 (eval keywords))))) | 1538 (eval keywords))))) |
1538 | 1539 |
1539 (defun font-lock-value-in-major-mode (alist) | 1540 (defun font-lock-value-in-major-mode (alist) |
1540 ;; Return value in ALIST for `major-mode', or ALIST if it is not an alist. | 1541 "Return value in ALIST for `major-mode', or ALIST if it is not an alist. |
1541 ;; Structure is ((MAJOR-MODE . VALUE) ...) where MAJOR-MODE may be t. | 1542 Structure is ((MAJOR-MODE . VALUE) ...) where MAJOR-MODE may be t." |
1542 (if (consp alist) | 1543 (if (consp alist) |
1543 (cdr (or (assq major-mode alist) (assq t alist))) | 1544 (cdr (or (assq major-mode alist) (assq t alist))) |
1544 alist)) | 1545 alist)) |
1545 | 1546 |
1546 (defun font-lock-choose-keywords (keywords level) | 1547 (defun font-lock-choose-keywords (keywords level) |
1547 ;; Return LEVELth element of KEYWORDS. A LEVEL of nil is equal to a | 1548 "Return LEVELth element of KEYWORDS. |
1548 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)). | 1549 A LEVEL of nil is equal to a LEVEL of 0, a LEVEL of t is equal to |
1550 \(1- (length KEYWORDS))." | |
1549 (cond ((symbolp keywords) | 1551 (cond ((symbolp keywords) |
1550 keywords) | 1552 keywords) |
1551 ((numberp level) | 1553 ((numberp level) |
1552 (or (nth level keywords) (car (reverse keywords)))) | 1554 (or (nth level keywords) (car (reverse keywords)))) |
1553 ((eq level t) | 1555 ((eq level t) |
1614 (set variable nil)) | 1616 (set variable nil)) |
1615 (set (make-local-variable variable) value) | 1617 (set (make-local-variable variable) value) |
1616 (setq alist (cdr alist)))))))) | 1618 (setq alist (cdr alist)))))))) |
1617 | 1619 |
1618 (defun font-lock-unset-defaults () | 1620 (defun font-lock-unset-defaults () |
1619 "Unset fontification defaults. See `font-lock-set-defaults'." | 1621 "Unset fontification defaults. See function `font-lock-set-defaults'." |
1620 (setq font-lock-set-defaults nil | 1622 (setq font-lock-set-defaults nil |
1621 font-lock-keywords nil | 1623 font-lock-keywords nil |
1622 font-lock-keywords-only nil | 1624 font-lock-keywords-only nil |
1623 font-lock-keywords-case-fold-search nil | 1625 font-lock-keywords-case-fold-search nil |
1624 font-lock-syntax-table nil | 1626 font-lock-syntax-table nil |
1664 | 1666 |
1665 (defvar font-lock-warning-face 'font-lock-warning-face | 1667 (defvar font-lock-warning-face 'font-lock-warning-face |
1666 "Face name to use for things that should stand out.") | 1668 "Face name to use for things that should stand out.") |
1667 | 1669 |
1668 (defvar font-lock-reference-face 'font-lock-constant-face | 1670 (defvar font-lock-reference-face 'font-lock-constant-face |
1669 "This variable is obsolete. Use font-lock-constant-face.") | 1671 "This variable is obsolete. Use `font-lock-constant-face'.") |
1670 | 1672 |
1671 ;; Originally face attributes were specified via `font-lock-face-attributes'. | 1673 ;; Originally face attributes were specified via `font-lock-face-attributes'. |
1672 ;; Users then changed the default face attributes by setting that variable. | 1674 ;; Users then changed the default face attributes by setting that variable. |
1673 ;; However, we try and be back-compatible and respect its value if set except | 1675 ;; However, we try and be back-compatible and respect its value if set except |
1674 ;; for faces where M-x customize has been used to save changes for the face. | 1676 ;; for faces where M-x customize has been used to save changes for the face. |
2307 (regexp-opt '("enum" "struct" "union") t))) | 2309 (regexp-opt '("enum" "struct" "union") t))) |
2308 (c-type-specs-depth | 2310 (c-type-specs-depth |
2309 (regexp-opt-depth c-type-specs)) | 2311 (regexp-opt-depth c-type-specs)) |
2310 (c-type-names | 2312 (c-type-names |
2311 `(mapconcat 'identity | 2313 `(mapconcat 'identity |
2312 (cons | 2314 (cons |
2313 (,@ (eval-when-compile | 2315 (,@ (eval-when-compile |
2314 (regexp-opt | 2316 (regexp-opt |
2315 '("char" "short" "int" "long" "signed" "unsigned" | 2317 '("char" "short" "int" "long" "signed" "unsigned" |
2316 "float" "double" "void" "complex")))) | 2318 "float" "double" "void" "complex")))) |
2317 c-font-lock-extra-types) | 2319 c-font-lock-extra-types) |
2506 "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t))) | 2508 "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t))) |
2507 (c++-type-specs-depth | 2509 (c++-type-specs-depth |
2508 (regexp-opt-depth c++-type-specs)) | 2510 (regexp-opt-depth c++-type-specs)) |
2509 (c++-type-names | 2511 (c++-type-names |
2510 `(mapconcat 'identity | 2512 `(mapconcat 'identity |
2511 (cons | 2513 (cons |
2512 (,@ (eval-when-compile | 2514 (,@ (eval-when-compile |
2513 (regexp-opt | 2515 (regexp-opt |
2514 '("signed" "unsigned" "short" "long" | 2516 '("signed" "unsigned" "short" "long" |
2515 "int" "char" "float" "double" "void" | 2517 "int" "char" "float" "double" "void" |
2516 "bool" "complex")))) | 2518 "bool" "complex")))) |
2847 "interface" "return" "switch" "throw" "try" "while") t))) | 2849 "interface" "return" "switch" "throw" "try" "while") t))) |
2848 ;; | 2850 ;; |
2849 ;; Classes immediately followed by an object name. | 2851 ;; Classes immediately followed by an object name. |
2850 (java-type-names | 2852 (java-type-names |
2851 `(mapconcat 'identity | 2853 `(mapconcat 'identity |
2852 (cons | 2854 (cons |
2853 (,@ (eval-when-compile | 2855 (,@ (eval-when-compile |
2854 (regexp-opt '("boolean" "char" "byte" "short" "int" "long" | 2856 (regexp-opt '("boolean" "char" "byte" "short" "int" "long" |
2855 "float" "double" "void")))) | 2857 "float" "double" "void")))) |
2856 java-font-lock-extra-types) | 2858 java-font-lock-extra-types) |
2857 "\\|")) | 2859 "\\|")) |