all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Default font 'default have no corresponding variable
@ 2008-02-18 13:18 Lennart Borgman (gmail)
  2008-02-18 13:20 ` Lennart Borgman (gmail)
  2008-02-18 13:32 ` Miles Bader
  0 siblings, 2 replies; 14+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-18 13:18 UTC (permalink / raw)
  To: Emacs Devel

Should it not have that? I think I have some something like this in 
several places

  ;; I believe default is defined in Xemacs but not in GNU Emacs.
  (unless (boundp 'default)
    (defvar default 'default))




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 13:18 Default font 'default have no corresponding variable Lennart Borgman (gmail)
@ 2008-02-18 13:20 ` Lennart Borgman (gmail)
  2008-02-18 13:25   ` Jason Rumney
  2008-02-18 13:32 ` Miles Bader
  1 sibling, 1 reply; 14+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-18 13:20 UTC (permalink / raw)
  To: Emacs Devel

Lennart Borgman (gmail) wrote:
> Should it not have that? I think I have some something like this in 
> several places
> 
>  ;; I believe default is defined in Xemacs but not in GNU Emacs.
>  (unless (boundp 'default)
>    (defvar default 'default))

Eh, default face, not default font.




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 13:20 ` Lennart Borgman (gmail)
@ 2008-02-18 13:25   ` Jason Rumney
  2008-02-18 16:12     ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Rumney @ 2008-02-18 13:25 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

Lennart Borgman (gmail) wrote:
> Lennart Borgman (gmail) wrote:
>> Should it not have that? I think I have some something like this in 
>> several places
>>
>>  ;; I believe default is defined in Xemacs but not in GNU Emacs.
>>  (unless (boundp 'default)
>>    (defvar default 'default))
>
> Eh, default face, not default font.

If you want to know if there is a face called default, you should use 
facep, not boundp.

Why would you need a variable of that name?




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 13:18 Default font 'default have no corresponding variable Lennart Borgman (gmail)
  2008-02-18 13:20 ` Lennart Borgman (gmail)
@ 2008-02-18 13:32 ` Miles Bader
  2008-02-18 15:59   ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 14+ messages in thread
From: Miles Bader @ 2008-02-18 13:32 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

Why should there be a "corresponding variable"?

-MIles

-- 
=====
(^o^;
(()))
*This is the cute octopus virus, please copy it into your sig so it can spread.




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 13:32 ` Miles Bader
@ 2008-02-18 15:59   ` Lennart Borgman (gmail)
  2008-02-18 16:37     ` Jason Rumney
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-18 15:59 UTC (permalink / raw)
  To: Miles Bader; +Cc: Emacs Devel

Miles Bader wrote:
> Why should there be a "corresponding variable"?

Maybe I got this wrong, I thought that there usually were a variable 
with the same name as the face and that the variable value was the face 
symbol. But maybe that is just used for faces defined specific uses in 
emacs libraries?

But anyway, as I wrote, libraries written for Xemacs often tends to 
assume that the variable default exist (and points to a face symbol I 
believe).




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 13:25   ` Jason Rumney
@ 2008-02-18 16:12     ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 14+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-18 16:12 UTC (permalink / raw)
  To: Jason Rumney; +Cc: Emacs Devel

Jason Rumney wrote:
> Lennart Borgman (gmail) wrote:
>> Lennart Borgman (gmail) wrote:
>>> Should it not have that? I think I have some something like this in 
>>> several places
>>>
>>>  ;; I believe default is defined in Xemacs but not in GNU Emacs.
>>>  (unless (boundp 'default)
>>>    (defvar default 'default))
>>
>> Eh, default face, not default font.
> 
> If you want to know if there is a face called default, you should use 
> facep, not boundp.

But here I am looking for the variable.

> Why would you need a variable of that name?

I am started to wonder if I have misunderstood something. Maybe there is 
no variable default with value 'default in Xemacs? But please see my 
answer to Miles.




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 15:59   ` Lennart Borgman (gmail)
@ 2008-02-18 16:37     ` Jason Rumney
  2008-02-18 16:48     ` Stefan Monnier
  2008-02-19 11:59     ` Richard Stallman
  2 siblings, 0 replies; 14+ messages in thread
From: Jason Rumney @ 2008-02-18 16:37 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel, Miles Bader

Lennart Borgman (gmail) wrote:
> Miles Bader wrote:
>> Why should there be a "corresponding variable"?
>
> Maybe I got this wrong, I thought that there usually were a variable 
> with the same name as the face and that the variable value was the 
> face symbol. But maybe that is just used for faces defined specific 
> uses in emacs libraries?
No. For historical reasons that is the case for font-lock-*-face, and 
many developers of external packages copy that pattern without 
understanding why.

My understanding is that before customize-face existed, it was much 
easier to create a new face than to modify an existing one. So font-lock 
was designed with redirection via a variable to allow the standard faces 
to be swapped out.

> But anyway, as I wrote, libraries written for Xemacs often tends to 
> assume that the variable default exist (and points to a face symbol I 
> believe).

No, you didn't write that as far as I can see.





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

* Re: Default font 'default have no corresponding variable
  2008-02-18 15:59   ` Lennart Borgman (gmail)
  2008-02-18 16:37     ` Jason Rumney
@ 2008-02-18 16:48     ` Stefan Monnier
  2008-02-18 20:37       ` Johan Bockgård
  2008-02-18 22:14       ` Lennart Borgman (gmail)
  2008-02-19 11:59     ` Richard Stallman
  2 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2008-02-18 16:48 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel, Miles Bader

>> Why should there be a "corresponding variable"?

> Maybe I got this wrong, I thought that there usually were a variable with
> the same name as the face and that the variable value was the face
> symbol. But maybe that is just used for faces defined specific uses in
> Emacs libraries?

No.  The only there is w.r.t vars and faces is that font-lock's author
originally decided to provide both font-lock-FOO-face faces and
font-lock-FOO-face variables where the variable's value points to the
face, so that you can use

      font-lock-FOO-face
or
      'font-lock-FOO-face

and get the same result.  Basically it makes the font-lock-FOO-face
symbol (used to refer to the face) self-quoting.  And since most
font-lock rules use the first form rather than the second, you get the
added benefit that the extra-indirection through the variable can be
made buffer-local so you can "change faces" on a buffer-by-buffer basis
(which is usually not possible in Emacs where faces can only be changed
on a frame-by-frame basis).

In any case, buffer-local faces should be added to Emacs (there are
plans to do that, although they don't seem to be going anywhere, sadly),
and variables pointing to faces are generally deprecated unless maybe
they're used in font-lock rules where avoiding the ' can be
marginally convenient.

> But anyway, as I wrote, libraries written for XEmacs often tends to assume
> that the variable default exist (and points to a face symbol I believe).

`xemacs -q' tells me that `default' indeed exists but has value "void".
Not sure what that means.  It seems not to have any equivalent in Emacs.
I'd never heard of it until now, so it can't be that used "often".


        Stefan




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 16:48     ` Stefan Monnier
@ 2008-02-18 20:37       ` Johan Bockgård
  2008-02-18 21:13         ` Stefan Monnier
  2008-02-18 22:14       ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 14+ messages in thread
From: Johan Bockgård @ 2008-02-18 20:37 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> `xemacs -q' tells me that `default' indeed exists but has value "void".
> Not sure what that means.

Dynamic scoping.

-- 
Johan Bockgård





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

* Re: Default font 'default have no corresponding variable
  2008-02-18 20:37       ` Johan Bockgård
@ 2008-02-18 21:13         ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2008-02-18 21:13 UTC (permalink / raw)
  To: emacs-devel

>> `xemacs -q' tells me that `default' indeed exists but has value "void".
>> Not sure what that means.

> Dynamic scoping.

Good catch ;-)


        Stefan





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

* Re: Default font 'default have no corresponding variable
  2008-02-18 16:48     ` Stefan Monnier
  2008-02-18 20:37       ` Johan Bockgård
@ 2008-02-18 22:14       ` Lennart Borgman (gmail)
  1 sibling, 0 replies; 14+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-18 22:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel, Jason Rumney

Stefan Monnier wrote:
>>> Why should there be a "corresponding variable"?
> 
>> Maybe I got this wrong, I thought that there usually were a variable with
>> the same name as the face and that the variable value was the face
>> symbol. But maybe that is just used for faces defined specific uses in
>> Emacs libraries?
> 
> No.  The only there is w.r.t vars and faces is that font-lock's author
> originally decided to provide both font-lock-FOO-face faces and
> font-lock-FOO-face variables where the variable's value points to the
> face, so that you can use
> 
>       font-lock-FOO-face
> or
>       'font-lock-FOO-face
> 
> and get the same result.  Basically it makes the font-lock-FOO-face
> symbol (used to refer to the face) self-quoting.  And since most
> font-lock rules use the first form rather than the second, you get the
> added benefit that the extra-indirection through the variable can be
> made buffer-local so you can "change faces" on a buffer-by-buffer basis
> (which is usually not possible in Emacs where faces can only be changed
> on a frame-by-frame basis).
> 
> In any case, buffer-local faces should be added to Emacs (there are
> plans to do that, although they don't seem to be going anywhere, sadly),
> and variables pointing to faces are generally deprecated unless maybe
> they're used in font-lock rules where avoiding the ' can be
> marginally convenient.


Thanks Stefan and Jason,

It seems like I have been misunderstanding this a bit more than I 
usually do ;-)

Unfortunately I have been spreading my unwisdom a bit so I have to clear 
that out.

>> But anyway, as I wrote, libraries written for XEmacs often tends to assume
>> that the variable default exist (and points to a face symbol I believe).
> 
> `xemacs -q' tells me that `default' indeed exists but has value "void".
> Not sure what that means.  It seems not to have any equivalent in Emacs.
> I'd never heard of it until now, so it can't be that used "often".
> 
> 
>         Stefan
> 




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

* Re: Default font 'default have no corresponding variable
  2008-02-18 15:59   ` Lennart Borgman (gmail)
  2008-02-18 16:37     ` Jason Rumney
  2008-02-18 16:48     ` Stefan Monnier
@ 2008-02-19 11:59     ` Richard Stallman
  2008-02-20  3:51       ` Drew Adams
  2 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2008-02-19 11:59 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel, miles

    Maybe I got this wrong, I thought that there usually were a variable 
    with the same name as the face and that the variable value was the face 
    symbol. But maybe that is just used for faces defined specific uses in 
    emacs libraries?

Maybe we should work harder to document the fact that we do not want
such variables.  Where would such info have reached you better?

How about if we put comments in and among the variable definitions in
font-lock.el saying not to imitate that practice.




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

* RE: Default font 'default have no corresponding variable
  2008-02-19 11:59     ` Richard Stallman
@ 2008-02-20  3:51       ` Drew Adams
  2008-02-20 16:44         ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2008-02-20  3:51 UTC (permalink / raw)
  To: rms, 'Lennart Borgman (gmail)'; +Cc: miles, emacs-devel

> Maybe we should work harder to document the fact that we do not want
> such variables.  Where would such info have reached you better?
> 
> How about if we put comments in and among the variable definitions in
> font-lock.el saying not to imitate that practice.

I think the place to discuss this is in the Elisp manual, in one of the
sections about faces. This is really about understanding what a face is,
IMO.

FWIW, I have a slightly different take on the practice to recommend and the
reasons to give for that recommendation. 

I agree with the recommended practice of defining and using faces, not face
variables, in general - and I follow it. However, I don't agree that the
only case for defining and using face variables is the legacy case of the
font-lock code. 

The use case I see, which, again, is not the usual case, is when you want to
make it easy for code to temporarily use a particular face. It is very easy
for some code to dynamically bind a face variable and cause subsequently
executed code to use that face. Getting the same effect with faces (without
a face variable) can make for uglier code, IMO.

Just one opinion. I'm not interested in arguing about that. I agree that we
should make it clear that you generally should not define face variables.
And I think the place to communicate that guideline is the Elisp doc, not
just comments in the code.





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

* Re: Default font 'default have no corresponding variable
  2008-02-20  3:51       ` Drew Adams
@ 2008-02-20 16:44         ` Richard Stallman
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2008-02-20 16:44 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel, lennart.borgman, miles

    The use case I see, which, again, is not the usual case, is when you want to
    make it easy for code to temporarily use a particular face. It is very easy
    for some code to dynamically bind a face variable and cause subsequently
    executed code to use that face. Getting the same effect with faces (without
    a face variable) can make for uglier code, IMO.

I agree that this would be a good reason to have such a variable.
Whether there are such cases, I don't know.




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

end of thread, other threads:[~2008-02-20 16:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 13:18 Default font 'default have no corresponding variable Lennart Borgman (gmail)
2008-02-18 13:20 ` Lennart Borgman (gmail)
2008-02-18 13:25   ` Jason Rumney
2008-02-18 16:12     ` Lennart Borgman (gmail)
2008-02-18 13:32 ` Miles Bader
2008-02-18 15:59   ` Lennart Borgman (gmail)
2008-02-18 16:37     ` Jason Rumney
2008-02-18 16:48     ` Stefan Monnier
2008-02-18 20:37       ` Johan Bockgård
2008-02-18 21:13         ` Stefan Monnier
2008-02-18 22:14       ` Lennart Borgman (gmail)
2008-02-19 11:59     ` Richard Stallman
2008-02-20  3:51       ` Drew Adams
2008-02-20 16:44         ` Richard Stallman

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.