I found this snippet of code from oremacs
(defmacro csetq (variable value)
`(funcall (or (get ',variable 'custom-set) 'set-default) ',variable ,value))
I would like to expand this macro so that is can take multiple pairs of arguments similar to setq
(e.g. (csetq foo 'bar fod 'baz str "a")
etc). I made an initial attempt, but it always returns nil
and leaves me with a lot of nested progn
forms when expanded.
(defmacro csetq (variable value &rest rest)
(when variable
`(progn (funcall (or (get ',variable 'custom-set) 'set-default) ',variable ,value)
(csetq ,(car rest) ,(cadr rest) ,(cddr rest)))))
Is there a way to fix this macro so that it returns the last value set (similar to setq
and does not nest?