I want use a macro to generate a package list.

(defvar xx-packages '())

(genpack evil)
(genpack all-the-icons-ivy-rich
   :recipe (:host github :repo "seagle0128/all-the-icons-ivy-rich"))

this macro genpack will append argument to xx-packages,then xx-packages value is

xx-packages '((evil)
                   :recipe (:host github :repo "seagle0128/all-the-icons-ivy-rich"))

How can i write this macro genpack, thanks


1 Answer 1


Like this?

(defmacro genpack (&rest args)
  "Append ARGS to `xx-packages'."
  `(setq xx-packages (nconc xx-packages '(,args))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.