Mercurial > emacs
comparison lisp/woman.el @ 63199:6d9a2cf91f62
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 10 Jun 2005 08:07:29 +0000 |
parents | 31aa9a390538 |
children | 5b60124f1c0a |
comparison
equal
deleted
inserted
replaced
63198:f855a20b356c | 63199:6d9a2cf91f62 |
---|---|
873 :group 'woman-faces) | 873 :group 'woman-faces) |
874 | 874 |
875 ;; This is overkill! Troff uses just italic; Nroff uses just underline. | 875 ;; This is overkill! Troff uses just italic; Nroff uses just underline. |
876 ;; You should probably select either italic or underline as you prefer, but | 876 ;; You should probably select either italic or underline as you prefer, but |
877 ;; not both, although italic and underline work together perfectly well! | 877 ;; not both, although italic and underline work together perfectly well! |
878 (defface woman-italic-face | 878 (defface woman-italic |
879 `((((min-colors 88) (background light)) | 879 `((((min-colors 88) (background light)) |
880 (:slant italic :underline t :foreground "red1")) | 880 (:slant italic :underline t :foreground "red1")) |
881 (((background light)) (:slant italic :underline t :foreground "red")) | 881 (((background light)) (:slant italic :underline t :foreground "red")) |
882 (((background dark)) (:slant italic :underline t))) | 882 (((background dark)) (:slant italic :underline t))) |
883 "Face for italic font in man pages." | 883 "Face for italic font in man pages." |
884 :group 'woman-faces) | 884 :group 'woman-faces) |
885 | 885 ;; backward-compatibility alias |
886 (defface woman-bold-face | 886 (put 'woman-italic-face 'face-alias 'woman-italic) |
887 | |
888 (defface woman-bold | |
887 '((((min-colors 88) (background light)) (:weight bold :foreground "blue1")) | 889 '((((min-colors 88) (background light)) (:weight bold :foreground "blue1")) |
888 (((background light)) (:weight bold :foreground "blue")) | 890 (((background light)) (:weight bold :foreground "blue")) |
889 (((background dark)) (:weight bold :foreground "green2"))) | 891 (((background dark)) (:weight bold :foreground "green2"))) |
890 "Face for bold font in man pages." | 892 "Face for bold font in man pages." |
891 :group 'woman-faces) | 893 :group 'woman-faces) |
894 ;; backward-compatibility alias | |
895 (put 'woman-bold-face 'face-alias 'woman-bold) | |
892 | 896 |
893 ;; Brown is a good compromise: it is distinguishable from the default | 897 ;; Brown is a good compromise: it is distinguishable from the default |
894 ;; but not enough so to make font errors look terrible. (Files that use | 898 ;; but not enough so to make font errors look terrible. (Files that use |
895 ;; non-standard fonts seem to do so badly or in idiosyncratic ways!) | 899 ;; non-standard fonts seem to do so badly or in idiosyncratic ways!) |
896 (defface woman-unknown-face | 900 (defface woman-unknown |
897 '((((background light)) (:foreground "brown")) | 901 '((((background light)) (:foreground "brown")) |
898 (((min-colors 88) (background dark)) (:foreground "cyan1")) | 902 (((min-colors 88) (background dark)) (:foreground "cyan1")) |
899 (((background dark)) (:foreground "cyan"))) | 903 (((background dark)) (:foreground "cyan"))) |
900 "Face for all unknown fonts in man pages." | 904 "Face for all unknown fonts in man pages." |
901 :group 'woman-faces) | 905 :group 'woman-faces) |
902 | 906 ;; backward-compatibility alias |
903 (defface woman-addition-face | 907 (put 'woman-unknown-face 'face-alias 'woman-unknown) |
908 | |
909 (defface woman-addition | |
904 '((t (:foreground "orange"))) | 910 '((t (:foreground "orange"))) |
905 "Face for all WoMan additions to man pages." | 911 "Face for all WoMan additions to man pages." |
906 :group 'woman-faces) | 912 :group 'woman-faces) |
913 ;; backward-compatibility alias | |
914 (put 'woman-addition-face 'face-alias 'woman-addition) | |
907 | 915 |
908 (defun woman-default-faces () | 916 (defun woman-default-faces () |
909 "Set foreground colours of italic and bold faces to their default values." | 917 "Set foreground colours of italic and bold faces to their default values." |
910 (interactive) | 918 (interactive) |
911 (face-spec-set 'woman-italic-face | 919 (face-spec-set 'woman-italic (face-user-default-spec 'woman-italic)) |
912 (face-user-default-spec 'woman-italic-face)) | 920 (face-spec-set 'woman-bold (face-user-default-spec 'woman-bold))) |
913 (face-spec-set 'woman-bold-face (face-user-default-spec 'woman-bold-face))) | |
914 | 921 |
915 (defun woman-monochrome-faces () | 922 (defun woman-monochrome-faces () |
916 "Set foreground colours of italic and bold faces to that of the default face. | 923 "Set foreground colours of italic and bold faces to that of the default face. |
917 This is usually either black or white." | 924 This is usually either black or white." |
918 (interactive) | 925 (interactive) |
919 (set-face-foreground 'woman-italic-face 'unspecified) | 926 (set-face-foreground 'woman-italic 'unspecified) |
920 (set-face-foreground 'woman-bold-face 'unspecified)) | 927 (set-face-foreground 'woman-bold 'unspecified)) |
921 | 928 |
922 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 929 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
923 ;; Experimental font support, initially only for MS-Windows. | 930 ;; Experimental font support, initially only for MS-Windows. |
924 (defconst woman-font-support | 931 (defconst woman-font-support |
925 (eq window-system 'w32) ; Support X later! | 932 (eq window-system 'w32) ; Support X later! |
936 (setq symbol-fonts (cons (car fonts) symbol-fonts))) | 943 (setq symbol-fonts (cons (car fonts) symbol-fonts))) |
937 (setq fonts (cdr fonts))) | 944 (setq fonts (cdr fonts))) |
938 symbol-fonts)) | 945 symbol-fonts)) |
939 | 946 |
940 (when woman-font-support | 947 (when woman-font-support |
941 (make-face 'woman-symbol-face) | 948 (make-face 'woman-symbol) |
942 | 949 |
943 ;; Set the symbol font only if `woman-use-symbol-font' is true, to | 950 ;; Set the symbol font only if `woman-use-symbol-font' is true, to |
944 ;; avoid unnecessarily upsetting the line spacing in NTEmacs 20.5! | 951 ;; avoid unnecessarily upsetting the line spacing in NTEmacs 20.5! |
945 | 952 |
946 (defcustom woman-use-extended-font t | 953 (defcustom woman-use-extended-font t |
1671 ;; Multibyte characters exist. | 1678 ;; Multibyte characters exist. |
1672 (progn | 1679 (progn |
1673 (goto-char (point-min)) | 1680 (goto-char (point-min)) |
1674 (while (search-forward "__\b\b" nil t) | 1681 (while (search-forward "__\b\b" nil t) |
1675 (backward-delete-char 4) | 1682 (backward-delete-char 4) |
1676 (woman-set-face (point) (1+ (point)) 'woman-italic-face)) | 1683 (woman-set-face (point) (1+ (point)) 'woman-italic)) |
1677 (goto-char (point-min)) | 1684 (goto-char (point-min)) |
1678 (while (search-forward "\b\b__" nil t) | 1685 (while (search-forward "\b\b__" nil t) |
1679 (backward-delete-char 4) | 1686 (backward-delete-char 4) |
1680 (woman-set-face (1- (point)) (point) 'woman-italic-face)))) | 1687 (woman-set-face (1- (point)) (point) 'woman-italic)))) |
1681 | 1688 |
1682 ;; Interpret overprinting to indicate bold face: | 1689 ;; Interpret overprinting to indicate bold face: |
1683 (goto-char (point-min)) | 1690 (goto-char (point-min)) |
1684 (while (re-search-forward "\\(.\\)\\(\\(+\\1\\)+\\)" nil t) | 1691 (while (re-search-forward "\\(.\\)\\(\\(+\\1\\)+\\)" nil t) |
1685 (woman-delete-match 2) | 1692 (woman-delete-match 2) |
1686 (woman-set-face (1- (point)) (point) 'woman-bold-face)) | 1693 (woman-set-face (1- (point)) (point) 'woman-bold)) |
1687 | 1694 |
1688 ;; Interpret underlining to indicate italic face: | 1695 ;; Interpret underlining to indicate italic face: |
1689 ;; (Must be AFTER emboldening to interpret bold _ correctly!) | 1696 ;; (Must be AFTER emboldening to interpret bold _ correctly!) |
1690 (goto-char (point-min)) | 1697 (goto-char (point-min)) |
1691 (while (search-forward "_" nil t) | 1698 (while (search-forward "_" nil t) |
1692 (delete-char -2) | 1699 (delete-char -2) |
1693 (woman-set-face (point) (1+ (point)) 'woman-italic-face)) | 1700 (woman-set-face (point) (1+ (point)) 'woman-italic)) |
1694 | 1701 |
1695 ;; Leave any other uninterpreted ^H's in the buffer for now! (They | 1702 ;; Leave any other uninterpreted ^H's in the buffer for now! (They |
1696 ;; might indicate composite special characters, which could be | 1703 ;; might indicate composite special characters, which could be |
1697 ;; interpreted if I knew what to expect.) | 1704 ;; interpreted if I knew what to expect.) |
1698 | 1705 |
1701 (cond | 1708 (cond |
1702 (woman-bold-headings | 1709 (woman-bold-headings |
1703 (goto-char (point-min)) | 1710 (goto-char (point-min)) |
1704 (forward-line) | 1711 (forward-line) |
1705 (while (re-search-forward "^\\( \\)?\\([A-Z].*\\)" nil t) | 1712 (while (re-search-forward "^\\( \\)?\\([A-Z].*\\)" nil t) |
1706 (woman-set-face (match-beginning 2) (match-end 2) 'woman-bold-face)))) | 1713 (woman-set-face (match-beginning 2) (match-end 2) 'woman-bold)))) |
1707 ) | 1714 ) |
1708 | 1715 |
1709 (defun woman-insert-file-contents (filename compressed) | 1716 (defun woman-insert-file-contents (filename compressed) |
1710 "Insert file FILENAME into the current buffer. | 1717 "Insert file FILENAME into the current buffer. |
1711 If COMPRESSED is t, or is non-nil and the filename implies compression, | 1718 If COMPRESSED is t, or is non-nil and the filename implies compression, |
2202 (setq woman-if-conditions-true | 2209 (setq woman-if-conditions-true |
2203 (cons (string-to-char (symbol-name woman-emulation)) '(?e ?o))) | 2210 (cons (string-to-char (symbol-name woman-emulation)) '(?e ?o))) |
2204 | 2211 |
2205 ;; Prepare non-underlined versions of underlined faces: | 2212 ;; Prepare non-underlined versions of underlined faces: |
2206 (woman-non-underline-faces) | 2213 (woman-non-underline-faces) |
2207 ;; Set font of `woman-symbol-face' to `woman-symbol-font' if | 2214 ;; Set font of `woman-symbol' face to `woman-symbol-font' if |
2208 ;; `woman-symbol-font' is well defined. | 2215 ;; `woman-symbol-font' is well defined. |
2209 (and woman-use-symbol-font | 2216 (and woman-use-symbol-font |
2210 (stringp woman-symbol-font) | 2217 (stringp woman-symbol-font) |
2211 (set-face-font 'woman-symbol-face woman-symbol-font | 2218 (set-face-font 'woman-symbol woman-symbol-font |
2212 (and (frame-live-p woman-frame) woman-frame))) | 2219 (and (frame-live-p woman-frame) woman-frame))) |
2213 | 2220 |
2214 ;; Set syntax and display tables: | 2221 ;; Set syntax and display tables: |
2215 (set-syntax-table woman-syntax-table) | 2222 (set-syntax-table woman-syntax-table) |
2216 (woman-set-buffer-display-table) | 2223 (woman-set-buffer-display-table) |
2291 (repl (if (or (= (aref esc 0) ?u) | 2298 (repl (if (or (= (aref esc 0) ?u) |
2292 (and (>= (length esc) 2) (= (aref esc 2) ?-))) | 2299 (and (>= (length esc) 2) (= (aref esc 2) ?-))) |
2293 "^" "_"))) | 2300 "^" "_"))) |
2294 (cond (first | 2301 (cond (first |
2295 (replace-match repl nil t) | 2302 (replace-match repl nil t) |
2296 (put-text-property (1- (point)) (point) | 2303 (put-text-property (1- (point)) (point) 'face 'woman-addition) |
2297 'face 'woman-addition-face) | |
2298 (WoMan-warn | 2304 (WoMan-warn |
2299 "Initial vertical motion escape \\%s simulated" esc) | 2305 "Initial vertical motion escape \\%s simulated" esc) |
2300 (WoMan-log | 2306 (WoMan-log |
2301 " by TeX `%s' in woman-addition-face!" repl)) | 2307 " by TeX `%s' in woman-addition-face!" repl)) |
2302 (t | 2308 (t |
2917 (defsubst woman-replace-match (newtext &optional face) | 2923 (defsubst woman-replace-match (newtext &optional face) |
2918 "Replace text matched by last search with NEWTEXT and return t. | 2924 "Replace text matched by last search with NEWTEXT and return t. |
2919 Set NEWTEXT in face FACE if specified." | 2925 Set NEWTEXT in face FACE if specified." |
2920 (woman-delete-match 0) | 2926 (woman-delete-match 0) |
2921 (insert-before-markers newtext) | 2927 (insert-before-markers newtext) |
2922 (if face (put-text-property (1- (point)) (point) | 2928 (if face (put-text-property (1- (point)) (point) 'face 'woman-symbol)) |
2923 'face 'woman-symbol-face)) | |
2924 t) | 2929 t) |
2925 | 2930 |
2926 (defun woman-special-characters (to) | 2931 (defun woman-special-characters (to) |
2927 "Process special character escapes \\(xx, \\[xxx] up to buffer position TO. | 2932 "Process special character escapes \\(xx, \\[xxx] up to buffer position TO. |
2928 \(This must be done AFTER translation, which may use special characters.)" | 2933 \(This must be done AFTER translation, which may use special characters.)" |
2936 (cond ((and (cddr replacement) | 2941 (cond ((and (cddr replacement) |
2937 (if (nthcdr 3 replacement) | 2942 (if (nthcdr 3 replacement) |
2938 ;; Need symbol font: | 2943 ;; Need symbol font: |
2939 (if woman-use-symbol-font | 2944 (if woman-use-symbol-font |
2940 (woman-replace-match (nth 2 replacement) | 2945 (woman-replace-match (nth 2 replacement) |
2941 'woman-symbol-face)) | 2946 'woman-symbol)) |
2942 ;; Need extended font: | 2947 ;; Need extended font: |
2943 (if woman-use-extended-font | 2948 (if woman-use-extended-font |
2944 (woman-replace-match (nth 2 replacement)))))) | 2949 (woman-replace-match (nth 2 replacement)))))) |
2945 ((cadr replacement) ; Use ASCII simulation | 2950 ((cadr replacement) ; Use ASCII simulation |
2946 (woman-replace-match (cadr replacement))))) | 2951 (woman-replace-match (cadr replacement))))) |
2961 (set-buffer standard-output) | 2966 (set-buffer standard-output) |
2962 (let ((i 32)) | 2967 (let ((i 32)) |
2963 (while (< i 256) | 2968 (while (< i 256) |
2964 (insert (format "\\%03o " i) (string i) " " (string i)) | 2969 (insert (format "\\%03o " i) (string i) " " (string i)) |
2965 (put-text-property (1- (point)) (point) | 2970 (put-text-property (1- (point)) (point) |
2966 'face 'woman-symbol-face) | 2971 'face 'woman-symbol) |
2967 (insert " ") | 2972 (insert " ") |
2968 (setq i (1+ i)) | 2973 (setq i (1+ i)) |
2969 (when (= i 128) (setq i 160) (insert "\n")) | 2974 (when (= i 128) (setq i 160) (insert "\n")) |
2970 (if (zerop (% i 8)) (insert "\n"))) | 2975 (if (zerop (% i 8)) (insert "\n"))) |
2971 )) | 2976 )) |
3229 | 3234 |
3230 ;;; Direct font selection: | 3235 ;;; Direct font selection: |
3231 | 3236 |
3232 (defconst woman-font-alist | 3237 (defconst woman-font-alist |
3233 '(("R" . default) | 3238 '(("R" . default) |
3234 ("I" . woman-italic-face) | 3239 ("I" . woman-italic) |
3235 ("B" . woman-bold-face) | 3240 ("B" . woman-bold) |
3236 ("P" . previous) | 3241 ("P" . previous) |
3237 ("1" . default) | 3242 ("1" . default) |
3238 ("2" . woman-italic-face) | 3243 ("2" . woman-italic) |
3239 ("3" . woman-bold-face) ; used in bash.1 | 3244 ("3" . woman-bold) ; used in bash.1 |
3240 ) | 3245 ) |
3241 "Alist of ?roff font indicators and woman font variables and names.") | 3246 "Alist of ?roff font indicators and woman font variables and names.") |
3242 | 3247 |
3243 (defun woman-change-fonts () | 3248 (defun woman-change-fonts () |
3244 "Process font changes." | 3249 "Process font changes." |
3282 font (if font | 3287 font (if font |
3283 (cdr font) | 3288 (cdr font) |
3284 (WoMan-warn "Unknown font %s." fontstring) | 3289 (WoMan-warn "Unknown font %s." fontstring) |
3285 ;; Output this message once only per call ... | 3290 ;; Output this message once only per call ... |
3286 (setq font-alist | 3291 (setq font-alist |
3287 (cons (cons fontstring 'woman-unknown-face) | 3292 (cons (cons fontstring 'woman-unknown) |
3288 font-alist)) | 3293 font-alist)) |
3289 'woman-unknown-face) | 3294 'woman-unknown) |
3290 ))) | 3295 ))) |
3291 ;; Delete font control line or escape sequence: | 3296 ;; Delete font control line or escape sequence: |
3292 (cond (beg (delete-region beg (point)) | 3297 (cond (beg (delete-region beg (point)) |
3293 (if (eq font 'previous) (setq font previous-font)))) | 3298 (if (eq font 'previous) (setq font previous-font)))) |
3294 (woman-set-face previous-pos (point) current-font) | 3299 (woman-set-face previous-pos (point) current-font) |
3745 (buffer-substring start here)) | 3750 (buffer-substring start here)) |
3746 (delete-region here (point))) | 3751 (delete-region here (point))) |
3747 )) | 3752 )) |
3748 ;; Embolden heading (point is at end of heading): | 3753 ;; Embolden heading (point is at end of heading): |
3749 (woman-set-face | 3754 (woman-set-face |
3750 (save-excursion (beginning-of-line) (point)) (point) 'woman-bold-face) | 3755 (save-excursion (beginning-of-line) (point)) (point) 'woman-bold) |
3751 (forward-line) | 3756 (forward-line) |
3752 (delete-blank-lines) | 3757 (delete-blank-lines) |
3753 (setq woman-left-margin woman-default-indent) | 3758 (setq woman-left-margin woman-default-indent) |
3754 (setq woman-prevailing-indent woman-default-indent) | 3759 (setq woman-prevailing-indent woman-default-indent) |
3755 (woman2-format-paragraphs to woman-left-margin)) | 3760 (woman2-format-paragraphs to woman-left-margin)) |
3765 (woman-leave-blank-lines woman-interparagraph-distance) | 3770 (woman-leave-blank-lines woman-interparagraph-distance) |
3766 (setq woman-leave-blank-lines nil) | 3771 (setq woman-leave-blank-lines nil) |
3767 ;; Optionally embolden heading (point is at beginning of heading): | 3772 ;; Optionally embolden heading (point is at beginning of heading): |
3768 (if woman-bold-headings | 3773 (if woman-bold-headings |
3769 (woman-set-face | 3774 (woman-set-face |
3770 (point) (save-excursion (end-of-line) (point)) 'woman-bold-face)) | 3775 (point) (save-excursion (end-of-line) (point)) 'woman-bold)) |
3771 (forward-line) | 3776 (forward-line) |
3772 (setq woman-left-margin woman-default-indent | 3777 (setq woman-left-margin woman-default-indent |
3773 woman-nofill nil) ; fill output lines | 3778 woman-nofill nil) ; fill output lines |
3774 (setq woman-prevailing-indent woman-default-indent) | 3779 (setq woman-prevailing-indent woman-default-indent) |
3775 (woman2-format-paragraphs to woman-left-margin)) | 3780 (woman2-format-paragraphs to woman-left-margin)) |