unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ergus <spacibba@aol.com>
To: help-gnu-emacs@gnu.org
Subject: Simple macro question
Date: Mon, 3 May 2021 02:07:12 +0200	[thread overview]
Message-ID: <20210503000712.l2wh2liwhg3jfjxy@Ergus> (raw)
In-Reply-To: 20210503000712.l2wh2liwhg3jfjxy.ref@Ergus


Hi:

Playing with macros to generate function I got an problem I am not sure
how to solve or why is it an issue

In the following minimal code:

==============================

;;; test.el --- test editing -*- lexical-binding: t; -*-

;;; Commentary:

;;; Code:

(defvar test-commands-list '(A B C)
   "List of replaced functions.")

(defmacro test-def ()
   "Doc def."
   `(eval-and-compile ,@(mapcar (lambda (com) nil) test-commands-list)))

(test-def)

(provide 'test)
;;; test ends here

==============================

This code shows an error like:

Symbol’s value as variable is void: test-commands-list

in this line: (test-def)

I can't use test-commands-list either in this way or as an input if I
define the macro as:

(defmacro test-def (commands-list)
...

(test-def test-commands-list)

In this second case I get: wrong arguments sequencep test-commands-list

Is this intended?




       reply	other threads:[~2021-05-03  0:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210503000712.l2wh2liwhg3jfjxy.ref@Ergus>
2021-05-03  0:07 ` Ergus [this message]
2021-05-03  1:29   ` Simple macro question Ergus
2021-05-03  1:46   ` Stefan Monnier
2021-05-03 11:32     ` Ergus
2021-05-04 19:54       ` Stefan Monnier via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=20210503000712.l2wh2liwhg3jfjxy@Ergus \
    --to=spacibba@aol.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).