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

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

Re: Simple macro question


From: Ergus
Subject: Re: Simple macro question
Date: Mon, 3 May 2021 03:29:38 +0200

Equivalent code like this:

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

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

;;; Commentary:

;;; Code:

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

(defun test-fun (com)
  "Testfun with COM."
  nil)

(defmacro test-def (thelist)
  "Doc def."
  `(progn ,@(mapcar #'test-fun thelist)))

(test-def (A B C))

(provide 'test)
;;; test ends here

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

Says that: Symbol’s function definition is void: test-fun

On Mon, May 03, 2021 at 02:07:12AM +0200, Ergus wrote:

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 via email to

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