Mercurial > hg > xemacs-beta
comparison lisp/font-lock.el @ 948:665fe33715d6
[xemacs-hg @ 2002-08-02 15:01:04 by scop]
2002-08-02 Ville Skyttä <ville.skytta@xemacs.org>
* font-lock.el: Some faces and doc typo fixes from GNU Emacs.
(font-lock-doc-face): New alias to font-lock-doc-string-face.
(font-lock-builtin-face): New.
(font-lock-constant-face): New.
(font-lock-face-list): Add builtin and constant faces.
Message-Id: <1028291844.2388.51.camel@bobcat.ods.org>
author | scop |
---|---|
date | Fri, 02 Aug 2002 15:01:10 +0000 |
parents | 79c6ff3eef26 |
children | 089f79dae3ab |
comparison
equal
deleted
inserted
replaced
947:5358ec398c43 | 948:665fe33715d6 |
---|---|
280 (radio :tag "Mode" | 280 (radio :tag "Mode" |
281 (const :tag "all" t) | 281 (const :tag "all" t) |
282 (symbol :tag "name")) | 282 (symbol :tag "name")) |
283 (radio :tag "Decoration" | 283 (radio :tag "Decoration" |
284 (const :tag "default" nil) | 284 (const :tag "default" nil) |
285 (const :tag "maximum" t) | 285 (const :tag "maximum" t) |
286 (integer :tag "level" 1))))) | 286 (integer :tag "level" 1))))) |
287 :group 'font-lock) | 287 :group 'font-lock) |
288 | 288 |
289 ;;;###autoload | 289 ;;;###autoload |
290 (define-obsolete-variable-alias 'font-lock-use-maximal-decoration | 290 (define-obsolete-variable-alias 'font-lock-use-maximal-decoration |
632 ;;; Initialization of faces. | 632 ;;; Initialization of faces. |
633 | 633 |
634 ;; #### barf gag retch. Horrid FSF lossage that we need to | 634 ;; #### barf gag retch. Horrid FSF lossage that we need to |
635 ;; keep around for compatibility with font-lock-keywords that | 635 ;; keep around for compatibility with font-lock-keywords that |
636 ;; forget to properly quote their faces. I tried just let-binding | 636 ;; forget to properly quote their faces. I tried just let-binding |
637 ;; them when we eval the face expression, but that failes because | 637 ;; them when we eval the face expression, but that fails because |
638 ;; some files actually use the variables directly in their init code | 638 ;; some files actually use the variables directly in their init code |
639 ;; without quoting them. --ben | 639 ;; without quoting them. --ben |
640 (defvar font-lock-comment-face 'font-lock-comment-face | 640 (defvar font-lock-comment-face 'font-lock-comment-face |
641 "This variable should not be set. | 641 "This variable should not be set. |
642 It is present only for horrid FSF compatibility reasons. | 642 It is present only for horrid FSF compatibility reasons. |
645 (defvar font-lock-doc-string-face 'font-lock-doc-string-face | 645 (defvar font-lock-doc-string-face 'font-lock-doc-string-face |
646 "This variable should not be set. | 646 "This variable should not be set. |
647 It is present only for horrid FSF compatibility reasons. | 647 It is present only for horrid FSF compatibility reasons. |
648 The corresponding face should be set using `edit-faces' or the | 648 The corresponding face should be set using `edit-faces' or the |
649 `set-face-*' functions.") | 649 `set-face-*' functions.") |
650 ;; GNU compatibility | |
651 (define-compatible-variable-alias | |
652 'font-lock-doc-face 'font-lock-doc-string-face) | |
650 (defvar font-lock-string-face 'font-lock-string-face | 653 (defvar font-lock-string-face 'font-lock-string-face |
651 "This variable should not be set. | 654 "This variable should not be set. |
652 It is present only for horrid FSF compatibility reasons. | 655 It is present only for horrid FSF compatibility reasons. |
653 The corresponding face should be set using `edit-faces' or the | 656 The corresponding face should be set using `edit-faces' or the |
654 `set-face-*' functions.") | 657 `set-face-*' functions.") |
655 (defvar font-lock-keyword-face 'font-lock-keyword-face | 658 (defvar font-lock-keyword-face 'font-lock-keyword-face |
659 "This variable should not be set. | |
660 It is present only for horrid FSF compatibility reasons. | |
661 The corresponding face should be set using `edit-faces' or the | |
662 `set-face-*' functions.") | |
663 (defvar font-lock-builtin-face 'font-lock-builtin-face | |
656 "This variable should not be set. | 664 "This variable should not be set. |
657 It is present only for horrid FSF compatibility reasons. | 665 It is present only for horrid FSF compatibility reasons. |
658 The corresponding face should be set using `edit-faces' or the | 666 The corresponding face should be set using `edit-faces' or the |
659 `set-face-*' functions.") | 667 `set-face-*' functions.") |
660 (defvar font-lock-function-name-face 'font-lock-function-name-face | 668 (defvar font-lock-function-name-face 'font-lock-function-name-face |
670 (defvar font-lock-type-face 'font-lock-type-face | 678 (defvar font-lock-type-face 'font-lock-type-face |
671 "This variable should not be set. | 679 "This variable should not be set. |
672 It is present only for horrid FSF compatibility reasons. | 680 It is present only for horrid FSF compatibility reasons. |
673 The corresponding face should be set using `edit-faces' or the | 681 The corresponding face should be set using `edit-faces' or the |
674 `set-face-*' functions.") | 682 `set-face-*' functions.") |
683 (defvar font-lock-constant-face 'font-lock-constant-face | |
684 "This variable should not be set. | |
685 It is present only for horrid FSF compatibility reasons. | |
686 The corresponding face should be set using `edit-faces' or the | |
687 `set-face-*' functions.") | |
675 (defvar font-lock-reference-face 'font-lock-reference-face | 688 (defvar font-lock-reference-face 'font-lock-reference-face |
676 "This variable should not be set. | 689 "This variable should not be set. |
677 It is present only for horrid FSF compatibility reasons. | 690 It is present only for horrid FSF compatibility reasons. |
678 The corresponding face should be set using `edit-faces' or the | 691 The corresponding face should be set using `edit-faces' or the |
679 `set-face-*' functions.") | 692 `set-face-*' functions.") |
686 (defconst font-lock-face-list | 699 (defconst font-lock-face-list |
687 '(font-lock-comment-face | 700 '(font-lock-comment-face |
688 font-lock-string-face | 701 font-lock-string-face |
689 font-lock-doc-string-face | 702 font-lock-doc-string-face |
690 font-lock-keyword-face | 703 font-lock-keyword-face |
704 font-lock-builtin-face | |
691 font-lock-function-name-face | 705 font-lock-function-name-face |
692 font-lock-variable-name-face | 706 font-lock-variable-name-face |
693 font-lock-type-face | 707 font-lock-type-face |
708 font-lock-constant-face | |
694 font-lock-reference-face | 709 font-lock-reference-face |
695 font-lock-preprocessor-face | 710 font-lock-preprocessor-face |
696 font-lock-warning-face)) | 711 font-lock-warning-face)) |
697 | 712 |
698 (defface font-lock-comment-face | 713 (defface font-lock-comment-face |
737 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | 752 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) |
738 (t (:bold t))) | 753 (t (:bold t))) |
739 "Font Lock mode face used to highlight keywords." | 754 "Font Lock mode face used to highlight keywords." |
740 :group 'font-lock-faces) | 755 :group 'font-lock-faces) |
741 | 756 |
757 (defface font-lock-builtin-face | |
758 '((((class color) (background light)) (:foreground "Purple")) | |
759 (((class color) (background dark)) (:foreground "Cyan")) | |
760 (((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | |
761 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | |
762 (t (:bold t))) | |
763 "Font Lock mode face used to highlight builtins." | |
764 :group 'font-lock-faces) | |
765 | |
742 (defface font-lock-function-name-face | 766 (defface font-lock-function-name-face |
743 '((((class color) (background dark)) (:foreground "aquamarine")) | 767 '((((class color) (background dark)) (:foreground "aquamarine")) |
744 ;; brown4 is hardly different from black on windows. | 768 ;; brown4 is hardly different from black on windows. |
745 ;; I changed it to red because IMO it's pointless and ugly to | 769 ;; I changed it to red because IMO it's pointless and ugly to |
746 ;; use a million slightly different colors for niggly syntactic | 770 ;; use a million slightly different colors for niggly syntactic |
769 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | 793 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) |
770 (t (:bold t))) | 794 (t (:bold t))) |
771 "Font Lock mode face used to highlight types." | 795 "Font Lock mode face used to highlight types." |
772 :group 'font-lock-faces) | 796 :group 'font-lock-faces) |
773 | 797 |
798 (defface font-lock-constant-face | |
799 '((((class color) (background light)) (:foreground "CadetBlue")) | |
800 (((class color) (background dark)) (:foreground "Aquamarine")) | |
801 (((class grayscale) (background light)) | |
802 (:foreground "LightGray" :bold t :underline t)) | |
803 (((class grayscale) (background dark)) | |
804 (:foreground "Gray50" :bold t :underline t)) | |
805 (t (:bold t :underline t))) | |
806 "Font Lock mode face used to highlight constants and labels." | |
807 :group 'font-lock-faces) | |
808 | |
774 (defface font-lock-reference-face | 809 (defface font-lock-reference-face |
775 '((((class color) (background dark)) (:foreground "cadetblue2")) | 810 '((((class color) (background dark)) (:foreground "cadetblue2")) |
776 (((class color) (background light)) (:foreground "red3")) | 811 (((class color) (background light)) (:foreground "red3")) |
777 (((class grayscale) (background light)) | 812 (((class grayscale) (background light)) |
778 (:foreground "LightGray" :bold t :underline t)) | 813 (:foreground "LightGray" :bold t :underline t)) |
779 (((class grayscale) (background dark)) | 814 (((class grayscale) (background dark)) |
780 (:foreground "Gray50" :bold t :underline t))) | 815 (:foreground "Gray50" :bold t :underline t))) |
781 "Font Lock mode face used to highlight references." | 816 "Font Lock mode face used to highlight references." |
782 :group 'font-lock-faces) | 817 :group 'font-lock-faces) |
783 | 818 |
784 ;; #### FSF has font-lock-builtin-face. | |
785 | |
786 (defface font-lock-preprocessor-face | 819 (defface font-lock-preprocessor-face |
787 '((((class color) (background dark)) (:foreground "steelblue1")) | 820 '((((class color) (background dark)) (:foreground "steelblue1")) |
788 (((class color) (background light)) (:foreground "blue3")) | 821 (((class color) (background light)) (:foreground "blue3")) |
789 (t (:underline t))) | 822 (t (:underline t))) |
790 "Font Lock Mode face used to highlight preprocessor conditionals." | 823 "Font Lock Mode face used to highlight preprocessor conditionals." |
791 :group 'font-lock-faces) | 824 :group 'font-lock-faces) |
792 | 825 |
793 ;; #### Currently unused | |
794 (defface font-lock-warning-face | 826 (defface font-lock-warning-face |
795 '((((class color) (background light)) (:foreground "Red" :bold t)) | 827 '((((class color) (background light)) (:foreground "Red" :bold t)) |
796 (((class color) (background dark)) (:foreground "Pink" :bold t)) | 828 (((class color) (background dark)) (:foreground "Pink" :bold t)) |
797 (t (:inverse-video t :bold t))) | 829 (t (:inverse-video t :bold t))) |
798 "Font Lock mode face used to highlight warnings." | 830 "Font Lock mode face used to highlight warnings." |
1455 ;; makes no sense for `syntax-table' property values, (e) they do not do it | 1487 ;; makes no sense for `syntax-table' property values, (e) they do not do it |
1456 ;; LOUDLY as it is not likely to be intensive. | 1488 ;; LOUDLY as it is not likely to be intensive. |
1457 | 1489 |
1458 (defun font-lock-apply-syntactic-highlight (highlight) | 1490 (defun font-lock-apply-syntactic-highlight (highlight) |
1459 "Apply HIGHLIGHT following a match. | 1491 "Apply HIGHLIGHT following a match. |
1460 HIGHLIGHT should be of the form MATCH-HIGHLIGHT, | 1492 HIGHLIGHT should be of the form MATCH-HIGHLIGHT, |
1461 see `font-lock-syntactic-keywords'." | 1493 see `font-lock-syntactic-keywords'." |
1462 (let* ((match (nth 0 highlight)) | 1494 (let* ((match (nth 0 highlight)) |
1463 (start (match-beginning match)) (end (match-end match)) | 1495 (start (match-beginning match)) (end (match-end match)) |
1464 (value (nth 1 highlight)) | 1496 (value (nth 1 highlight)) |
1465 (override (nth 2 highlight))) | 1497 (override (nth 2 highlight))) |
1466 (unless (numberp (car-safe value)) | 1498 (unless (numberp (car-safe value)) |
1534 (while highlights | 1566 (while highlights |
1535 (if (numberp (car (car highlights))) | 1567 (if (numberp (car (car highlights))) |
1536 (font-lock-apply-syntactic-highlight (car highlights)) | 1568 (font-lock-apply-syntactic-highlight (car highlights)) |
1537 (font-lock-fontify-syntactic-anchored-keywords (car highlights) | 1569 (font-lock-fontify-syntactic-anchored-keywords (car highlights) |
1538 end)) | 1570 end)) |
1539 (setq highlights (cdr highlights))) | 1571 (setq highlights (cdr highlights)))) |
1540 ) | |
1541 (setq keywords (cdr keywords))))) | 1572 (setq keywords (cdr keywords))))) |
1542 | 1573 |
1543 ;;; Regexp fontification functions. | 1574 ;;; Regexp fontification functions. |
1544 | 1575 |
1545 (defsubst font-lock-apply-highlight (highlight) | 1576 (defsubst font-lock-apply-highlight (highlight) |
1681 | 1712 |
1682 | 1713 |
1683 ;; Various functions. | 1714 ;; Various functions. |
1684 | 1715 |
1685 (defun font-lock-compile-keywords (keywords) | 1716 (defun font-lock-compile-keywords (keywords) |
1686 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD | 1717 "Compile KEYWORDS into the form (t KEYWORD ...). |
1687 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. | 1718 Here KEYWORD is of the form (MATCHER HIGHLIGHT ...) as shown in the |
1719 `font-lock-keywords' doc string." | |
1688 (if (eq (car-safe keywords) t) | 1720 (if (eq (car-safe keywords) t) |
1689 keywords | 1721 keywords |
1690 (cons t (mapcar 'font-lock-compile-keyword keywords)))) | 1722 (cons t (mapcar 'font-lock-compile-keyword keywords)))) |
1691 | 1723 |
1692 (defun font-lock-compile-keyword (keyword) | 1724 (defun font-lock-compile-keyword (keyword) |
1702 (list (car keyword) (cdr keyword))) | 1734 (list (car keyword) (cdr keyword))) |
1703 (t ; Hopefully (MATCHER HIGHLIGHT ...) | 1735 (t ; Hopefully (MATCHER HIGHLIGHT ...) |
1704 keyword))) | 1736 keyword))) |
1705 | 1737 |
1706 (defun font-lock-eval-keywords (keywords) | 1738 (defun font-lock-eval-keywords (keywords) |
1707 ;; Evalulate KEYWORDS if a function (funcall) or variable (eval) name. | 1739 "Evaluate KEYWORDS if a function (funcall) or variable (eval) name." |
1708 (if (listp keywords) | 1740 (if (listp keywords) |
1709 keywords | 1741 keywords |
1710 (font-lock-eval-keywords (if (fboundp keywords) | 1742 (font-lock-eval-keywords (if (fboundp keywords) |
1711 (funcall keywords) | 1743 (funcall keywords) |
1712 (eval keywords))))) | 1744 (eval keywords))))) |