-(require 'custom)
-
-(eval-and-compile (require 'cl))
-
-;;; Compatibility.
-
-(if (string-match "XEmacs" emacs-version)
- (defun custom-face-background (face &optional frame)
- ;; Specifiers suck!
- "Return the background color name of face FACE, or nil if unspecified."
- (color-instance-name (specifier-instance (face-background face) frame)))
- (defalias 'custom-face-background 'face-background))
-
-(if (string-match "XEmacs" emacs-version)
- (defun custom-face-foreground (face &optional frame)
- ;; Specifiers suck!
- "Return the background color name of face FACE, or nil if unspecified."
- (color-instance-name (specifier-instance (face-foreground face) frame)))
- (defalias 'custom-face-foreground 'face-foreground))
-
-(defalias 'custom-face-font-name (if (string-match "XEmacs" emacs-version)
- 'face-font-name
- 'face-font))
-
-(eval-and-compile
- (unless (fboundp 'frame-property)
- ;; XEmacs function missing in Emacs 19.34.
- (defun frame-property (frame property &optional default)
- "Return FRAME's value for property PROPERTY."
- (or (cdr (assq property (frame-parameters frame)))
- default)))
-
- (unless (fboundp 'face-doc-string)
- ;; XEmacs function missing in Emacs.
- (defun face-doc-string (face)
- "Get the documentation string for FACE."
- (get face 'face-doc-string)))
-
- (unless (fboundp 'set-face-doc-string)
- ;; XEmacs function missing in Emacs.
- (defun set-face-doc-string (face string)
- "Set the documentation string for FACE to STRING."
- (put face 'face-doc-string string)))
-
- (when (and (not (fboundp 'set-face-stipple))
- (fboundp 'set-face-background-pixmap))
- ;; Emacs function missing in XEmacs 19.15.
- (defun set-face-stipple (face pixmap &optional frame)
- ;; Written by Kyle Jones.
- "Change the stipple pixmap of face FACE to PIXMAP.
-PIXMAP should be a string, the name of a file of pixmap data.
-The directories listed in the `x-bitmap-file-path' variable are searched.
-
-Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
-where WIDTH and HEIGHT are the size in pixels,
-and DATA is a string, containing the raw bits of the bitmap.
-
-If the optional FRAME argument is provided, change only
-in that frame; otherwise change each frame."
- (while (not (find-face face))
- (setq face (signal 'wrong-type-argument (list 'facep face))))
- (while (cond ((stringp pixmap)
- (unless (file-readable-p pixmap)
- (setq pixmap (vector 'xbm ':file pixmap)))
- nil)
- ((and (consp pixmap) (= (length pixmap) 3))
- (setq pixmap (vector 'xbm ':data pixmap))
- nil)
- (t t))
- (setq pixmap (signal 'wrong-type-argument
- (list 'stipple-pixmap-p pixmap))))
- (while (and frame (not (framep frame)))
- (setq frame (signal 'wrong-type-argument (list 'framep frame))))
- (set-face-background-pixmap face pixmap frame))))
-
-(unless (fboundp 'x-color-values)
- ;; Emacs function missing in XEmacs 19.14.
- (defun x-color-values (color &optional frame)
- "Return a description of the color named COLOR on frame FRAME.
-The value is a list of integer RGB values--(RED GREEN BLUE).
-These values appear to range from 0 to 65280 or 65535, depending
-on the system; white is (65280 65280 65280) or (65535 65535 65535).
-If FRAME is omitted or nil, use the selected frame."
- (color-instance-rgb-components (make-color-instance color))))
-
-;; XEmacs and Emacs have different definitions of `facep'.
-;; The Emacs definition is the useful one, so emulate that.
-(cond ((not (fboundp 'facep))
- (defun custom-facep (face)
- "No faces"
- nil))
- ((string-match "XEmacs" emacs-version)
- (defalias 'custom-facep 'find-face))
- (t
- (defalias 'custom-facep 'facep)))
-
-(unless (fboundp 'make-empty-face)
- ;; This should be moved to `faces.el'.
- (if (string-match "XEmacs" emacs-version)
- ;; Give up for old XEmacs pre 19.15/20.1.
- (defalias 'make-empty-face 'make-face)
- ;; Define for Emacs pre 19.35.
- (defun make-empty-face (name)
- "Define a new FACE on all frames, ignoring X resources."
- (interactive "SMake face: ")
- (or (internal-find-face name)
- (let ((face (make-vector 8 nil)))
- (aset face 0 'face)
- (aset face 1 name)
- (let* ((frames (frame-list))
- (inhibit-quit t)
- (id (internal-next-face-id)))
- (make-face-internal id)
- (aset face 2 id)
- (while frames
- (set-frame-face-alist (car frames)
- (cons (cons name (copy-sequence face))
- (frame-face-alist (car frames))))
- (setq frames (cdr frames)))
- (setq global-face-data (cons (cons name face) global-face-data)))
- ;; add to menu
- (if (fboundp 'facemenu-add-new-face)
- (facemenu-add-new-face name))
- face))
- name)))
-
-(defcustom initialize-face-resources t
- "If non nil, allow X resources to initialize face properties.
-This only affects faces declared with `defface', and only NT or X11 frames."
- :group 'customize
- :type 'boolean)
-
-(cond ((fboundp 'initialize-face-resources)
- ;; Already bound, do nothing.
- )
- ((fboundp 'make-face-x-resource-internal)
- ;; Emacs or new XEmacs.
- (defun initialize-face-resources (face &optional frame)
- "Initialize face according to the X11 resources.
-This might overwrite existing face properties.
-Does nothing when the variable initialize-face-resources is nil."
- (when initialize-face-resources
- (make-face-x-resource-internal face frame t))))
- (t
- ;; Too hard to do right on XEmacs.
- (defalias 'initialize-face-resources 'ignore)))
-
-;;(if (string-match "XEmacs" emacs-version)
-;; ;; Xemacs.
-;; (defun custom-invert-face (face &optional frame)
-;; "Swap the foreground and background colors of face FACE.
-;;If the colors are not specified in the face, use the default colors."
-;; (interactive (list (read-face-name "Reverse face: ")))
-;; (let ((fg (color-name (face-foreground face frame) frame))
-;; (bg (color-name (face-background face frame) frame)))
-;; (set-face-foreground face bg frame)
-;; (set-face-background face fg frame)))
-;; ;; Emacs.
-;; (defun custom-invert-face (face &optional frame)
-;; "Swap the foreground and background colors of face FACE.
-;;If the colors are not specified in the face, use the default colors."
-;; (interactive (list (read-face-name "Reverse face: ")))
-;; (let ((fg (or (face-foreground face frame)
-;; (face-foreground 'default frame)
-;; (frame-property (or frame (selected-frame))
-;; 'foreground-color)
-;; "black"))
-;; (bg (or (face-background face frame)
-;; (face-background 'default frame)
-;; (frame-property (or frame (selected-frame))
-;; 'background-color)
-;; "white")))
-;; (set-face-foreground face bg frame)
-;; (set-face-background face fg frame))))
-
-(defcustom custom-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."
- :group 'customize
- :type '(choice (choice-item dark)
- (choice-item light)
- (choice-item :tag "default" nil)))
-
-(defun custom-background-mode (frame)
- "Kludge to detect background mode for FRAME."
- (let* ((bg-resource
- (condition-case ()
- (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
- (error nil)))
- color
- (mode (cond (bg-resource
- (intern (downcase bg-resource)))
- ((and (setq color (condition-case ()
- (or (frame-property
- frame
- 'background-color)
- (custom-face-background
- 'default))
- (error nil)))
- (or (string-match "XEmacs" emacs-version)
- window-system)
- (< (apply '+ (x-color-values color))
- (/ (apply '+ (x-color-values "white"))
- 3)))
- 'dark)
- (t 'light))))
- (modify-frame-parameters frame (list (cons 'background-mode mode)))
- mode))
-
-(eval-and-compile
- (if (string-match "XEmacs" emacs-version)
- ;; XEmacs.
- (defun custom-extract-frame-properties (frame)
- "Return a plist with the frame properties of FRAME used by custom."
- (list 'type (device-type (frame-device frame))
- 'class (device-class (frame-device frame))
- 'background (or custom-background-mode
- (frame-property frame
- 'background-mode)
- (custom-background-mode frame))))
- ;; Emacs.
- (defun custom-extract-frame-properties (frame)
- "Return a plist with the frame properties of FRAME used by custom."
- (list 'type window-system
- 'class (frame-property frame 'display-type)
- 'background (or custom-background-mode
- (frame-property frame 'background-mode)
- (custom-background-mode frame))))))