I'm trying to create a macro on Emacs Lisp and I'm struggling to see if a user may pass a symbol quoted or not quoted.
Actually I need something like quote-only-if-is-not-quoted
macro. Is there anything like that? I didn't found nothing about that on any Lisp dialect. Macro example:
(quote-only-if-is-not-quoted 'q) => (quote q)
(quote-only-if-is-not-quoted q) => (quote q)
Thanks in advance.
Macro arguments are unevaluated, so yes, you can check to see whether an argument is quoted and, if not, quote it. Something like this?
(defmacro quote-only-if-is-not-quoted (arg)
(if (and (consp arg)
(eq (car arg) 'quote))
arg
`(quote ,arg)))