emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.50; face-problems with multy-tty


From: Richard Stallman
Subject: Re: 23.0.50; face-problems with multy-tty
Date: Tue, 25 Sep 2007 06:44:53 -0400

    It wasn't an example of a real init file. The case I'm worried about is
    when you want to reset the faces from the init file with `C-x C-e' on
    the custom-set-faces form (or by loading the file).

I see why that might be useful, but I am not sure we can expect it to
work.  This is overconstrained.

     The
    problem is that that doesn't distinguish between different kinds of
    frames. Now custom-set-faces sets the attributes per frame (via
    face-spec-set), but it needs to clear the new-frame defaults too.

Does this definition give good results?  This clears the new-frame
defaults for ALL attributes, which seems like the right thing in
principle, but it may not work well in all cases.


(defun face-spec-set (face spec &optional frame)
  "Set FACE's attributes according to the first matching entry in SPEC.
FRAME is the frame whose frame-local face is set.  FRAME nil means
do it on all frames.  See `defface' for information about SPEC.
If SPEC is nil, do nothing."
  (let ((attrs (face-spec-choose spec frame)))
        (when spec
          (face-spec-reset-face face frame))
        (while attrs
          (let ((attribute (car attrs))
                (value (car (cdr attrs))))
            ;; Support some old-style attribute names and values.
            (case attribute
              (:bold (setq attribute :weight value (if value 'bold 'normal)))
              (:italic (setq attribute :slant value (if value 'italic 'normal)))
              ((:foreground :background)
               ;; Compatibility with 20.x.  Some bogus face specs seem to
               ;; exist containing things like `:foreground nil'.
               (if (null value) (setq value 'unspecified)))
              (t (unless (assq attribute face-x-resources)
                   (setq attribute nil))))
            (when attribute
              (set-face-attribute face frame attribute value)))
          (setq attrs (cdr (cdr attrs)))))
    ;; When we reset the face based on its spec, then it is unmodified
    ;; as far as Custom is concerned.
    (put (or (get face 'face-alias) face) 'face-modified nil)
    ;; Clear all the new-frame defaults for this face.
    (dolist (attribute '(:family :width :height :weight :slant :foreground
                         :background :underline :overline :strike-through
                         :box :inverse-video))
      (set-face-attribute face nil attribute nil))
    ;; Set each frame according to the rules implied by SPEC.
    (dolist (frame (frame-list))
      (face-spec-set face spec frame)))




reply via email to

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