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

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

RE: how to save a face in Lisp?


From: Drew Adams
Subject: RE: how to save a face in Lisp?
Date: Wed, 3 Oct 2007 07:55:16 -0700

> > For example, suppose this is the definition of face `foo':
> >
> > (defface foo
> >     '((((background dark)) (:foreground "DarkGreen"))
> >       (t (:foreground "Red")))
> >   "...")
> >
> > And suppose this has been evaluated, temporarily "customizing" the face
> > outside of Customize:
> >
> > (set-face-attribute 'foo nil :foreground "Yellow")
> >
> > And suppose that the background mode is not `dark'. Then the 
> > spec that needs to be written if this face is saved is this:
> >
> >  '((((background dark)) (:foreground "DarkGreen"))
> >    (t (:foreground "Yellow")))
> 
> (set-face-attribute FACE nil ...) overrides all other settings of FACE,
> so I don't think the `(background dark)' part should be saved.

Regardless of the fact that `set-face-attribute' does that for the current 
session, I want the effect to be exactly what it would be "if the face had been 
modified by the user in Customize and saved by the user in Customize."

But perhaps even in the latter case only the equivalent of the 
`set-face-attribute' effect is saved, not the whole (updated) spec. I was 
thinking that what was in the custom file was a complete defface spec that 
covers all background modes that were defined in the original defface spec, but 
it looks like it is just the part of that spec that the user actually 
customized.

However, it does include the entire alist entry (DISPLAY ATTS), not just ATTS. 
Here, for example, is a spec from my `custom-file':

 '(link ((((class color) (min-colors 88) (background light))
           (:foreground "blue1"))))

`face-attr-construct' gives me only ATTS. In this case, it would give me only 
(:foreground "blue1").

Depending on what the ATTS are, it would be possible to look up the 
corresponding DISPLAY in `face-user-default-spec'. Or I could try to construct 
DISPLAY from the current background mode and terminal type (color support 
etc.), but there is no way, without consulting the spec from 
`face-user-default-spec', to know whether DISPLAY should be `t' or, say, 
((class color) (min-colors 88) (background light)).

I'm surprised that customizing in a currently light-background session would 
lose any dark-background information for the customized face. That doesn't seem 
right. You might want to use the same custom-file in different settings, with 
different background modes.






reply via email to

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