all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: Pierre Rouleau <prouleau001@gmail.com>,
	Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: Passing result of macroexpand-all as argument to a function
Date: Wed, 09 Aug 2023 02:53:41 +0000	[thread overview]
Message-ID: <8jYTST4ZkiHwzpQf6qnWQ9vjFoSbMlhTJmH2ReO4KSw0O0PHGXhtGaGvsT6fugo3G-ibKDxfXErDu5mRKvFdKGhGitKSXiHKAB7pomMnt8w=@protonmail.com> (raw)
In-Reply-To: <SJ0PR10MB5488C1B4F88458C0D64560DEF312A@SJ0PR10MB5488.namprd10.prod.outlook.com>

------- Original Message -------
On Wednesday, August 9th, 2023 at 2:27 PM, Drew Adams <drew.adams@oracle.com> wrote:


> > > > 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))

Did not occur to me to quote it.  Still I know what quoting means.

I want to pass other variables to my function, example a a buffer name like so

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

So you want to quote it, but then execute macroexpand-all

What I am worried about is this.  Would myfunc get confused when the code of 
macroexpand-all ends and when bfname starts ?

If I understand correctly, just calling would get the result from 
(macroexpand-all something arg) but then evaluate it because the macro 
code changes in context when used as an argument to a function.

(myfunc (macroexpand-all something arg) bfname)
 
> 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.

I just say things how they are.  If I do not understand and the manual is of no help
(to me of course), no amount of abuse from anyone will convince my understanding.

If you want to help someone, one should not expect a certain result.  Because the
result is not up to you.  The result is determined by the person who receives it.




  reply	other threads:[~2023-08-09  2:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09  0:22 Passing result of macroexpand-all as argument to a function Heime
2023-08-09  1:37 ` Pierre Rouleau
2023-08-09  2:04   ` Heime
2023-08-09  2:26     ` Corwin Brust
2023-08-09  2:40       ` Heime
2023-08-09  2:27     ` [External] : " Drew Adams
2023-08-09  2:53       ` Heime [this message]
2023-08-09  4:02         ` Pierre Rouleau
2023-08-09  4:14         ` Drew Adams
2023-08-09  3:37       ` Michael Heerdegen
2023-08-09  4:13         ` Heime
2023-08-09  4:36           ` Michael Heerdegen
2023-08-09  4:54             ` Heime
2023-08-09 15:21               ` Drew Adams
2023-08-09  4:28         ` Drew Adams
2023-08-09  3:39     ` Michael Heerdegen
2023-08-09  5:06       ` Heime
2023-08-09 15:27         ` [External] : " Drew Adams
2023-08-09 20:34           ` Heime
2023-08-09 21:24             ` Drew Adams
2023-08-09 21:32               ` Heime

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='8jYTST4ZkiHwzpQf6qnWQ9vjFoSbMlhTJmH2ReO4KSw0O0PHGXhtGaGvsT6fugo3G-ibKDxfXErDu5mRKvFdKGhGitKSXiHKAB7pomMnt8w=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=prouleau001@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.