help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Customizing faces...which method?


From: Ivan Kanis
Subject: Re: Customizing faces...which method?
Date: 03 Oct 2002 21:42:15 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

    Matt> I would like to set different foregrounds (colors) depending
    Matt> on whether the foreground is light or dark.  When I use the
    Matt> customize tool, it seems to ignore the value of
    Matt> frame-background-mode and sets the selected face attributes
    Matt> for all background states.

I am editing my own code in .emacs. I have done this in many different
ways. Using inheritance seem to be the most flexible. As you see the
colors are defined for a light and dark background. The color switch
automatically when I change the background color. I have two functions
called 'light' and 'dark' that toggles the background. I have also
aliased the function 'custom-set-face' to 'my-set-face'. This prevents
the customize tool from screwing up my settings.

Hope this helps!

Ivan

; define an alias to custom-set-face to keep customise messing with my
; font definition
(defalias 'my-set-faces 'custom-set-faces)

; two color combinations for sunny and rainy days
(defun dark()
(interactive)
(my-set-faces
 '(default ((t (:foreground "white" :background "black"))) t)
))

(defun light()
(interactive)
(my-set-faces
 '(default ((t (:foreground "black" :background "grey82"))) t)
))

; Faces customizations
(defface blue-face
  '((((class color) (background light))
       (:foreground "blue"))
      (((class color) (background dark))
       (:foreground "cyan"))
      )
  "Basic face for blue text"
  :version "21.1"
  :group 'basic-faces)

(defface red-face
  '((((class color) (background light))
       (:foreground "red"))
      (((class color) (background dark))
       (:foreground "yellow"))
      )
  "Basic face for red text"
  :version "21.1"
  :group 'basic-faces)

(defface normal-face
  '((((class color) (background light))
       (:foreground "red"))
      (((class color) (background dark))
       (:foreground "yellow"))
      )
  "Basic face for normal text"
  :version "21.1"
  :group 'basic-faces)

(defface purple-face
  '((((class color) (background light))
       (:foreground "purple"))
      (((class color) (background dark))
       (:foreground "magenta"))
      )
  "Basic face for purple text"
  :version "21.1"
  :group 'basic-faces)

(defface green-face
  '((((class color) (background light))
       (:foreground "dark green"))
      (((class color) (background dark))
       (:foreground "green"))
      )
  "Basic face for purple text"
  :version "21.1"
  :group 'basic-faces)


; Faces that uses inheritance
(my-set-faces
 '(bold ((t (:inherit red-face))))
 '(bold-italic ((t (:inherit blue-face))))
 '(comint-input-face ((t (:inherit blue-face))))
 '(cperl-array-face ((t (:inherit normal-face))))
 '(cperl-hash-face ((t (:inherit normal-face))))
 '(cperl-nonoverridable-face ((t (:inherit purple-face))))
 '(cvs-filename-face ((t (:inherit blue-face))))
 '(cvs-handled-face ((t (:inherit green-face))))
 '(cvs-header-face ((t (:inherit blue-face))))
 '(eshell-ls-archive-face ((t (:inherit blue-face))))
 '(eshell-ls-backup-face ((t (:inherit normal-face))))
 '(eshell-ls-clutter-face ((t (:inherit normal-face))))
 '(eshell-ls-directory-face ((t (:inherit red-face))))
 '(eshell-ls-executable-face ((t (:inherit green-face))))
 '(eshell-ls-missing-face ((t (:inherit normal-face))))
 '(eshell-ls-product-face ((t (:inherit normal-face))))
 '(eshell-ls-readonly-face ((t (:inherit normal-face))))
 '(eshell-ls-special-face ((t (:inherit normal-face))))
 '(eshell-ls-symlink-face ((t (:inherit purple-face))))
 '(eshell-ls-unreadable-face ((t (:inherit normal-face))))
 '(eshell-prompt-face ((t (:inherit normal-face))))
 '(font-lock-comment-face ((t (:inherit green-face))))
 '(font-lock-doc-face ((t (:inherit green-face))))
 '(font-lock-doc-string-face ((t (:inherit green-face))))
 '(font-lock-function-name-face ((t (:inherit blue-face))))
 '(font-lock-keyword-face ((t (:inherit purple-face))))
 '(font-lock-other-type-face ((t (:inherit purple-face))))
 '(font-lock-preprocessor-face ((t (:inherit purple-face))))
 '(font-lock-reference-face ((t (:inherit red-face))))
 '(font-lock-string-face ((t (:inherit green-face))))
 '(font-lock-type-face ((t (:inherit purple-face))))
 '(font-lock-variable-name-face ((t (:inherit blue-face))))
 '(font-lock-warning-face ((t (:inherit purple-face))))
 '(info-node ((t (:inherit blue-face))))
 '(info-xref ((t (:inherit blue-face))))
 '(italic ((t (:inherit normal-face))))
 '(woman-bold-face ((t (:inherit red-face))))
 '(woman-italic-face ((t (:inherit normal-face))))
 '(message-cited-text ((t (:inherit green-face))))
)

; Special faces
(my-set-faces
 '(cursor ((((background dark)) (:background "yellow")) 
    (((background light)) (:background "red"))))
 '(default ((t (:foreground "white" :background "black"))))
 '(highlight 
   ((((background light)) (:background "black" :foreground "darkseagreen2"))
        (((background dark)) (:background "darkseagreen2" :foreground 
"black"))))
 '(isearch 
   ((((background light)) (:background "paleturquoise" :foreground "black"))
        (((background dark)) (:background "yellow" :foreground "black"))))
 '(show-paren-match-face ((((class color)) 
    (:background "green" :foreground "black"))))
 '(show-paren-mismatch-face ((((class color)) (:background "red"))))
)



-- 
/-----------------------------------------------------------------------------*
|  "I can stand brute force, but brute reason is quite   |     Ivan Kanis     |
|  unbearable. There is something unfair about its use.  |  ivank@juliva.com  |
|  It is hitting below the intellect."                   |   www.juliva.com   |
|  (Oscar Wilde)                                         |                    |
*-----------------------------------------------------------------------------/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]