*** empty log message ***
[gnus] / lisp / custom.el
index 3475fce..910ef02 100644 (file)
@@ -68,6 +68,9 @@
 
 ;;; Code:
 
+(eval-when-compile
+  (require 'cl))
+
 ;;; Compatibility:
 
 (defun custom-xmas-add-text-properties (start end props &optional object)
@@ -204,7 +207,7 @@ STRING should be given if the last search was by `string-match' on STRING."
           (funcall 'set-face-underline-p 'underline t))))
 
 (defun custom-xmas-set-text-properties (start end props &optional buffer)
-  (if (or (null buffer) (bufferp buffer))
+  (if (null buffer)
       (if props
          (while props
            (custom-put-text-property 
@@ -257,9 +260,10 @@ into the buffer visible in the event's window."
 
 ;; Put it in the Help menu, if possible.
 (if (string-match "XEmacs" emacs-version)
-    ;; XEmacs (disabled because it doesn't work)
-    (and current-menubar
-        (add-menu-item '("Help") "Customize..." 'customize nil))
+    (if (featurep 'menubar)
+       ;; XEmacs (disabled because it doesn't work)
+       (and current-menubar
+            (add-menu-item '("Help") "Customize..." 'customize t)))
   ;; Emacs 19.28 and earlier
   (global-set-key [ menu-bar help customize ]
                  '("Customize..." . customize))
@@ -1461,7 +1465,8 @@ If optional ORIGINAL is non-nil, consider VALUE for the original value."
 
 (defun custom-face-import (custom value)
   "Modify CUSTOM's VALUE to match internal expectations."
-  (let ((name (symbol-name value)))
+  (let ((name (or (and (facep value) (symbol-name (face-name value)))
+                 (symbol-name value))))
     (list (if (string-match "\
 custom-face-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)"
                            name)
@@ -1474,7 +1479,7 @@ custom-face-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)"
                    (intern (match-string 6 name)))
            value))))
 
-(defun custom-face-lookup (fg bg stipple bold italic underline)
+(defun custom-face-lookup (&optional fg bg stipple bold italic underline)
   "Lookup or create a face with specified attributes."
   (let ((name (intern (format "custom-face-%s-%s-%s-%S-%S-%S"
                              (or fg "default")
@@ -1487,10 +1492,14 @@ custom-face-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)-\\(.*\\)"
       (copy-face 'default name)
       (when (and fg
                 (not (string-equal fg "default")))
-       (set-face-foreground name fg))
+       (condition-case ()
+           (set-face-foreground name fg)
+         (error nil)))
       (when (and bg
                 (not (string-equal bg "default")))
-       (set-face-background name bg))
+       (condition-case ()
+           (set-face-background name bg)
+         (error nil)))
       (when (and stipple
                 (not (string-equal stipple "default"))
                 (not (eq stipple 'custom:asis))
@@ -2454,9 +2463,8 @@ Face used for customization fields while they are being edited.")
                     (not (string-match "XEmacs" emacs-version)))
 (custom-category-put 'custom-hidden-properties intangible t)
 
-(eval-when 'load
-  (if (file-readable-p custom-file)
-      (load-file custom-file)))
+(if (file-readable-p custom-file)
+    (load-file custom-file))
 
 (provide 'custom)