]> code.delx.au - gnu-emacs/blobdiff - lisp/cus-face.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / cus-face.el
index f813b5b84d11d7d7ef2e1833ef96691e7b70fb02..e1f1668d1ad33f2eac3bb00cb621bdb1a207e851 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cus-face.el --- customization support for faces
 ;;
-;; Copyright (C) 1996-1997, 1999-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 1999-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: help, faces
 ;;; Declaring a face.
 
 (defun custom-declare-face (face spec doc &rest args)
-  "Like `defface', but FACE is evaluated as a normal argument."
+  "Like `defface', but with FACE evaluated as a normal argument."
   (unless (get face 'face-defface-spec)
-    (when (fboundp 'facep)
-      (unless (facep face)
-       ;; If the user has already created the face, respect that.
-       (let ((value (or (get face 'saved-face) spec))
-             (have-window-system (memq initial-window-system '(x w32))))
-         ;; Create global face.
-         (make-empty-face face)
-         ;; Create frame-local faces
-         (dolist (frame (frame-list))
-           (face-spec-set-2 face frame value)
-           (when (memq (window-system frame) '(x w32 ns))
-             (setq have-window-system t)))
-         ;; When making a face after frames already exist
-         (if have-window-system
-             (make-face-x-resource-internal face)))))
-    ;; Don't record SPEC until we see it causes no errors.
-    (put face 'face-defface-spec (purecopy spec))
+    (face-spec-set face (purecopy spec) 'face-defface-spec)
     (push (cons 'defface face) current-load-list)
-    (when (and doc (null (face-documentation face)))
+    (when doc
       (set-face-documentation face (purecopy doc)))
     (custom-handle-all-keywords face args 'custom-face)
     (run-hooks 'custom-define-hook))
      (choice :tag "Underline"
             :help-echo "Control text underlining."
             (const :tag "Off" nil)
-            (const :tag "On" t)
-            (color :tag "Colored")))
+            (list :tag "On"
+                  :value (:color foreground-color :style line)
+                  (const :format "" :value :color)
+                  (choice :tag "Color"
+                          (const :tag "Foreground Color" foreground-color)
+                          color)
+                  (const :format "" :value :style)
+                  (choice :tag "Style"
+                          (const :tag "Line" line)
+                          (const :tag "Wave" wave))))
+     ;; filter to make value suitable for customize
+     (lambda (real-value)
+       (and real-value
+           (let ((color
+                  (or (and (consp real-value) (plist-get real-value :color))
+                      (and (stringp real-value) real-value)
+                      'foreground-color))
+                 (style
+                  (or (and (consp real-value) (plist-get real-value :style))
+                      'line)))
+             (list :color color :style style))))
+     ;; filter to make customized-value suitable for storing
+     (lambda (cus-value)
+       (and cus-value
+           (let ((color (plist-get cus-value :color))
+                 (style (plist-get cus-value :style)))
+             (cond ((eq style 'line)
+                    ;; Use simple value for default style
+                    (if (eq color 'foreground-color) t color))
+                   (t
+                    `(:color ,color :style ,style)))))))
 
     (:overline
      (choice :tag "Overline"
@@ -309,10 +322,7 @@ Several properties of THEME and FACE are used in the process:
 
 If THEME property `theme-immediate' is non-nil, this is equivalent of
 providing the NOW argument to all faces in the argument list: FACE is
-created now.  The only difference is FACE property `force-face': if NOW
-is non-nil, FACE property `force-face' is set to the symbol `rogue', else
-if THEME property `theme-immediate' is non-nil, FACE property `force-face'
-is set to the symbol `immediate'.
+created now.
 
 SPEC itself is saved in FACE property `saved-face' and it is stored in
 FACE's list property `theme-face' \(using `custom-push-theme')."
@@ -337,15 +347,11 @@ FACE's list property `theme-face' \(using `custom-push-theme')."
            (when (not (and oldspec (eq 'user (caar oldspec))))
              (put face 'saved-face spec)
              (put face 'saved-face-comment comment))
-           ;; Do this AFTER checking the `theme-face' property.
            (custom-push-theme 'theme-face face theme 'set spec)
            (when (or now immediate)
              (put face 'force-face (if now 'rogue 'immediate)))
            (when (or now immediate (facep face))
-             (unless (facep face)
-               (make-empty-face face))
              (put face 'face-comment comment)
-             (put face 'face-override-spec nil)
              (face-spec-set face spec t))))))))
 
 ;; XEmacs compatibility function.  In XEmacs, when you reset a Custom