[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple macro question
From: |
Stefan Monnier |
Subject: |
Re: Simple macro question |
Date: |
Tue, 04 May 2021 15:54:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (defun test-fun (com)
> "Testfun with COM."
> nil)
>
> (defmacro test-def (thelist)
> "Doc def."
> `(progn ,@(mapcar #'test-fun thelist)))
>
> (test-def (A B C))
[...]
> Will require to put the test-fun inside an `eval-and-compile` too?
Yup: macro-expansion of `(test-def (A B C))` evaluates the body of
`test-def` and hence calls `test-fun`, but since this is done during
compilation, `test-fun` needs to be not just compiled but also defined.
> I tried to use eval-and-compile in this case but the problem is that in
> my real code test-fun calls another function (a minor mode) that needs
> to be defined later (in the same file);
It's hard to imagine a macro which needs to enable a minor mode during
its expansion. Are you sure?
Stefan