aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2000-11-24 09:09:55 +0000
committerMiles Bader2000-11-24 09:09:55 +0000
commitf5b50baad33a98aba08e7889451b2749994e159b (patch)
tree2f94bea8d3eb3985e53da6372ecf1e61833b0373
parent7d0278167b563513731e93c71d65463eadb6b89a (diff)
downloademacs-f5b50baad33a98aba08e7889451b2749994e159b.tar.gz
emacs-f5b50baad33a98aba08e7889451b2749994e159b.zip
(custom-filter-face-spec, custom-pre-filter-face-spec)
(custom-post-filter-face-spec): New functions. (custom-face-set, custom-face-value-create): Filter the face spec before and after customization. (custom-face-set): If VALUE specifies a null face, pass a non-null-but-otherwise-ignored face-spec instead to `face-spec-set'.
-rw-r--r--lisp/cus-edit.el60
1 files changed, 58 insertions, 2 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index d8fa38249eb..755f0ff5cb8 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -2593,6 +2593,57 @@ Match frames with dark backgrounds.")
2593(defconst custom-face-selected (widget-convert 'custom-face-selected) 2593(defconst custom-face-selected (widget-convert 'custom-face-selected)
2594 "Converted version of the `custom-face-selected' widget.") 2594 "Converted version of the `custom-face-selected' widget.")
2595 2595
2596(defun custom-filter-face-spec (spec filter-index default-filter)
2597 "Return a canonicalized version of SPEC using.
2598FILTER-INDEX is the index in the entry for each attribute in
2599`custom-face-attributes' at which the appropriate filter function can be
2600found, and DEFAULT-FILTER is the filter to apply for attributes that
2601don't specify one."
2602 (mapcar (lambda (entry)
2603 ;; Filter a single face-spec entry
2604 (let ((tests (car entry))
2605 (unfiltered-attrs
2606 ;; Handle both old- and new-style attribute syntax
2607 (if (listp (car (cdr entry)))
2608 (car (cdr entry))
2609 (cdr entry)))
2610 (filtered-attrs nil))
2611 ;; Filter each face attribute
2612 (while unfiltered-attrs
2613 (let* ((attr (pop unfiltered-attrs))
2614 (pre-filtered-value (pop unfiltered-attrs))
2615 (filter
2616 (or (nth filter-index (assq attr custom-face-attributes))
2617 default-filter))
2618 (filtered-value
2619 (if filter
2620 (funcall filter pre-filtered-value)
2621 pre-filtered-value)))
2622 (push filtered-value filtered-attrs)
2623 (push attr filtered-attrs)))
2624 ;;
2625 (list tests filtered-attrs)))
2626 spec))
2627
2628(defun custom-pre-filter-face-spec (spec)
2629 "Return SPEC changed as necessary for editing by the face customization widget.
2630SPEC must be a full face spec."
2631 (custom-filter-face-spec
2632 spec 2
2633 (lambda (value)
2634 (cond ((eq value 'unspecified) nil)
2635 ((eq value nil) 'off)
2636 (t value)))))
2637
2638(defun custom-post-filter-face-spec (spec)
2639 "Return the customized SPEC in a form suitable for setting the face."
2640 (custom-filter-face-spec
2641 spec 3
2642 (lambda (value)
2643 (cond ((eq value nil) 'unspecified)
2644 ((eq value 'off) nil)
2645 (t value)))))
2646
2596(defun custom-face-value-create (widget) 2647(defun custom-face-value-create (widget)
2597 "Create a list of the display specifications for WIDGET." 2648 "Create a list of the display specifications for WIDGET."
2598 (let ((buttons (widget-get widget :buttons)) 2649 (let ((buttons (widget-get widget :buttons))
@@ -2681,6 +2732,7 @@ Match frames with dark backgrounds.")
2681 ;; edit it as the user has specified it. 2732 ;; edit it as the user has specified it.
2682 (if (not (face-spec-match-p symbol spec (selected-frame))) 2733 (if (not (face-spec-match-p symbol spec (selected-frame)))
2683 (setq spec (list (list t (face-attr-construct symbol (selected-frame)))))) 2734 (setq spec (list (list t (face-attr-construct symbol (selected-frame))))))
2735 (setq spec (custom-pre-filter-face-spec spec))
2684 (setq edit (widget-create-child-and-convert 2736 (setq edit (widget-create-child-and-convert
2685 widget 2737 widget
2686 (cond ((and (eq form 'selected) 2738 (cond ((and (eq form 'selected)
@@ -2794,7 +2846,7 @@ Optional EVENT is the location for the menu."
2794 "Make the face attributes in WIDGET take effect." 2846 "Make the face attributes in WIDGET take effect."
2795 (let* ((symbol (widget-value widget)) 2847 (let* ((symbol (widget-value widget))
2796 (child (car (widget-get widget :children))) 2848 (child (car (widget-get widget :children)))
2797 (value (widget-value child)) 2849 (value (custom-post-filter-face-spec (widget-value child)))
2798 (comment-widget (widget-get widget :comment-widget)) 2850 (comment-widget (widget-get widget :comment-widget))
2799 (comment (widget-value comment-widget))) 2851 (comment (widget-value comment-widget)))
2800 (when (equal comment "") 2852 (when (equal comment "")
@@ -2802,7 +2854,11 @@ Optional EVENT is the location for the menu."
2802 ;; Make the comment invisible by hand if it's empty 2854 ;; Make the comment invisible by hand if it's empty
2803 (custom-comment-hide comment-widget)) 2855 (custom-comment-hide comment-widget))
2804 (put symbol 'customized-face value) 2856 (put symbol 'customized-face value)
2805 (face-spec-set symbol value) 2857 (if (face-spec-choose value)
2858 (face-spec-set symbol value)
2859 ;; face-set-spec ignores empty attribute lists, so just give it
2860 ;; something harmless instead.
2861 (face-spec-set symbol '((t :foreground unspecified))))
2806 (put symbol 'customized-face-comment comment) 2862 (put symbol 'customized-face-comment comment)
2807 (put symbol 'face-comment comment) 2863 (put symbol 'face-comment comment)
2808 (custom-face-state-set widget) 2864 (custom-face-state-set widget)