I have the feeling that Emacs Lisp macros are written in some different way than Common Lisp macros. This can't be true, but where is all the gensym
things? Recently I was writing a macro and I needed to avoid capturing a lexical variable, so I started searching for gensym
function. There is no such function! How can a Lisp that has macros don't have gensym
? Maybe it's handled differently in Emacs Lisp?
I've found gensym
in cl-lib
, that's already something. But what I really need is with-gensyms
. Do you know where can I find such a macro (third party package is fine if it's in ELPA or MELPA, although it should be built in Emacs by now, I think).
I'm ready to write these eight lines myself, but this sort of thing shouldn't be rewritten every time, IMHO.
Edit: to make it clear: I'm searching for a way to get this once and for all, that's a library that contains it that I can depend upon. If you think it's OK to rewrite it everywhere every time developer needs it -- that's your point of view. If you vote to close the question simply because there is no such library and
Lisp hackers generally do what is practical for them, such as writing a small utility macro and leaving it at that
-- I think your reasoning is fallacious. Lisp hackers generally don't like to redo something simply because that's how people do it. They create what they need and then use it everywhere.
There are quite a few different libraries that make life easier, and they often do more trivial things. Yet when I ask for something that's useful but missing I get this typical answer "well, don't you know, just copy paste it from Goggle because it isn't there".
You can of course close this question, but IMHO it's normal question asking for certain tool that Emacs Lisp developer might find useful in some cases. If you don't know decent solution, that doesn't mean that the question is bad.
with-gensyms
. It was the first hit from a Google search for "emacs with-gensyms".with-gensyms
is from Alexandria, it isn't standard CL either. Disclaimer: I didn't use this library, but I'm convinced that hygienic macros are better for many purposes than CL-style ones, and here's a library that claims to implement them in ELisp: github.com/ijp/mbe.el . Perhaps, if you are looking for a library to do a lot of macrology, this can come in handy.M-x report-emacs-bug
and suggest thatorg-with-gensyms
be extracted and renamed towith-gensyms
(or maybecl-with-gensyms
, depending on where it is most sensibly relocated to) for more general use.