(frame-background-mode): New variable.
[elisp/apel.git] / tinycustom.el
index a912103..e6d2744 100644 (file)
 
 ;;; Commentary:
 
-;; Purpose of this program is emulating for who does not have
-;; `custom.el'.
+;; Purpose of this program is emulating for who does not have "custom".
+;; (custom.el bundled with v19 is old; does not have following macros.)
+;;
 ;; DEFCUSTOM below has the same effect as the original DEFVAR has.
-;; DEFGROUP and DEFFACE below are just nop macro.
+;; DEFFACE only makes a face.
+;; DEFGROUP and DEFINE-WIDGET below are just nop macro.
 
 ;;; Code:
 
@@ -39,8 +41,8 @@
 SYMBOL does not need to be quoted.
 Third arg DOC is the group documentation.
 
-This is a nop defgroup only for emulating purpose.."
-  nil )
+This is a nop defgroup only for emulating purpose."
+  nil)
     
 (defmacro-maybe defcustom (symbol value doc &rest args) 
   "Declare SYMBOL as a customizable variable that defaults to VALUE.
@@ -48,16 +50,71 @@ DOC is the variable documentation.
 
 This is a defcustom only for emulating purpose.
 Its effect is just as same as that of defvar."
-  (` (defvar (, symbol) (, value) (, doc))) )
+  (` (defvar (, symbol) (, value) (, doc))))
     
-(defmacro-maybe defface (symbol value doc &rest args) 
+(defvar-maybe frame-background-mode nil
+  "*The brightness of the background.
+Set this to the symbol dark if your background color is dark, light if
+your background is light, or nil (default) if you want Emacs to
+examine the brightness for you.  However, the old Emacsen might not
+examine the brightness, so you should set this value definitely.")
+
+(defmacro-maybe-cond defface (face spec doc &rest args)
   "Declare FACE as a customizable face that defaults to SPEC.
-FACE does not need to be quoted.
-
-This is a nop defface only for emulating purpose."
-  nil )
+FACE does not need to be quoted.  [custom emulating macro]"
+  ((fboundp 'make-face)
+   (` (let ((name (quote (, face))))
+       (or
+        (find-face name)
+        (let ((face (make-face name))
+              (spec (, spec))
+              (colorp (and window-system (x-display-color-p)))
+              display atts req item match done)
+          (while (and spec (not done))
+            (setq display (car (car spec))
+                  atts (car (cdr (car spec)))
+                  spec (cdr spec))
+            (cond
+             ((consp display)
+              (setq match t)
+              (while (and display match)
+                (setq req (car (car display))
+                      item (car (cdr (car display)))
+                      display (cdr display))
+                (cond
+                 ((eq 'class req)
+                  (setq match (or (and colorp (eq 'color item))
+                                  (and (not colorp)
+                                       (memq item '(grayscale mono))))))
+                 ((eq 'background req)
+                  (setq match (eq frame-background-mode item)))))
+              (setq done match))
+             ((eq t display)
+              (setq done t))))
+          (if done
+              (let ((alist '((:foreground . set-face-foreground)
+                             (:background . set-face-background)
+                             (:bold . set-face-bold-p)
+                             (:italic . set-face-italic-p)
+                             (:underline . set-face-underline-p)))
+                    function)
+                (while atts
+                  (if (setq function (cdr (assq (car atts) alist)))
+                      (funcall function face (car (cdr atts))))
+                  (setq atts (cdr (cdr atts))))))
+          face)))))
+  (t
+   ;; do nothing.
+   ))
+
+(defmacro-maybe define-widget (name class doc &rest args)
+  "Define a new widget type named NAME from CLASS.
+The third argument DOC is a documentation string for the widget.
+
+This is a nop define-widget only for emulating purpose."
+  nil)
 
 (provide 'tinycustom)
 (provide 'custom)
 
-;; end of tinycustom.el
+;;; tinycustom.el ends here.