help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: Passing result of macroexpand-all as argument to a


From: Drew Adams
Subject: RE: [External] : Re: Passing result of macroexpand-all as argument to a function
Date: Wed, 9 Aug 2023 02:27:33 +0000

> > > 1- What is the problem that you are trying to solve?
> >
> > 2- If you want to pass something to a function and you want that
> something
> > not evaluated, then: quote it. The function can later evaluate it if it
> > needs to extract the result of the expression, or it can print it using
> a
> > string formatting function.
> >
> > 3- If #2 is not clear, reading a LISP tutorial will help. Investing time
> > reading on LISP and Emacs Lisp will help a lot.
> 
> I am going to pass
> (myfunc (macroexpand-all something arg) bfname)
> 
> How would I define myfunc ?
> 
> Will (macroexpand-all something arg) be in a form of a list (list of names
> and arguments) or what ?

As several have said, a Lisp macro takes a list sexp that has a symbol car, 
that is, something that looks like a function call: (foo...), and it returns a 
Lisp form - pretty much any kind of Lisp object you like: a string, a symbol, a 
list, a vector, a character or other number.

`macroexpand-all` just expands the macro calls at all levels of its FORM 
argument: the topmost sexp and any sexps inside it - all the way down.

You've already been told that if you want to pass a Lisp object to a function 
without it being evaluated then quote it.

Since you want `macroexpand-all' to first expand your `something' form, you 
want to quote it after evaluating the `macroexpand-all' call.  How to do that 
is the among the FAQiest FAQs:

https://emacs.stackexchange.com/q/7481

IOW, (myfunc `,(macroexpand-all something arg))

As many have suggested to you ... the Elisp Intro manual is your friend, as is 
the Elisp manual.  It has a wealth of clear explanation and unlimited patience.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]