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: Steven L.
Subject: Re: how to save a face in Lisp?
Date: Wed, 03 Oct 2007 00:24:02 -0400
User-agent: Thunderbird 1.5.0.13 (Windows/20070809)

Drew Adams wrote:
In Lisp, how can I save a face to the user's custom-file after
it has been changed (or to cause it to be saved when Emacs is quit)?
The function custom-set-faces works for me.

It requires the face's SPEC also as input:

  "The arguments should be a list where each entry has the form:
    (FACE SPEC [NOW [COMMENT]])
   SPEC is stored as the saved value for FACE..."

I'm looking for something that takes just the face as arg and saves it. IOW,
I don't want to define the face; I just want to save it.

You don't have to define the face manually. But you have to write Elisp code to find the current values of the attributes of an existing face, and write those values to a custom-file which can be read back the next time you start Emacs.

Example:  If you execute the following in a Lisp-Interaction buffer:
(describe-face 'default)
you will see all the default face's attributes whose *current* values you have to save to a file: :family, :width, :height, :slant, :foreground, :background, etc.

A function to inspect each attribute in turn is called 'face-attribute

So again, for the default face, you can get each value:

(face-attribute 'default :family)

(face-attribute 'default :height)

(face-attribute 'default :background)

And so on. Get the value of each attribute of the face you're interested in, and then write those values to a file and you can read them back in at any time.


--
Steven L.
Email:  sdlitvin@earthlinkNOSPAM.net
Remove the NOSPAM before replying to me.





reply via email to

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