diff options
| author | Bill Wohler | 2006-04-01 00:58:41 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-04-01 00:58:41 +0000 |
| commit | 367c48ef1ee5e861ace73d4219325e64191fc25a (patch) | |
| tree | a08953c4ad53f2652c71c87e7f54a46cfccaa4f2 | |
| parent | 4c2ee078aaa8d5690578dfd22f725c61195c0737 (diff) | |
| download | emacs-367c48ef1ee5e861ace73d4219325e64191fc25a.tar.gz emacs-367c48ef1ee5e861ace73d4219325e64191fc25a.zip | |
(mh-strip-package-version): Make macro, also to avoid compiler error.
(mh-defface-compat): Incorporate body into mh-face-data and delete.
| -rw-r--r-- | lisp/mh-e/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/mh-e/mh-e.el | 126 |
2 files changed, 70 insertions, 60 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 51fdf8cce32..fa66eaca664 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | 2006-03-31 Bill Wohler <wohler@newt.com> | 1 | 2006-03-31 Bill Wohler <wohler@newt.com> |
| 2 | 2 | ||
| 3 | * mh-e.el (mh-strip-package-version): Move before use to avoid | 3 | * mh-e.el (mh-strip-package-version): Move before use to avoid |
| 4 | compiler error. | 4 | compiler error. Make macro, also to avoid compiler error. |
| 5 | (mh-defface-compat): Incorporate body into mh-face-data and | ||
| 6 | delete. | ||
| 5 | 7 | ||
| 6 | 2006-03-30 Bill Wohler <wohler@newt.com> | 8 | 2006-03-30 Bill Wohler <wohler@newt.com> |
| 7 | 9 | ||
diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el index 191cecb709a..5f1c66e58d8 100644 --- a/lisp/mh-e/mh-e.el +++ b/lisp/mh-e/mh-e.el | |||
| @@ -895,18 +895,18 @@ necessary and can actually cause problems." | |||
| 895 | 895 | ||
| 896 | ;; Temporary function and data structure used customization. | 896 | ;; Temporary function and data structure used customization. |
| 897 | ;; These will be unbound after the options are defined. | 897 | ;; These will be unbound after the options are defined. |
| 898 | (defun mh-strip-package-version (args) | 898 | (defmacro mh-strip-package-version (args) |
| 899 | "Strip :package-version keyword and its value from ARGS. | 899 | "Strip :package-version keyword and its value from ARGS. |
| 900 | In Emacs versions that support the :package-version keyword, | 900 | In Emacs versions that support the :package-version keyword, |
| 901 | ARGS is returned unchanged." | 901 | ARGS is returned unchanged." |
| 902 | (if (boundp 'customize-package-emacs-version-alist) | 902 | `(if (boundp 'customize-package-emacs-version-alist) |
| 903 | args | 903 | ,args |
| 904 | (let (seen) | 904 | (let (seen) |
| 905 | (loop for keyword in args | 905 | (loop for keyword in ,args |
| 906 | if (cond ((eq keyword ':package-version) (setq seen t) nil) | 906 | if (cond ((eq keyword ':package-version) (setq seen t) nil) |
| 907 | (seen (setq seen nil) nil) | 907 | (seen (setq seen nil) nil) |
| 908 | (t t)) | 908 | (t t)) |
| 909 | collect keyword)))) | 909 | collect keyword)))) |
| 910 | 910 | ||
| 911 | (defmacro mh-defgroup (symbol members doc &rest args) | 911 | (defmacro mh-defgroup (symbol members doc &rest args) |
| 912 | "Declare SYMBOL as a customization group containing MEMBERS. | 912 | "Declare SYMBOL as a customization group containing MEMBERS. |
| @@ -3115,46 +3115,12 @@ sequence." | |||
| 3115 | (if (boundp 'facemenu-unlisted-faces) | 3115 | (if (boundp 'facemenu-unlisted-faces) |
| 3116 | (add-to-list 'facemenu-unlisted-faces "^mh-")) | 3116 | (add-to-list 'facemenu-unlisted-faces "^mh-")) |
| 3117 | 3117 | ||
| 3118 | ;; Temporary function and data structure used for defining faces. | 3118 | ;; To add a new face: |
| 3119 | ;; These will be unbound after the faces are defined. | 3119 | ;; 1. Add entry to variable mh-face-data. |
| 3120 | (defvar mh-min-colors-defined-flag (and (not mh-xemacs-flag) | 3120 | ;; 2. Create face using mh-defface (which removes min-color spec and |
| 3121 | (>= emacs-major-version 22)) | 3121 | ;; :package-version keyword where these are not supported), |
| 3122 | "Non-nil means `defface' supports min-colors display requirement.") | 3122 | ;; accessing face data with function mh-face-data. |
| 3123 | 3123 | ;; 3. Add inherit argument to function mh-face-data if applicable. | |
| 3124 | (defun mh-defface-compat (spec) | ||
| 3125 | "Convert SPEC for defface if necessary to run on older platforms. | ||
| 3126 | Modifies SPEC in place and returns it. See `defface' for the spec definition. | ||
| 3127 | |||
| 3128 | When `mh-min-colors-defined-flag' is nil, this function finds | ||
| 3129 | display entries with \"min-colors\" requirements and either | ||
| 3130 | removes the \"min-colors\" requirement or strips the display | ||
| 3131 | entirely if the display does not support the number of specified | ||
| 3132 | colors." | ||
| 3133 | (if mh-min-colors-defined-flag | ||
| 3134 | spec | ||
| 3135 | (let ((cells (mh-display-color-cells)) | ||
| 3136 | new-spec) | ||
| 3137 | ;; Remove entries with min-colors, or delete them if we have fewer colors | ||
| 3138 | ;; than they specify. | ||
| 3139 | (loop for entry in (reverse spec) do | ||
| 3140 | (let ((requirement (if (eq (car entry) t) | ||
| 3141 | nil | ||
| 3142 | (assoc 'min-colors (car entry))))) | ||
| 3143 | (if requirement | ||
| 3144 | (when (>= cells (nth 1 requirement)) | ||
| 3145 | (setq new-spec (cons (cons (delq requirement (car entry)) | ||
| 3146 | (cdr entry)) | ||
| 3147 | new-spec))) | ||
| 3148 | (setq new-spec (cons entry new-spec))))) | ||
| 3149 | new-spec))) | ||
| 3150 | |||
| 3151 | (require 'cus-face) | ||
| 3152 | |||
| 3153 | (defvar mh-inherit-face-flag (assq :inherit custom-face-attributes) | ||
| 3154 | "Non-nil means that the `defface' :inherit keyword is available. | ||
| 3155 | The :inherit keyword is available on all supported versions of | ||
| 3156 | GNU Emacs and XEmacs from at least 21.5.23 on.") | ||
| 3157 | |||
| 3158 | (defvar mh-face-data | 3124 | (defvar mh-face-data |
| 3159 | '((mh-folder-followup | 3125 | '((mh-folder-followup |
| 3160 | ((((class color) (background light)) | 3126 | ((((class color) (background light)) |
| @@ -3297,19 +3263,61 @@ GNU Emacs and XEmacs from at least 21.5.23 on.") | |||
| 3297 | (((class color) (background dark)) | 3263 | (((class color) (background dark)) |
| 3298 | (:foreground "red1" :underline t)) | 3264 | (:foreground "red1" :underline t)) |
| 3299 | (t | 3265 | (t |
| 3300 | (:underline t)))))) | 3266 | (:underline t))))) |
| 3267 | "MH-E face data. | ||
| 3268 | Used by function `mh-face-data' which returns spec that is | ||
| 3269 | consumed by `mh-defface'.") | ||
| 3270 | |||
| 3271 | (require 'cus-face) | ||
| 3272 | |||
| 3273 | (defvar mh-inherit-face-flag (assq :inherit custom-face-attributes) | ||
| 3274 | "Non-nil means that the `defface' :inherit keyword is available. | ||
| 3275 | The :inherit keyword is available on all supported versions of | ||
| 3276 | GNU Emacs and XEmacs from at least 21.5.23 on.") | ||
| 3277 | |||
| 3278 | (defvar mh-min-colors-defined-flag (and (not mh-xemacs-flag) | ||
| 3279 | (>= emacs-major-version 22)) | ||
| 3280 | "Non-nil means `defface' supports min-colors display requirement.") | ||
| 3301 | 3281 | ||
| 3302 | (defun mh-face-data (face &optional inherit) | 3282 | (defun mh-face-data (face &optional inherit) |
| 3303 | "Return spec for FACE. | 3283 | "Return spec for FACE. |
| 3304 | If INHERIT is non-nil and `defface' supports the :inherit | 3284 | See `defface' for the spec definition. |
| 3305 | keyword, return INHERIT literally; otherwise, return spec for FACE. | ||
| 3306 | 3285 | ||
| 3307 | This isn't a perfect implementation. In the case that | 3286 | If INHERIT is non-nil and `defface' supports the :inherit |
| 3308 | the :inherit keyword is not supported, any additional attributes | 3287 | keyword, return INHERIT literally; otherwise, return spec for |
| 3309 | in the inherit parameter are not added to the returned spec." | 3288 | FACE from the variable `mh-face-data'. This isn't a perfect |
| 3310 | (if (and inherit mh-inherit-face-flag) | 3289 | implementation. In the case that the :inherit keyword is not |
| 3311 | inherit | 3290 | supported, any additional attributes in the inherit parameter are |
| 3312 | (mh-defface-compat (cadr (assoc face mh-face-data))))) | 3291 | not added to the returned spec. |
| 3292 | |||
| 3293 | Furthermore, when `mh-min-colors-defined-flag' is nil, this | ||
| 3294 | function finds display entries with \"min-colors\" requirements | ||
| 3295 | and either removes the \"min-colors\" requirement or strips the | ||
| 3296 | display entirely if the display does not support the number of | ||
| 3297 | specified colors." | ||
| 3298 | (let ((spec | ||
| 3299 | (if (and inherit mh-inherit-face-flag) | ||
| 3300 | inherit | ||
| 3301 | (or (cadr (assq face mh-face-data)) | ||
| 3302 | (error "Could not find %s in mh-face-data" face))))) | ||
| 3303 | |||
| 3304 | (if mh-min-colors-defined-flag | ||
| 3305 | spec | ||
| 3306 | (let ((cells (mh-display-color-cells)) | ||
| 3307 | new-spec) | ||
| 3308 | ;; Remove entries with min-colors, or delete them if we have | ||
| 3309 | ;; fewer colors than they specify. | ||
| 3310 | (loop for entry in (reverse spec) do | ||
| 3311 | (let ((requirement (if (eq (car entry) t) | ||
| 3312 | nil | ||
| 3313 | (assq 'min-colors (car entry))))) | ||
| 3314 | (if requirement | ||
| 3315 | (when (>= cells (nth 1 requirement)) | ||
| 3316 | (setq new-spec (cons (cons (delq requirement (car entry)) | ||
| 3317 | (cdr entry)) | ||
| 3318 | new-spec))) | ||
| 3319 | (setq new-spec (cons entry new-spec))))) | ||
| 3320 | new-spec)))) | ||
| 3313 | 3321 | ||
| 3314 | (mh-defface mh-folder-address | 3322 | (mh-defface mh-folder-address |
| 3315 | (mh-face-data 'mh-folder-subject '((t (:inherit mh-folder-subject)))) | 3323 | (mh-face-data 'mh-folder-subject '((t (:inherit mh-folder-subject)))) |
| @@ -3520,9 +3528,9 @@ The background and foreground are used in the image." | |||
| 3520 | ;; Get rid of temporary functions and data structures. | 3528 | ;; Get rid of temporary functions and data structures. |
| 3521 | (fmakunbound 'mh-defcustom) | 3529 | (fmakunbound 'mh-defcustom) |
| 3522 | (fmakunbound 'mh-defface) | 3530 | (fmakunbound 'mh-defface) |
| 3523 | (fmakunbound 'mh-defface-compat) | ||
| 3524 | (fmakunbound 'mh-defgroup) | 3531 | (fmakunbound 'mh-defgroup) |
| 3525 | (fmakunbound 'mh-face-data) | 3532 | (fmakunbound 'mh-face-data) |
| 3533 | (fmakunbound 'mh-strip-package-version) | ||
| 3526 | (makunbound 'mh-face-data) | 3534 | (makunbound 'mh-face-data) |
| 3527 | (makunbound 'mh-inherit-face-flag) | 3535 | (makunbound 'mh-inherit-face-flag) |
| 3528 | (makunbound 'mh-min-colors-defined-flag) | 3536 | (makunbound 'mh-min-colors-defined-flag) |