* defface/defcustom question @ 2003-08-08 22:15 Jesper Harder 2003-08-09 1:54 ` Simon Josefsson 0 siblings, 1 reply; 16+ messages in thread From: Jesper Harder @ 2003-08-08 22:15 UTC (permalink / raw) In some places Gnus faces are defined both with `defface' _and_ `defcustom'. E.g. ,---- | (defface gnus-server-opened-face | '((((class color) (background light)) (:foreground "Green3" :bold t)) | (((class color) (background dark)) (:foreground "Green1" :bold t)) | (t (:bold t))) | "Face used for displaying OPENED servers" | :group 'gnus-server-visual) | | [...] | | (defcustom gnus-server-opened-face 'gnus-server-opened-face | "Face name to use on OPENED servers." | :group 'gnus-server-visual | :type 'face) `---- This means that the face shows up twice when you use Customize. It looks like a mistake to me ... or is there a reason for doing it? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-08 22:15 defface/defcustom question Jesper Harder @ 2003-08-09 1:54 ` Simon Josefsson 2003-08-09 9:55 ` Kai Großjohann 0 siblings, 1 reply; 16+ messages in thread From: Simon Josefsson @ 2003-08-09 1:54 UTC (permalink / raw) Jesper Harder <harder@myrealbox.com> writes: > In some places Gnus faces are defined both with `defface' _and_ > `defcustom'. E.g. > > ,---- > | (defface gnus-server-opened-face > | '((((class color) (background light)) (:foreground "Green3" :bold t)) > | (((class color) (background dark)) (:foreground "Green1" :bold t)) > | (t (:bold t))) > | "Face used for displaying OPENED servers" > | :group 'gnus-server-visual) > | > | [...] > | > | (defcustom gnus-server-opened-face 'gnus-server-opened-face > | "Face name to use on OPENED servers." > | :group 'gnus-server-visual > | :type 'face) > `---- > > This means that the face shows up twice when you use Customize. It > looks like a mistake to me ... or is there a reason for doing it? Aren't variables and faces different things? The variable identifies the name of the face to use, and the face define the actual face. An extra indirection. Compare the ':type face' documentation: `face' The value must be a symbol which is a face name, and you can do completion with `M-<TAB>'. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 1:54 ` Simon Josefsson @ 2003-08-09 9:55 ` Kai Großjohann 2003-08-09 11:32 ` Simon Josefsson 0 siblings, 1 reply; 16+ messages in thread From: Kai Großjohann @ 2003-08-09 9:55 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > Aren't variables and faces different things? The variable identifies > the name of the face to use, and the face define the actual face. An > extra indirection. One might ask: why the indirection? Maybe one part of the answer is that variables can be buffer-local, whereas faces, afaik, can't. -- Two cafe au lait please, but without milk. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 9:55 ` Kai Großjohann @ 2003-08-09 11:32 ` Simon Josefsson 2003-08-09 13:13 ` Kai Großjohann 0 siblings, 1 reply; 16+ messages in thread From: Simon Josefsson @ 2003-08-09 11:32 UTC (permalink / raw) kai.grossjohann@gmx.net (Kai Großjohann) writes: > Simon Josefsson <jas@extundo.com> writes: > >> Aren't variables and faces different things? The variable identifies >> the name of the face to use, and the face define the actual face. An >> extra indirection. > > One might ask: why the indirection? Maybe one part of the answer is > that variables can be buffer-local, whereas faces, afaik, can't. It also makes it possible to express "use the same face for this, that and this" and then later be able to change the face only once to change it in all places. And it simplifies font-lock stuff, compare gnus-server-font-lock-keywords. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 11:32 ` Simon Josefsson @ 2003-08-09 13:13 ` Kai Großjohann 2003-08-09 15:45 ` Simon Josefsson 0 siblings, 1 reply; 16+ messages in thread From: Kai Großjohann @ 2003-08-09 13:13 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > It also makes it possible to express "use the same face for this, that > and this" and then later be able to change the face only once to > change it in all places. But that's possible with regular faces already? Just use the same symbol (face name) in all those places? > And it simplifies font-lock stuff, compare > gnus-server-font-lock-keywords. I looked at it. It looks simple. But I can't see how variables made it simpler. -- Two cafe au lait please, but without milk. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 13:13 ` Kai Großjohann @ 2003-08-09 15:45 ` Simon Josefsson 2003-08-09 16:43 ` Jesper Harder ` (2 more replies) 0 siblings, 3 replies; 16+ messages in thread From: Simon Josefsson @ 2003-08-09 15:45 UTC (permalink / raw) kai.grossjohann@gmx.net (Kai Großjohann) writes: > Simon Josefsson <jas@extundo.com> writes: > >> It also makes it possible to express "use the same face for this, that >> and this" and then later be able to change the face only once to >> change it in all places. > > But that's possible with regular faces already? Just use the same > symbol (face name) in all those places? You mean changing gnus source? I meant for users. >> And it simplifies font-lock stuff, compare >> gnus-server-font-lock-keywords. > > I looked at it. It looks simple. But I can't see how variables made > it simpler. font-lock-keywords uses face names, not faces. Compare info://Elisp/Faces%20for%20Font%20Lock ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 15:45 ` Simon Josefsson @ 2003-08-09 16:43 ` Jesper Harder 2003-08-09 17:16 ` Alan Shutko 2003-08-10 20:33 ` Kai Großjohann 2 siblings, 0 replies; 16+ messages in thread From: Jesper Harder @ 2003-08-09 16:43 UTC (permalink / raw) [-- Attachment #1: Type: text/plain, Size: 1069 bytes --] Simon Josefsson <jas@extundo.com> writes: > kai.grossjohann@gmx.net (Kai Großjohann) writes: > >> Simon Josefsson <jas@extundo.com> writes: >> >>> It also makes it possible to express "use the same face for this, that >>> and this" and then later be able to change the face only once to >>> change it in all places. >> >> But that's possible with regular faces already? Just use the same >> symbol (face name) in all those places? > > You mean changing gnus source? I meant for users. I think it's harder to understand for users. It's confusing to have two customization options with the same name (and very similar purpose). >>> And it simplifies font-lock stuff, compare >>> gnus-server-font-lock-keywords. >> >> I looked at it. It looks simple. But I can't see how variables made >> it simpler. > > font-lock-keywords uses face names, not faces. Compare > info://Elisp/Faces%20for%20Font%20Lock I don't see your point. This just means that you need to quote the name of the face -- I thinks that's a lot simpler than an extra layer of indirection. E.g. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: gnus-srvr.el.diff --] [-- Type: text/x-patch, Size: 1598 bytes --] --- gnus/lisp/gnus-srvr.el Tue Jun 24 07:22:43 2003 +++ cvsgnus/lisp/gnus-srvr.el Sat Aug 9 15:50:22 2003 @@ -202,38 +202,13 @@ "Face used for displaying OFFLINE servers" :group 'gnus-server-visual) -(defcustom gnus-server-agent-face 'gnus-server-agent-face - "Face name to use on AGENTIZED servers." - :group 'gnus-server-visual - :type 'face) - -(defcustom gnus-server-opened-face 'gnus-server-opened-face - "Face name to use on OPENED servers." - :group 'gnus-server-visual - :type 'face) - -(defcustom gnus-server-closed-face 'gnus-server-closed-face - "Face name to use on CLOSED servers." - :group 'gnus-server-visual - :type 'face) - -(defcustom gnus-server-denied-face 'gnus-server-denied-face - "Face name to use on DENIED servers." - :group 'gnus-server-visual - :type 'face) - -(defcustom gnus-server-offline-face 'gnus-server-offline-face - "Face name to use on OFFLINE servers." - :group 'gnus-server-visual - :type 'face) - (defvar gnus-server-font-lock-keywords (list - '("(\\(agent\\))" 1 gnus-server-agent-face) - '("(\\(opened\\))" 1 gnus-server-opened-face) - '("(\\(closed\\))" 1 gnus-server-closed-face) - '("(\\(offline\\))" 1 gnus-server-offline-face) - '("(\\(denied\\))" 1 gnus-server-denied-face))) + '("(\\(agent\\))" 1 'gnus-server-agent-face) + '("(\\(opened\\))" 1 'gnus-server-opened-face) + '("(\\(closed\\))" 1 'gnus-server-closed-face) + '("(\\(offline\\))" 1 'gnus-server-offline-face) + '("(\\(denied\\))" 1 'gnus-server-denied-face))) (defun gnus-server-mode () "Major mode for listing and editing servers. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 15:45 ` Simon Josefsson 2003-08-09 16:43 ` Jesper Harder @ 2003-08-09 17:16 ` Alan Shutko 2003-08-09 18:05 ` Simon Josefsson 2003-08-10 20:33 ` Kai Großjohann 2 siblings, 1 reply; 16+ messages in thread From: Alan Shutko @ 2003-08-09 17:16 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > You mean changing gnus source? I meant for users. Well, users can customize all the Gnus faces to inherit from the same face. -- Alan Shutko <ats@acm.org> - I am the rocks. Last night our sex was so good, the neighbors lit cigarettes. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 17:16 ` Alan Shutko @ 2003-08-09 18:05 ` Simon Josefsson 2003-08-09 18:44 ` Alan Shutko 0 siblings, 1 reply; 16+ messages in thread From: Simon Josefsson @ 2003-08-09 18:05 UTC (permalink / raw) Cc: ding Alan Shutko <ats@acm.org> writes: > Simon Josefsson <jas@extundo.com> writes: > >> You mean changing gnus source? I meant for users. > > Well, users can customize all the Gnus faces to inherit from the same > face. True. Hm. Using both a variable and a face seem to be common practice though, I wonder if there are other reasons. Maybe face inheritance is a recent feature? I dunno. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 18:05 ` Simon Josefsson @ 2003-08-09 18:44 ` Alan Shutko 2003-08-10 20:34 ` Kai Großjohann 2003-08-25 14:41 ` Per Abrahamsen 0 siblings, 2 replies; 16+ messages in thread From: Alan Shutko @ 2003-08-09 18:44 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > True. Hm. Using both a variable and a face seem to be common > practice though, I wonder if there are other reasons. Maybe face > inheritance is a recent feature? I dunno. I believe it is. The custom attribute is only from 2000, and I know these faces are a lot older than that. I don't know if there's a big reason to change it, but it might make M-x customize-group gnus a bit cleaner. -- Alan Shutko <ats@acm.org> - I am the rocks. extraneous text! ... You may find (as I have) that Ron Janorkar's Tag-X ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 18:44 ` Alan Shutko @ 2003-08-10 20:34 ` Kai Großjohann 2003-08-25 14:41 ` Per Abrahamsen 1 sibling, 0 replies; 16+ messages in thread From: Kai Großjohann @ 2003-08-10 20:34 UTC (permalink / raw) Alan Shutko <ats@acm.org> writes: > Simon Josefsson <jas@extundo.com> writes: > >> True. Hm. Using both a variable and a face seem to be common >> practice though, I wonder if there are other reasons. Maybe face >> inheritance is a recent feature? I dunno. > > I believe it is. The custom attribute is only from 2000, and I know > these faces are a lot older than that. I don't know if there's a big > reason to change it, but it might make M-x customize-group gnus a bit > cleaner. IIRC, font-lock was changed several times between using variables and not using variables. I have no idea, why. -- Two cafe au lait please, but without milk. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 18:44 ` Alan Shutko 2003-08-10 20:34 ` Kai Großjohann @ 2003-08-25 14:41 ` Per Abrahamsen 1 sibling, 0 replies; 16+ messages in thread From: Per Abrahamsen @ 2003-08-25 14:41 UTC (permalink / raw) Alan Shutko <ats@acm.org> writes: > Simon Josefsson <jas@extundo.com> writes: > >> True. Hm. Using both a variable and a face seem to be common >> practice though, I wonder if there are other reasons. Maybe face >> inheritance is a recent feature? I dunno. > > I believe it is. The custom attribute is only from 2000, and I know > these faces are a lot older than that. Faces are oldest, customize in between, and face inheritance is newest. Emacs never really been consistent about whether to use variables to hold the faces, but before customize there was a great incentive to do so, as the pre-customize face API sucked. Often one would just do (defvar some-package-face 'bold "Face used by some package.") in order to avoid the problem of creating a face. If the user wanted some package to use italic instead, he'd (setq some-package-face 'italic) It had a nice feature that if bold looked ugly with his favorite face, he could change the bold face to something else, and many occurrences of bold in Emacs would adjust. It is probably simpler to just use a defface for new options these days, but if we remove the old variables we will break user customizations with setq like the above. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-09 15:45 ` Simon Josefsson 2003-08-09 16:43 ` Jesper Harder 2003-08-09 17:16 ` Alan Shutko @ 2003-08-10 20:33 ` Kai Großjohann 2003-08-12 11:53 ` Simon Josefsson 2 siblings, 1 reply; 16+ messages in thread From: Kai Großjohann @ 2003-08-10 20:33 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > kai.grossjohann@gmx.net (Kai Großjohann) writes: > >> Simon Josefsson <jas@extundo.com> writes: >> >>> It also makes it possible to express "use the same face for this, that >>> and this" and then later be able to change the face only once to >>> change it in all places. >> >> But that's possible with regular faces already? Just use the same >> symbol (face name) in all those places? > > You mean changing gnus source? I meant for users. I don't understand. The default font-lock setup is to use different faces for all the elements in the server buffer. If you want to change the look of the faces, set-face-foreground and friends seem to be sufficient. Obviously, they can be used to make different faces look the same. And equally obviously, if font-lock-keywords specifies the same face for construct A and B, then they will always look the same, regardless of whether a variable is used or a face is used directly -- a variable can only have one value after all... I think I'm misunderstanding you completely; I hope the above helps to show you what my weak mind is thinking so that you can guide me out of the fog. I apologize for being so dense :-/ -- Two cafe au lait please, but without milk. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-10 20:33 ` Kai Großjohann @ 2003-08-12 11:53 ` Simon Josefsson 2003-08-14 21:23 ` Kai Großjohann 0 siblings, 1 reply; 16+ messages in thread From: Simon Josefsson @ 2003-08-12 11:53 UTC (permalink / raw) kai.grossjohann@gmx.net (Kai Großjohann) writes: > Simon Josefsson <jas@extundo.com> writes: > >> kai.grossjohann@gmx.net (Kai Großjohann) writes: >> >>> Simon Josefsson <jas@extundo.com> writes: >>> >>>> It also makes it possible to express "use the same face for this, that >>>> and this" and then later be able to change the face only once to >>>> change it in all places. >>> >>> But that's possible with regular faces already? Just use the same >>> symbol (face name) in all those places? >> >> You mean changing gnus source? I meant for users. > > I don't understand. The default font-lock setup is to use different > faces for all the elements in the server buffer. If you want to > change the look of the faces, set-face-foreground and friends seem to > be sufficient. > > Obviously, they can be used to make different faces look the same. > > And equally obviously, if font-lock-keywords specifies the same face > for construct A and B, then they will always look the same, > regardless of whether a variable is used or a face is used > directly -- a variable can only have one value after all... > > I think I'm misunderstanding you completely; I hope the above helps > to show you what my weak mind is thinking so that you can guide me > out of the fog. I apologize for being so dense :-/ You are right in all that, and I wasn't clear. Consider a user that customizes some face to RED, and then wants the server buffer to use that face for everything. She can then customize all the server buffers to have a RED face. But, the point of having a variable would be if the user then changes her mind on the original RED face, and wants it to be BLUE. Initially, instead of changing the faces, she would only have changed the server buffer face names to point at the original RED face name. So if she changes the original RED face to BLUE, then all server buffer faces also changes to BLUE. Now it seems customize-face supports inheritance, so this can be achieved anyway, but perhaps that feature didn't exist when the face name idea was implemented. So I don't know what the real reason for still supporting face names is. Backwards compatibility? Does XEmacs support face inheritance? Maybe we should ask on emacs-devel, if nobody else here knows, since several other parts of Emacs also uses face names. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-12 11:53 ` Simon Josefsson @ 2003-08-14 21:23 ` Kai Großjohann 2003-08-15 12:07 ` Alex Schroeder 0 siblings, 1 reply; 16+ messages in thread From: Kai Großjohann @ 2003-08-14 21:23 UTC (permalink / raw) Simon Josefsson <jas@extundo.com> writes: > You are right in all that, and I wasn't clear. Consider a user that > customizes some face to RED, and then wants the server buffer to use > that face for everything. She can then customize all the server > buffers to have a RED face. But, the point of having a variable would > be if the user then changes her mind on the original RED face, and > wants it to be BLUE. Initially, instead of changing the faces, she > would only have changed the server buffer face names to point at the > original RED face name. So if she changes the original RED face to > BLUE, then all server buffer faces also changes to BLUE. Ah, I see. An extra level of indirection can be good, I see now. -- Two cafe au lait please, but without milk. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: defface/defcustom question 2003-08-14 21:23 ` Kai Großjohann @ 2003-08-15 12:07 ` Alex Schroeder 0 siblings, 0 replies; 16+ messages in thread From: Alex Schroeder @ 2003-08-15 12:07 UTC (permalink / raw) kai.grossjohann@gmx.net (Kai Großjohann) writes: > Ah, I see. An extra level of indirection can be good, I see now. Well, it often feels like overengineering to me. People really understand face customization. Consider how I customize the look of things. I look at the buffer and notice an ugly piece of text. I try to discover the face used at that point. And then I customize it. Straightforward. Now, how would I find out about the variable used for the indirection we have? I believe I would have to read the source for that. Therefore I think that indirection via variables used to be a way to keep the number of faces small. Emacs Example: apropos-label-face's value is italic. In order to avoid creating a new apropos-label-face, the author decided to reuse an existing face. The same is true for dired. dired-font-lock-keywords contains lots of references to plain font-lock faces such as font-lock-type-face, font-lock-constant-face, etc. The alternative is to create many new faces for each "item". This is why XEmacs has lots of dired faces. So only one small unexplained item remains. Why are there also variables called font-lock-type-face and similar? I think they are useless. The reason is this: You cannot use M-x customize-option to change its value. You can use M-x customize-face to customize font-lock faces. Therefore, having a variable font-lock-type-face pointing to the face font-lock-type-face must be something old -- kept for backwards compatibility. For users, there should be only one thing to change. And based on how font-lock-type-face works, I suggest we allow users to customize faces, not set variables. This is also how I personally customize Emacs, as I said at the beginning. If at all, I therefore propose to remove the indirections via variables. Alex. -- http://www.emacswiki.org/alex/ There is no substitute for experience. ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2003-08-25 14:41 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-08-08 22:15 defface/defcustom question Jesper Harder 2003-08-09 1:54 ` Simon Josefsson 2003-08-09 9:55 ` Kai Großjohann 2003-08-09 11:32 ` Simon Josefsson 2003-08-09 13:13 ` Kai Großjohann 2003-08-09 15:45 ` Simon Josefsson 2003-08-09 16:43 ` Jesper Harder 2003-08-09 17:16 ` Alan Shutko 2003-08-09 18:05 ` Simon Josefsson 2003-08-09 18:44 ` Alan Shutko 2003-08-10 20:34 ` Kai Großjohann 2003-08-25 14:41 ` Per Abrahamsen 2003-08-10 20:33 ` Kai Großjohann 2003-08-12 11:53 ` Simon Josefsson 2003-08-14 21:23 ` Kai Großjohann 2003-08-15 12:07 ` Alex Schroeder
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 NNTP newsgroup(s).