unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* copy-face seems to work only for current frame
@ 2004-01-27  7:51 Klaus Zeitler
  2004-01-27  9:13 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Klaus Zeitler @ 2004-01-27  7:51 UTC (permalink / raw)



Since I didn't like woman-bold-face I tried to change the face by adding:
(eval-after-load "woman"
  '(copy-face 'font-lock-builtin-face 'woman-bold-face))

This works fine as long as I open a manual in the same frame. But when
I open it (setting woman-use-own-frame to t) in a new frame, I have the old
face back.
I also played with the 3rd parameter of copy face (tried nil and t) but to
no avail.

How can I copy a face so that it'll stay the same for all existing and new
frames?

Thanks

Klaus


-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
"I don't think so," said René Descartes. Just then, he vanished

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27  7:51 copy-face seems to work only for current frame Klaus Zeitler
@ 2004-01-27  9:13 ` Eli Zaretskii
       [not found] ` <mailman.1431.1075194776.928.help-gnu-emacs@gnu.org>
  2004-01-27 20:07 ` Kevin Rodgers
  2 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2004-01-27  9:13 UTC (permalink / raw)


> From: Klaus Zeitler <kzeitler+usenet@gsm-mailhost.de.lucent.com>
> Newsgroups: gnu.emacs.help
> Date: 27 Jan 2004 08:51:59 +0100
> 
> Since I didn't like woman-bold-face I tried to change the face by adding:
> (eval-after-load "woman"
>   '(copy-face 'font-lock-builtin-face 'woman-bold-face))
> 
> This works fine as long as I open a manual in the same frame. But when
> I open it (setting woman-use-own-frame to t) in a new frame, I have the old
> face back.
> I also played with the 3rd parameter of copy face (tried nil and t) but to
> no avail.

I think the above fails because it is evaluated after _loading_
woman.elc, and at that point, the new frame where the WoMan buffer is
to be displayed does not yet exist.  The new WoMan frame is created
only when woman.elc's code _runs_, not when it is _loaded_.  So
copy-face indeed copies the face definition into all the existing
frames, but the WoMan frame is created only afterwards.

> How can I copy a face so that it'll stay the same for all existing and new
> frames?

Why don't you simply customize woman-bold-face?  That's what one is
supposed to do in such cases, you know ;-)

Alternatively, if you want to get fancy, run your code from
`woman-pre-format-hook'.  The WoMan docs explicitly says that this
hook is intended for things like face customizations...

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
       [not found] ` <mailman.1431.1075194776.928.help-gnu-emacs@gnu.org>
@ 2004-01-27 14:51   ` Klaus Zeitler
  2004-01-27 15:15     ` Stefan Monnier
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Klaus Zeitler @ 2004-01-27 14:51 UTC (permalink / raw)


>>>>> "Eli" == Eli Zaretskii <eliz@elta.co.il> writes:
    Eli> 
    Eli> I think the above fails because it is evaluated after _loading_
    Eli> woman.elc, and at that point, the new frame where the WoMan buffer is
    Eli> to be displayed does not yet exist.  The new WoMan frame is created
    Eli> only when woman.elc's code _runs_, not when it is _loaded_.  So
    Eli> copy-face indeed copies the face definition into all the existing
    Eli> frames, but the WoMan frame is created only afterwards.

I don't understand this. I thought woman.el creates (via defface) the face
woman-bold-face as soon as it gets loaded, then eval-after-load
copies another face into woman-bold-face and that should be it.
And I was so naive to think that this face would be used now in new
frames too. Why not? From the documentation of copy-face I don't see
why this doesn't do it.

    Eli> Why don't you simply customize woman-bold-face?  That's what one is
    Eli> supposed to do in such cases, you know ;-)

Mostly habit I guess and then I have hundreds of autoloads and
eval-after-loads in my .emacs.el. And I have them where and when I want them
whereas customize keeps everything intermingled together and executes
everything when I start emacs.
But I don't want to start a discussion about customize, it's certainly
a good thing to have and (since about half a year) I've started to use it
every once in a while.

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
The average income of the modern teenager is about 2AM.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27 14:51   ` Klaus Zeitler
@ 2004-01-27 15:15     ` Stefan Monnier
  2004-01-28  9:41       ` Klaus Zeitler
  2004-01-27 20:27     ` Eli Zaretskii
       [not found]     ` <mailman.1467.1075235771.928.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2004-01-27 15:15 UTC (permalink / raw)


> Why not? From the documentation of copy-face I don't see
> why this doesn't do it.

Because defface support includes some code directly in the C code that sets
up the face for each and every new frame since the way defface works you can
set your faces differently on different frames (e.g. if you use
make-frame-on-display).

> But I don't want to start a discussion about customize, it's certainly
> a good thing to have and (since about half a year) I've started to use it
> every once in a while.

Given the way defface works, the best way to changes such faces is
via customize.  And I can assure you that I do try to avoid using customize.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27  7:51 copy-face seems to work only for current frame Klaus Zeitler
  2004-01-27  9:13 ` Eli Zaretskii
       [not found] ` <mailman.1431.1075194776.928.help-gnu-emacs@gnu.org>
@ 2004-01-27 20:07 ` Kevin Rodgers
  2004-01-28  9:48   ` Klaus Zeitler
  2 siblings, 1 reply; 12+ messages in thread
From: Kevin Rodgers @ 2004-01-27 20:07 UTC (permalink / raw)


Klaus Zeitler wrote:

> Since I didn't like woman-bold-face I tried to change the face by adding:
> (eval-after-load "woman"
>   '(copy-face 'font-lock-builtin-face 'woman-bold-face))
> 
> This works fine as long as I open a manual in the same frame. But when
> I open it (setting woman-use-own-frame to t) in a new frame, I have the old
> face back.
> I also played with the 3rd parameter of copy face (tried nil and t) but to
> no avail.
> 
> How can I copy a face so that it'll stay the same for all existing and new
> frames?


Does this work (before loading woman.el)?

(defface woman-bold-face
   '((t (:inherit font-lock-builtin-face))))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27 14:51   ` Klaus Zeitler
  2004-01-27 15:15     ` Stefan Monnier
@ 2004-01-27 20:27     ` Eli Zaretskii
       [not found]     ` <mailman.1467.1075235771.928.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2004-01-27 20:27 UTC (permalink / raw)


> From: Klaus Zeitler <kzeitler+usenet@gsm-mailhost.de.lucent.com>
> Newsgroups: gnu.emacs.help
> Date: 27 Jan 2004 15:51:59 +0100
> 
> I don't understand this. I thought woman.el creates (via defface) the face
> woman-bold-face as soon as it gets loaded, then eval-after-load
> copies another face into woman-bold-face and that should be it.

defface does indeed run at load time, but the face copying is not a
magic wand: it can only copy into the face definitions of those frames
it finds in the value returned by (frame-list).  And the new frame is
not there yet.  Look at the code of copy-face, and you will see it.

> And I was so naive to think that this face would be used now in new
> frames too. Why not?

Because faces in Emacs are frame-local by design.  Changing face
definitions on one frame doesn't propagate them to other frames,
unless some code walks the frame list and does that.  copy-face indeed
does this walking, but it cannot do it for non-existing frames.

>     Eli> Why don't you simply customize woman-bold-face?  That's what one is
>     Eli> supposed to do in such cases, you know ;-)
> 
> Mostly habit I guess

A bad habit, I must say ;-)

You don't need to actually do it via M-x customize-face if you don't
like, simply use set-face-foreground etc. for woman-bold-face.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27 15:15     ` Stefan Monnier
@ 2004-01-28  9:41       ` Klaus Zeitler
  0 siblings, 0 replies; 12+ messages in thread
From: Klaus Zeitler @ 2004-01-28  9:41 UTC (permalink / raw)


>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
    Stefan> 
    Stefan> Given the way defface works, the best way to changes such faces is
    Stefan> via customize.  And I can assure you that I do try to avoid using
    Stefan> customize.

Thanks for the explanation. I've now added 
 '(woman-bold-face ((t (:inherit font-lock-builtin-face))))
to custom-set-faces.

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
There are two ways of constructing a software design: One way is to make it so
simple that there are obviously no deficiencies, and the other way is to make
it so complicated that there are no obvious deficiencies.    -- C. A. R. Hoare

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-27 20:07 ` Kevin Rodgers
@ 2004-01-28  9:48   ` Klaus Zeitler
  0 siblings, 0 replies; 12+ messages in thread
From: Klaus Zeitler @ 2004-01-28  9:48 UTC (permalink / raw)


>>>>> "Kevin" == Kevin Rodgers <ihs_4664@yahoo.com> writes:
    Kevin> 
    Kevin> Does this work (before loading woman.el)?
    Kevin> 
    Kevin> (defface woman-bold-face
    Kevin>    '((t (:inherit font-lock-builtin-face))))

Nearly, in CVS emacs I needed to add a doc string to make the byte compiler
happy. Now I need to add this to an eval-before-load :-).

BTW '((t (:inherit font-lock-builtin-face)))
is exactly what I added to custom-set-faces yesterday.

Thanks

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
When I get real bored, I like to drive downtown and get
a great parking spot, then sit in my car and count how
many people ask me if I'm leaving.     -- Steven Wright

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
       [not found]     ` <mailman.1467.1075235771.928.help-gnu-emacs@gnu.org>
@ 2004-01-28 10:27       ` Klaus Zeitler
  2004-01-28 14:00         ` Eli Zaretskii
       [not found]       ` <mailman.1503.1075298800.928.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 12+ messages in thread
From: Klaus Zeitler @ 2004-01-28 10:27 UTC (permalink / raw)


>>>>> "Eli" == Eli Zaretskii <eliz@fencepost.gnu.org> writes:
    Eli> 
    Eli> You don't need to actually do it via M-x customize-face if you don't
    Eli> like, simply use set-face-foreground etc. for woman-bold-face.

Do I understand this right? You say set-face-background and similar functions
change the face definition, whereas copy-face only changes the frame local
definitions? I always thought that something like set-face-background
changes part of a face and copy face changes the whole thing.
I've now changed my code to using customize.
But as they say: inquiring minds want to know :-)

Thanks

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
 ------------------------------------------
---
A city is a large community where people are
lonesome together        -- Herbert Prochnow

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-28 10:27       ` Klaus Zeitler
@ 2004-01-28 14:00         ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2004-01-28 14:00 UTC (permalink / raw)


> Do I understand this right? You say set-face-background and similar functions
> change the face definition, whereas copy-face only changes the frame local
> definitions?

Yes.  By default, set-face-background and its ilk change the face
definitions for all the frames that exist, and also change the
defaults for new frames.  To make the face changes only on the current
frame, you need to use the optional argument FRAME.  See the doc
string of set-face-background.

copy-face can modify the face on all existing frames, but AFAICS it
cannot change the face definitions to be used for future frames.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
       [not found]       ` <mailman.1503.1075298800.928.help-gnu-emacs@gnu.org>
@ 2004-01-28 15:07         ` Stefan Monnier
  2004-01-29  6:48           ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2004-01-28 15:07 UTC (permalink / raw)


> copy-face can modify the face on all existing frames, but AFAICS it
> cannot change the face definitions to be used for future frames.

This faces business is still pretty messy.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: copy-face seems to work only for current frame
  2004-01-28 15:07         ` Stefan Monnier
@ 2004-01-29  6:48           ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2004-01-29  6:48 UTC (permalink / raw)


> Newsgroups: gnu.emacs.help
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Wed, 28 Jan 2004 15:07:41 GMT
> 
> > copy-face can modify the face on all existing frames, but AFAICS it
> > cannot change the face definitions to be used for future frames.
> 
> This faces business is still pretty messy.

That's the understatement of the century ;-)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-01-29  6:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-27  7:51 copy-face seems to work only for current frame Klaus Zeitler
2004-01-27  9:13 ` Eli Zaretskii
     [not found] ` <mailman.1431.1075194776.928.help-gnu-emacs@gnu.org>
2004-01-27 14:51   ` Klaus Zeitler
2004-01-27 15:15     ` Stefan Monnier
2004-01-28  9:41       ` Klaus Zeitler
2004-01-27 20:27     ` Eli Zaretskii
     [not found]     ` <mailman.1467.1075235771.928.help-gnu-emacs@gnu.org>
2004-01-28 10:27       ` Klaus Zeitler
2004-01-28 14:00         ` Eli Zaretskii
     [not found]       ` <mailman.1503.1075298800.928.help-gnu-emacs@gnu.org>
2004-01-28 15:07         ` Stefan Monnier
2004-01-29  6:48           ` Eli Zaretskii
2004-01-27 20:07 ` Kevin Rodgers
2004-01-28  9:48   ` Klaus Zeitler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).