* defmacro and defface problems
@ 2008-03-21 0:26 tsgatesv
0 siblings, 0 replies; 2+ messages in thread
From: tsgatesv @ 2008-03-21 0:26 UTC (permalink / raw)
To: help-gnu-emacs
hi, all!
I met a problem about defining macro with defface!
It looks extremely strange to me, help!
1. define macro "git--face" in order to short my codes
--------------------------------------------------------------------------
(defmacro git--face (name fore1 prop1 fore2 prop2)
`(defface ,(make-symbol (concat "git--" (symbol-name name) "-face"))
'((((class color) (background light)) (:foreground ,fore1 ,@prop1))
(((class color) (background dark)) (:foreground ,fore2 ,@prop2)))
,(concat "git " (symbol-name name) " face in status buffer mode")
:group 'git))
--------------------------------------------------------------------------
2. seems like work,
--------------------------------------------------------------------------
(git--face wow "red" (:bold t) "tomato" (:bold t))
git--wow-face
--------------------------------------------------------------------------
3. but not defined (but, there is 'git--wow-face in "list-faces-display)
--------------------------------------------------------------------------
(facep 'git--wow-face)
nil
--------------------------------------------------------------------------
4. this is what I want to eval
--------------------------------------------------------------------------
(defface git--wow-face
'((((class color) (background light)) (:foreground "gray" :bold
t :italic t))
(((class color) (background dark)) (:foreground "gray" :bold
t :italic t)))
"git wow face in status buffer mode"
:group 'git)
git--wow-face
(facep 'git--wow-face)
[face unspecified unspecified unspecified unspecified unspecified
unspecified unspecified unspecified unspecified unspecified
unspecified ...]
--------------------------------------------------------------------------
5. Actually, the expanded macro of 1 and 4 is exactly same like under
--------------------------------------------------------------------------
(macroexpand '(git--face wow "red" (:bold t) "tomato" (:bold
t)))
(custom-declare-face (quote git--wow-face) (quote ((... ...) (... ...)))
"git wow face in status buffer mode" :group (quote git))
(macroexpand
'(defface git--wow-face
'((((class color) (background light)) (:foreground "gray" :bold
t :italic t))
(((class color) (background dark)) (:foreground "gray" :bold
t :italic t)))
"git wow face in status buffer mode"
:group 'git))
(custom-declare-face (quote git--wow-face) (quote ((... ...) (... ...)))
"git wow face in status buffer mode" :group (quote git))
--------------------------------------------------------------------------
Thank you for reading and please help me!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: defmacro and defface problems
[not found] <mailman.9284.1206066601.18990.help-gnu-emacs@gnu.org>
@ 2008-03-21 20:19 ` Barry Margolin
0 siblings, 0 replies; 2+ messages in thread
From: Barry Margolin @ 2008-03-21 20:19 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.9284.1206066601.18990.help-gnu-emacs@gnu.org>,
tsgatesv <tsgatesv@gmail.com> wrote:
> hi, all!
>
> I met a problem about defining macro with defface!
>
> It looks extremely strange to me, help!
>
> 1. define macro "git--face" in order to short my codes
> --------------------------------------------------------------------------
> (defmacro git--face (name fore1 prop1 fore2 prop2)
> `(defface ,(make-symbol (concat "git--" (symbol-name name) "-face"))
Use intern, not make-symbol. Make-symbol creates uninterned symbols, so
when you later type (facep 'git--wow-face), you're not using the same
symbol that you defined.
> '((((class color) (background light)) (:foreground ,fore1 ,@prop1))
> (((class color) (background dark)) (:foreground ,fore2 ,@prop2)))
> ,(concat "git " (symbol-name name) " face in status buffer mode")
> :group 'git))
> --------------------------------------------------------------------------
>
> 2. seems like work,
> --------------------------------------------------------------------------
> (git--face wow "red" (:bold t) "tomato" (:bold t))
> git--wow-face
> --------------------------------------------------------------------------
>
> 3. but not defined (but, there is 'git--wow-face in "list-faces-display)
> --------------------------------------------------------------------------
> (facep 'git--wow-face)
> nil
> --------------------------------------------------------------------------
>
> 4. this is what I want to eval
> --------------------------------------------------------------------------
> (defface git--wow-face
> '((((class color) (background light)) (:foreground "gray" :bold
> t :italic t))
> (((class color) (background dark)) (:foreground "gray" :bold
> t :italic t)))
> "git wow face in status buffer mode"
> :group 'git)
> git--wow-face
>
>
> (facep 'git--wow-face)
> [face unspecified unspecified unspecified unspecified unspecified
> unspecified unspecified unspecified unspecified unspecified
> unspecified ...]
> --------------------------------------------------------------------------
>
> 5. Actually, the expanded macro of 1 and 4 is exactly same like under
> --------------------------------------------------------------------------
>
> (macroexpand '(git--face wow "red" (:bold t) "tomato" (:bold
> t)))
> (custom-declare-face (quote git--wow-face) (quote ((... ...) (... ...)))
> "git wow face in status buffer mode" :group (quote git))
>
> (macroexpand
> '(defface git--wow-face
> '((((class color) (background light)) (:foreground "gray" :bold
> t :italic t))
> (((class color) (background dark)) (:foreground "gray" :bold
> t :italic t)))
> "git wow face in status buffer mode"
> :group 'git))
> (custom-declare-face (quote git--wow-face) (quote ((... ...) (... ...)))
> "git wow face in status buffer mode" :group (quote git))
> --------------------------------------------------------------------------
>
> Thank you for reading and please help me!
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-21 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21 0:26 defmacro and defface problems tsgatesv
[not found] <mailman.9284.1206066601.18990.help-gnu-emacs@gnu.org>
2008-03-21 20:19 ` Barry Margolin
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).