Questions tagged [defmacro]
8 questions
4
votes
1 answer
Bug in defmacro?
I think I found a bug in defmacro so I'd like to ask for confirmation before I make a fool of myself reporting something silly!
Here is how to reproduce it:
Define the following macro which simply reports the value of case-fold-search in the…

Ruy
- 787
- 4
- 11
2
votes
2 answers
How to distinguish from within a macro definition whether a parameter is a constant string, as opposed to a symbol whose value is a string?
I want to write an emacs macro via defmacro that takes a parameter which could either be (1) a constant string or (2) a symbol whose value is a string.
Within the macro definition I want to be able to distinghish between alternatives (1) and (2)…

Ruy
- 787
- 4
- 11
1
vote
1 answer
The forbidden question about defmacro: when does the expansion occur?
I have recently learned (in shock!) that it is impossible to
predict the moment a macro defined via defmacro is
expanded (i.e., its code is run in order to generate the expanded
form which will in turn run when the macro is invoked). For
instance,…

Ruy
- 787
- 4
- 11
0
votes
2 answers
How does a Lisp macro behave?
Have read that macro provide a way to perform transformations before the code is actually evaluated. When the macro is called, its arguments are passed to the macro as unevaluated forms. The macro then generates objects which are substituted and…

Dilna
- 1,173
- 3
- 10
0
votes
2 answers
How do I properly use keyword/named arguments in a macro with cl-defmacro?
I'm trying to use cl-defmacro, with the supposed benefit of having optional arguments specified with keywords. However, I'm not getting the outcome I would expect.
(cl-defmacro asd (a &rest body &key b)
(format "%s %s %s" a b body))
(asd 1 :b 2…

aaa
- 426
- 3
- 9
0
votes
1 answer
How to use the same variable name with let when calling defmacro?
This is only an example, I understand this can easily be achieved with a function.
Don't Work
This is what I've come up with based on the elisp manual and a couple of answers/articles that I have read. The suggestion is to use gensym, but I can't…

Rick
- 25
- 4
0
votes
1 answer
How do I use a while loop with a macro?
This works when I remove the loop but with the loop it does not
work.
(defmacro my/def-key (state map)
(let ((x '(
(kbd "z z") (lambda nil (interactive)(message "zz"))
(kbd "z f") (lambda nil…

ritchie
- 151
- 6
-2
votes
1 answer
Defining a macro that does nothing
I am defining a macro that accepts any number of arguments that actually do nothing. From a previous discussion, it was pointed out to me that a macro does not evaluate its arguments, which is beneficial to me because I could pass anything, with…

Dilna
- 1,173
- 3
- 10