Mercurial > emacs
comparison lisp/textmodes/rst.el @ 107445:4f21cfcfbb42
Use faces not variables for font-lock customization in rst.el.
* textmodes/rst.el: (rst-block, rst-external, rst-definition, rst-directive)
(rst-comment, rst-emphasis1, rst-emphasis2, rst-literal, rst-reference):
New faces.
(rst-block-face, rst-external-face, rst-definition-face)
(rst-directive-face, rst-comment-face, rst-emphasis1-face)
(rst-emphasis2-face, rst-literal-face, rst-reference-face):
Make obsolete.
(rst-font-lock-keywords-function): Update for above changes.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 20 Mar 2010 11:17:59 -0700 |
parents | 1d1d5d9bd884 |
children | d835100c3e8b |
comparison
equal
deleted
inserted
replaced
107444:db38deea3cef | 107445:4f21cfcfbb42 |
---|---|
2583 (defgroup rst-faces nil "Faces used in Rst Mode." | 2583 (defgroup rst-faces nil "Faces used in Rst Mode." |
2584 :group 'rst | 2584 :group 'rst |
2585 :group 'faces | 2585 :group 'faces |
2586 :version "21.1") | 2586 :version "21.1") |
2587 | 2587 |
2588 (defcustom rst-block-face 'font-lock-keyword-face | 2588 (defface rst-block '((t :inherit font-lock-keyword-face)) |
2589 "Face used for all syntax marking up a special block." | |
2590 :version "24.1" | |
2591 :group 'rst-faces) | |
2592 | |
2593 (defcustom rst-block-face 'rst-block | |
2589 "All syntax marking up a special block." | 2594 "All syntax marking up a special block." |
2595 :version "24.1" | |
2590 :group 'rst-faces | 2596 :group 'rst-faces |
2591 :type '(face)) | 2597 :type '(face)) |
2592 | 2598 (make-obsolete-variable 'rst-block-face |
2593 (defcustom rst-external-face 'font-lock-type-face | 2599 "customize the face `rst-block' instead." |
2600 "24.1") | |
2601 | |
2602 (defface rst-external '((t :inherit font-lock-type-face)) | |
2603 "Face used for field names and interpreted text." | |
2604 :version "24.1" | |
2605 :group 'rst-faces) | |
2606 | |
2607 (defcustom rst-external-face 'rst-external | |
2594 "Field names and interpreted text." | 2608 "Field names and interpreted text." |
2609 :version "24.1" | |
2595 :group 'rst-faces | 2610 :group 'rst-faces |
2596 :type '(face)) | 2611 :type '(face)) |
2597 | 2612 (make-obsolete-variable 'rst-external-face |
2598 (defcustom rst-definition-face 'font-lock-function-name-face | 2613 "customize the face `rst-external' instead." |
2614 "24.1") | |
2615 | |
2616 (defface rst-definition '((t :inherit font-lock-function-name-face)) | |
2617 "Face used for all other defining constructs." | |
2618 :version "24.1" | |
2619 :group 'rst-faces) | |
2620 | |
2621 (defcustom rst-definition-face 'rst-definition | |
2599 "All other defining constructs." | 2622 "All other defining constructs." |
2623 :version "24.1" | |
2600 :group 'rst-faces | 2624 :group 'rst-faces |
2601 :type '(face)) | 2625 :type '(face)) |
2602 | 2626 (make-obsolete-variable 'rst-definition-face |
2603 (defcustom rst-directive-face | 2627 "customize the face `rst-definition' instead." |
2604 ;; XEmacs compatibility | 2628 "24.1") |
2605 (if (boundp 'font-lock-builtin-face) | 2629 |
2606 'font-lock-builtin-face | 2630 ;; XEmacs compatibility (?). |
2607 'font-lock-preprocessor-face) | 2631 (defface rst-directive (if (boundp 'font-lock-builtin-face) |
2632 '((t :inherit font-lock-builtin-face)) | |
2633 '((t :inherit font-lock-preprocessor-face))) | |
2634 "Face used for directives and roles." | |
2635 :version "24.1" | |
2636 :group 'rst-faces) | |
2637 | |
2638 (defcustom rst-directive-face 'rst-directive | |
2608 "Directives and roles." | 2639 "Directives and roles." |
2609 :group 'rst-faces | 2640 :group 'rst-faces |
2610 :type '(face)) | 2641 :type '(face)) |
2611 | 2642 (make-obsolete-variable 'rst-directive-face |
2612 (defcustom rst-comment-face 'font-lock-comment-face | 2643 "customize the face `rst-directive' instead." |
2644 "24.1") | |
2645 | |
2646 (defface rst-comment '((t :inherit font-lock-comment-face)) | |
2647 "Face used for comments." | |
2648 :version "24.1" | |
2649 :group 'rst-faces) | |
2650 | |
2651 (defcustom rst-comment-face 'rst-comment | |
2613 "Comments." | 2652 "Comments." |
2653 :version "24.1" | |
2614 :group 'rst-faces | 2654 :group 'rst-faces |
2615 :type '(face)) | 2655 :type '(face)) |
2616 | 2656 (make-obsolete-variable 'rst-comment-face |
2617 (defcustom rst-emphasis1-face | 2657 "customize the face `rst-comment' instead." |
2618 ;; XEmacs compatibility | 2658 "24.1") |
2619 (if (facep 'italic) | 2659 |
2620 ''italic | 2660 (defface rst-emphasis1 '((t :inherit italic)) |
2621 'italic) | 2661 "Face used for simple emphasis." |
2662 :version "24.1" | |
2663 :group 'rst-faces) | |
2664 | |
2665 (defcustom rst-emphasis1-face 'rst-emphasis1 | |
2622 "Simple emphasis." | 2666 "Simple emphasis." |
2667 :version "24.1" | |
2623 :group 'rst-faces | 2668 :group 'rst-faces |
2624 :type '(face)) | 2669 :type '(face)) |
2625 | 2670 (make-obsolete-variable 'rst-emphasis1-face |
2626 (defcustom rst-emphasis2-face | 2671 "customize the face `rst-emphasis1' instead." |
2627 ;; XEmacs compatibility | 2672 "24.1") |
2628 (if (facep 'bold) | 2673 |
2629 ''bold | 2674 (defface rst-emphasis2 '((t :inherit bold)) |
2630 'bold) | 2675 "Face used for double emphasis." |
2676 :version "24.1" | |
2677 :group 'rst-faces) | |
2678 | |
2679 (defcustom rst-emphasis2-face 'rst-emphasis2 | |
2631 "Double emphasis." | 2680 "Double emphasis." |
2632 :group 'rst-faces | 2681 :group 'rst-faces |
2633 :type '(face)) | 2682 :type '(face)) |
2634 | 2683 (make-obsolete-variable 'rst-emphasis2-face |
2635 (defcustom rst-literal-face 'font-lock-string-face | 2684 "customize the face `rst-emphasis2' instead." |
2685 "24.1") | |
2686 | |
2687 (defface rst-literal '((t :inherit font-lock-string-face)) | |
2688 "Face used for literal text." | |
2689 :version "24.1" | |
2690 :group 'rst-faces) | |
2691 | |
2692 (defcustom rst-literal-face 'rst-literal | |
2636 "Literal text." | 2693 "Literal text." |
2694 :version "24.1" | |
2637 :group 'rst-faces | 2695 :group 'rst-faces |
2638 :type '(face)) | 2696 :type '(face)) |
2639 | 2697 (make-obsolete-variable 'rst-literal-face |
2640 (defcustom rst-reference-face 'font-lock-variable-name-face | 2698 "customize the face `rst-literal' instead." |
2699 "24.1") | |
2700 | |
2701 (defface rst-reference '((t :inherit font-lock-variable-name-face)) | |
2702 "Face used for references to a definition." | |
2703 :version "24.1" | |
2704 :group 'rst-faces) | |
2705 | |
2706 (defcustom rst-reference-face 'rst-reference | |
2641 "References to a definition." | 2707 "References to a definition." |
2708 :version "24.1" | |
2642 :group 'rst-faces | 2709 :group 'rst-faces |
2643 :type '(face)) | 2710 :type '(face)) |
2711 (make-obsolete-variable 'rst-reference-face | |
2712 "customize the face `rst-reference' instead." | |
2713 "24.1") | |
2644 | 2714 |
2645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2715 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2646 | 2716 |
2647 (defgroup rst-faces-defaults nil | 2717 (defgroup rst-faces-defaults nil |
2648 "Values used to generate default faces for section titles on all levels. | 2718 "Values used to generate default faces for section titles on all levels. |
2816 ;; FIXME: Block markup is not recognized in blocks after explicit markup | 2886 ;; FIXME: Block markup is not recognized in blocks after explicit markup |
2817 ;; start | 2887 ;; start |
2818 | 2888 |
2819 ;; Simple `Body Elements`_ | 2889 ;; Simple `Body Elements`_ |
2820 ;; `Bullet Lists`_ | 2890 ;; `Bullet Lists`_ |
2821 (list | 2891 `(,(concat re-bol "\\([-*+]" re-blksep1 "\\)") |
2822 (concat re-bol "\\([-*+]" re-blksep1 "\\)") | 2892 1 rst-block-face) |
2823 1 rst-block-face) | |
2824 ;; `Enumerated Lists`_ | 2893 ;; `Enumerated Lists`_ |
2825 (list | 2894 `(,(concat re-bol "\\((?\\(#\\|[0-9]+\\|[A-Za-z]\\|[IVXLCMivxlcm]+\\)[.)]" |
2826 (concat re-bol "\\((?\\(#\\|[0-9]+\\|[A-Za-z]\\|[IVXLCMivxlcm]+\\)[.)]" | 2895 re-blksep1 "\\)") |
2827 re-blksep1 "\\)") | 2896 1 rst-block-face) |
2828 1 rst-block-face) | |
2829 ;; `Definition Lists`_ FIXME: missing | 2897 ;; `Definition Lists`_ FIXME: missing |
2830 ;; `Field Lists`_ | 2898 ;; `Field Lists`_ |
2831 (list | 2899 `(,(concat re-bol "\\(:[^:\n]+:\\)" re-blksep1) |
2832 (concat re-bol "\\(:[^:\n]+:\\)" re-blksep1) | 2900 1 rst-external-face) |
2833 1 rst-external-face) | |
2834 ;; `Option Lists`_ | 2901 ;; `Option Lists`_ |
2835 (list | 2902 `(,(concat re-bol "\\(\\(\\(\\([-+/]\\|--\\)\\sw\\(-\\|\\sw\\)*" |
2836 (concat re-bol "\\(\\(\\(\\([-+/]\\|--\\)\\sw\\(-\\|\\sw\\)*" | 2903 "\\([ =]\\S +\\)?\\)\\(,[\t ]\\)?\\)+\\)\\($\\|[\t ]\\{2\\}\\)") |
2837 "\\([ =]\\S +\\)?\\)\\(,[\t ]\\)?\\)+\\)\\($\\|[\t ]\\{2\\}\\)") | 2904 1 rst-block-face) |
2838 1 rst-block-face) | |
2839 | 2905 |
2840 ;; `Tables`_ FIXME: missing | 2906 ;; `Tables`_ FIXME: missing |
2841 | 2907 |
2842 ;; All the `Explicit Markup Blocks`_ | 2908 ;; All the `Explicit Markup Blocks`_ |
2843 ;; `Footnotes`_ / `Citations`_ | 2909 ;; `Footnotes`_ / `Citations`_ |
2844 (list | 2910 `(,(concat re-bol "\\(" re-ems "\\[[^[\n]+\\]\\)" re-blksep1) |
2845 (concat re-bol "\\(" re-ems "\\[[^[\n]+\\]\\)" re-blksep1) | |
2846 1 rst-definition-face) | 2911 1 rst-definition-face) |
2847 ;; `Directives`_ / `Substitution Definitions`_ | 2912 ;; `Directives`_ / `Substitution Definitions`_ |
2848 (list | 2913 `(,(concat re-bol "\\(" re-ems "\\)\\(\\(|[^|\n]+|[\t ]+\\)?\\)\\(" |
2849 (concat re-bol "\\(" re-ems "\\)\\(\\(|[^|\n]+|[\t ]+\\)?\\)\\(" | 2914 re-sym1 "+::\\)" re-blksep1) |
2850 re-sym1 "+::\\)" re-blksep1) | 2915 (1 rst-directive-face) |
2851 (list 1 rst-directive-face) | 2916 (2 rst-definition-face) |
2852 (list 2 rst-definition-face) | 2917 (4 rst-directive-face)) |
2853 (list 4 rst-directive-face)) | |
2854 ;; `Hyperlink Targets`_ | 2918 ;; `Hyperlink Targets`_ |
2855 (list | 2919 `(,(concat re-bol "\\(" re-ems "_\\([^:\\`\n]\\|\\\\.\\|`[^`\n]+`\\)+:\\)" |
2856 (concat re-bol "\\(" re-ems "_\\([^:\\`\n]\\|\\\\.\\|`[^`\n]+`\\)+:\\)" | 2920 re-blksep1) |
2857 re-blksep1) | 2921 1 rst-definition-face) |
2858 1 rst-definition-face) | 2922 `(,(concat re-bol "\\(__\\)" re-blksep1) |
2859 (list | 2923 1 rst-definition-face) |
2860 (concat re-bol "\\(__\\)" re-blksep1) | |
2861 1 rst-definition-face) | |
2862 | 2924 |
2863 ;; All `Inline Markup`_ | 2925 ;; All `Inline Markup`_ |
2864 ;; FIXME: Condition 5 preventing fontification of e.g. "*" not implemented | 2926 ;; FIXME: Condition 5 preventing fontification of e.g. "*" not implemented |
2865 ;; `Strong Emphasis`_ | 2927 ;; `Strong Emphasis`_ |
2866 (list | 2928 `(,(concat re-imp1 "\\(\\*\\*" re-ima2 "\\*\\*\\)" re-ims1) |
2867 (concat re-imp1 "\\(\\*\\*" re-ima2 "\\*\\*\\)" re-ims1) | 2929 2 rst-emphasis2-face) |
2868 2 rst-emphasis2-face) | |
2869 ;; `Emphasis`_ | 2930 ;; `Emphasis`_ |
2870 (list | 2931 `(,(concat re-imp1 "\\(\\*" re-ima2 "\\*\\)" re-ims1) |
2871 (concat re-imp1 "\\(\\*" re-ima2 "\\*\\)" re-ims1) | 2932 2 rst-emphasis1-face) |
2872 2 rst-emphasis1-face) | |
2873 ;; `Inline Literals`_ | 2933 ;; `Inline Literals`_ |
2874 (list | 2934 `(,(concat re-imp1 "\\(``" re-imb2 "``\\)" re-ims1) |
2875 (concat re-imp1 "\\(``" re-imb2 "``\\)" re-ims1) | 2935 2 rst-literal-face) |
2876 2 rst-literal-face) | |
2877 ;; `Inline Internal Targets`_ | 2936 ;; `Inline Internal Targets`_ |
2878 (list | 2937 `(,(concat re-imp1 "\\(_`" re-imb2 "`\\)" re-ims1) |
2879 (concat re-imp1 "\\(_`" re-imb2 "`\\)" re-ims1) | 2938 2 rst-definition-face) |
2880 2 rst-definition-face) | |
2881 ;; `Hyperlink References`_ | 2939 ;; `Hyperlink References`_ |
2882 ;; FIXME: `Embedded URIs`_ not considered | 2940 ;; FIXME: `Embedded URIs`_ not considered |
2883 (list | 2941 `(,(concat re-imp1 "\\(\\(`" re-imb2 "`\\|\\(\\sw\\(\\sw\\|-\\)+\\sw\\)\\)__?\\)" re-ims1) |
2884 (concat re-imp1 "\\(\\(`" re-imb2 "`\\|\\(\\sw\\(\\sw\\|-\\)+\\sw\\)\\)__?\\)" re-ims1) | |
2885 2 rst-reference-face) | 2942 2 rst-reference-face) |
2886 ;; `Interpreted Text`_ | 2943 ;; `Interpreted Text`_ |
2887 (list | 2944 `(,(concat re-imp1 "\\(\\(:" re-sym1 "+:\\)?\\)\\(`" re-imb2 "`\\)\\(\\(:" |
2888 (concat re-imp1 "\\(\\(:" re-sym1 "+:\\)?\\)\\(`" re-imb2 "`\\)\\(\\(:" | 2945 re-sym1 "+:\\)?\\)" re-ims1) |
2889 re-sym1 "+:\\)?\\)" re-ims1) | 2946 (2 rst-directive-face) |
2890 (list 2 rst-directive-face) | 2947 (5 rst-external-face) |
2891 (list 5 rst-external-face) | 2948 (8 rst-directive-face)) |
2892 (list 8 rst-directive-face)) | |
2893 ;; `Footnote References`_ / `Citation References`_ | 2949 ;; `Footnote References`_ / `Citation References`_ |
2894 (list | 2950 `(,(concat re-imp1 "\\(\\[[^]]+\\]_\\)" re-ims1) |
2895 (concat re-imp1 "\\(\\[[^]]+\\]_\\)" re-ims1) | 2951 2 rst-reference-face) |
2896 2 rst-reference-face) | |
2897 ;; `Substitution References`_ | 2952 ;; `Substitution References`_ |
2898 (list | 2953 `(,(concat re-imp1 "\\(|" re-imv2 "|\\)" re-ims1) |
2899 (concat re-imp1 "\\(|" re-imv2 "|\\)" re-ims1) | 2954 2 rst-reference-face) |
2900 2 rst-reference-face) | |
2901 ;; `Standalone Hyperlinks`_ | 2955 ;; `Standalone Hyperlinks`_ |
2902 (list | 2956 `(;; FIXME: This takes it easy by using a whitespace as delimiter |
2903 ;; FIXME: This takes it easy by using a whitespace as delimiter | 2957 ,(concat re-imp1 "\\(" re-uris1 ":\\S +\\)" re-ims1) |
2904 (concat re-imp1 "\\(" re-uris1 ":\\S +\\)" re-ims1) | 2958 2 rst-definition-face) |
2905 2 rst-definition-face) | 2959 `(,(concat re-imp1 "\\(" re-sym1 "+@" re-sym1 "+\\)" re-ims1) |
2906 (list | 2960 2 rst-definition-face) |
2907 (concat re-imp1 "\\(" re-sym1 "+@" re-sym1 "+\\)" re-ims1) | |
2908 2 rst-definition-face) | |
2909 | 2961 |
2910 ;; Do all block fontification as late as possible so 'append works | 2962 ;; Do all block fontification as late as possible so 'append works |
2911 | 2963 |
2912 ;; Sections_ / Transitions_ | 2964 ;; Sections_ / Transitions_ |
2913 (append | 2965 (append |
2914 (list | 2966 (list |
2915 re-ado2) | 2967 re-ado2) |
2916 (if (not rst-mode-lazy) | 2968 (if (not rst-mode-lazy) |
2917 (list 1 rst-block-face) | 2969 '(1 rst-block-face) |
2918 (list | 2970 (list |
2919 (list 'rst-font-lock-handle-adornment | 2971 (list 'rst-font-lock-handle-adornment |
2920 '(progn | 2972 '(progn |
2921 (setq rst-font-lock-adornment-point (match-end 1)) | 2973 (setq rst-font-lock-adornment-point (match-end 1)) |
2922 (point-max)) | 2974 (point-max)) |
2932 ;; `Comments`_ | 2984 ;; `Comments`_ |
2933 (append | 2985 (append |
2934 (list | 2986 (list |
2935 (concat re-bol "\\(" re-ems "\\)\[^[|_]\\([^:\n]\\|:\\([^:\n]\\|$\\)\\)*$") | 2987 (concat re-bol "\\(" re-ems "\\)\[^[|_]\\([^:\n]\\|:\\([^:\n]\\|$\\)\\)*$") |
2936 | 2988 |
2937 (list 1 rst-comment-face)) | 2989 '(1 rst-comment-face)) |
2938 (if rst-mode-lazy | 2990 (if rst-mode-lazy |
2939 (list | 2991 (list |
2940 (list 'rst-font-lock-find-unindented-line | 2992 (list 'rst-font-lock-find-unindented-line |
2941 '(progn | 2993 '(progn |
2942 (setq rst-font-lock-indentation-point (match-end 1)) | 2994 (setq rst-font-lock-indentation-point (match-end 1)) |
2943 (point-max)) | 2995 (point-max)) |
2944 nil | 2996 nil |
2945 (list 0 rst-comment-face 'append))))) | 2997 '(0 rst-comment-face append))))) |
2946 (append | 2998 (append |
2947 (list | 2999 (list |
2948 (concat re-bol "\\(" re-emt "\\)\\(\\s *\\)$") | 3000 (concat re-bol "\\(" re-emt "\\)\\(\\s *\\)$") |
2949 (list 1 rst-comment-face) | 3001 '(1 rst-comment-face) |
2950 (list 2 rst-comment-face)) | 3002 '(2 rst-comment-face)) |
2951 (if rst-mode-lazy | 3003 (if rst-mode-lazy |
2952 (list | 3004 (list |
2953 (list 'rst-font-lock-find-unindented-line | 3005 (list 'rst-font-lock-find-unindented-line |
2954 '(progn | 3006 '(progn |
2955 (setq rst-font-lock-indentation-point 'next) | 3007 (setq rst-font-lock-indentation-point 'next) |
2956 (point-max)) | 3008 (point-max)) |
2957 nil | 3009 nil |
2958 (list 0 rst-comment-face 'append))))) | 3010 '(0 rst-comment-face append))))) |
2959 | 3011 |
2960 ;; `Literal Blocks`_ | 3012 ;; `Literal Blocks`_ |
2961 (append | 3013 (append |
2962 (list | 3014 (list |
2963 (concat re-bol "\\(\\([^.\n]\\|\\.[^.\n]\\).*\\)?\\(::\\)$") | 3015 (concat re-bol "\\(\\([^.\n]\\|\\.[^.\n]\\).*\\)?\\(::\\)$") |
2964 (list 3 rst-block-face)) | 3016 '(3 rst-block-face)) |
2965 (if rst-mode-lazy | 3017 (if rst-mode-lazy |
2966 (list | 3018 (list |
2967 (list 'rst-font-lock-find-unindented-line | 3019 (list 'rst-font-lock-find-unindented-line |
2968 '(progn | 3020 '(progn |
2969 (setq rst-font-lock-indentation-point t) | 3021 (setq rst-font-lock-indentation-point t) |
2970 (point-max)) | 3022 (point-max)) |
2971 nil | 3023 nil |
2972 (list 0 rst-literal-face 'append))))) | 3024 '(0 rst-literal-face append))))) |
2973 | 3025 |
2974 ;; `Doctest Blocks`_ | 3026 ;; `Doctest Blocks`_ |
2975 (append | 3027 (append |
2976 (list | 3028 (list |
2977 (concat re-bol "\\(>>>\\|\\.\\.\\.\\)\\(.+\\)") | 3029 (concat re-bol "\\(>>>\\|\\.\\.\\.\\)\\(.+\\)") |
2978 (list 1 rst-block-face) | 3030 '(1 rst-block-face) |
2979 (list 2 rst-literal-face))) | 3031 '(2 rst-literal-face))) |
2980 ))) | 3032 ))) |
2981 | 3033 |
2982 | 3034 |
2983 | 3035 |
2984 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 3036 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |