[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macro Expansion Inconsistency
From: |
John Mastro |
Subject: |
Re: Macro Expansion Inconsistency |
Date: |
Tue, 16 Dec 2014 19:34:18 -0800 |
Hi Alexander,
Alexander Shukaev <haroogan@gmail.com> wrote:
> John, please, have a look at my latest post. It will give you the whole idea
> of what's going on. Thanks for your time.
You're very close. I think the below will do what you're looking for,
without using `eval'.
The problem you were having with `foreground' is because it's within two
backquotes. You can think of each unquote as peeling away a single level
of quoting.
The `progn' is necessary because the macro, like other functions, can
only return a single value. Since we need to emit seval forms, we wrap
them up in a single `progn'. This wasn't necessary in yours since you
weren't actually emitting any forms from the macro, but it is necessary
in this way of doing it.
I moved the calls to `put' within the backquote just for the example of
how it's sometimes necessary to quote the result of what you've just
unquoted.
Let me know if anything's unclear or if I missed something.
(defmacro bm-define-flag2 (name index character foreground)
(let* ((symbol
(intern (format "bm-%s-flag" (symbol-name name))))
(character-symbol
(intern (format "%s-character" (symbol-name symbol)))))
`(progn
(put ',symbol 'index ,index)
(put ',symbol 'character ',character-symbol)
(defcustom ,character-symbol
,character
:tag "BM Flag Character"
:group 'buffer-manager
:type 'character)
(defface ,symbol
`((t :foreground ,,foreground
:weight bold))
"Face for flag."
:tag "BM Flag Face"
:group 'buffer-manager-faces))))
--
john
- Re: Macro Expansion Inconsistency, (continued)
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Message not available
- Re: Macro Expansion Inconsistency, Barry Margolin, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Message not available
- Re: Macro Expansion Inconsistency, Rusi, 2014/12/16
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16
- Message not available
- Re: Macro Expansion Inconsistency,
John Mastro <=
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16
Re: Macro Expansion Inconsistency, Stefan Monnier, 2014/12/16