all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@gnu.org>
To: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: 13278-done@debbugs.gnu.org
Subject: bug#13278: 24.3.50; Attributes aren't inherited in a copied face across frames
Date: Mon, 31 Dec 2012 12:03:15 +0800	[thread overview]
Message-ID: <87fw2mvpfg.fsf@gnu.org> (raw)
In-Reply-To: <b4md2xr13fk.fsf@jpl.org> (Katsumi Yamaoka's message of "Mon, 31 Dec 2012 09:16:31 +0900")

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>> May I ask why you are trying to use `copy-face' instead of `defface'?
>
> I've been using it conveniently since the face feature was introduced
> in Emacs.  For example, it's handy when I want a face of which only
> the color differs from the built-in one:
>
> (copy-face 'bold 'orange-bold)
> (set-face-foreground 'orange-bold "Orange")
>
> Of course doing it by defface is not so troublesome, so I can live
> without copy-face.

Here's the basic issue: `copy-face' acts on internal faces (and always
has, IIRC).  Internal faces are vectors of face attributes, which are
stored by Emacs in `face-new-frame-defaults' and in per-frame alists.
The key point is that the face spec, which is specified by `defface', is
separate from this.  Since `defface' is used for practically all Emacs
faces, the internal faces stored in `face-new-frame-defaults' are
usually empty.  The purpose of `face-new-frame-defaults' is to keep
track of the "overriding attributes", for when the user calls
`set-face-attribute', `set-face-foreground', etc.

What `copy-face' does is to create a new entry for the face copy in
`face-new-frame-defaults'; it doesn't touch the face spec (customization
data).  When you create a new frame, Emacs combines
`face-new-frame-defaults' with the face spec from the face's
customization data.  So a face created with `copy-face', lacking that
customization data, would have a blank appearance.

Note also that `face-new-frame-defaults' overrides the customization
data, so this mechanism inherently doesn't play well with Custom themes.
That's one reason the direct setting of internal faces is
downplayed/deprecated these days: it can lead to surprising effects for
people who don't know what they're doing.

Of course, we could make `copy-face' copy the customization data as
well, if that is more useful.  But this would be a backward incompatible
change, and I would have to think about whether it would screw anything
up.





      parent reply	other threads:[~2012-12-31  4:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26  1:56 bug#13278: 24.3.50; Attributes aren't inherited in a copied face across frames Katsumi Yamaoka
2012-12-26 19:43 ` Glenn Morris
2012-12-30  1:28   ` Katsumi Yamaoka
2012-12-30  3:13     ` Chong Yidong
2012-12-31  0:16       ` Katsumi Yamaoka
2012-12-31  3:14         ` Drew Adams
2012-12-31  4:03         ` Chong Yidong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fw2mvpfg.fsf@gnu.org \
    --to=cyd@gnu.org \
    --cc=13278-done@debbugs.gnu.org \
    --cc=yamaoka@jpl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.