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

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

Re: Easy to add with push but not to the end of a list


From: Michael Heerdegen
Subject: Re: Easy to add with push but not to the end of a list
Date: Tue, 06 Dec 2022 18:22:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Emanuel Berg <incal@dataswamp.org> writes:

> Are the macros here correct then?

Depends on what you want.

> (defmacro file-to-variable (file var)
>   `(setq ,var ,(file-to-string file)) )
>
> (defmacro file-to-variable-integer (file var)
>   `(setq ,var ,(string-to-number (file-to-string file))) )

Calls of these macros will cause those FILEs to be looked up at macro
expansion/ compile time, and the file contents will be become a part of
the .elc.  I guess this is not what you want.

A second (related) problem is that FILE must be a string - a function
call like (expand-file-name "my-file" "/some/path") will not behave as
expected, because your helper functions don't expect an expression.

But `macroexpand' will tell you all of that.  I suggest to take the time
to think thoroughly about it.  Don't try to solve this by guessing or
trial and error.

Michael.




reply via email to

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