I want to improve my Elisp, but despite reading about the differences between functions and macros (including discussions here in Emacs SE and on Reddit), I still find examples where the distinction confuses me.
For example, in the "starter-pack" Radian, a macro can be found which wraps use-package
ensuring some sort of partial application:
(defmacro use-feature (name &rest args)
"Like `use-package', but with `straight-use-package-by-default' disabled."
(declare (indent defun))
`(use-package ,name
:straight nil
,@args))
As a case study, would it not be possible to achieve the same with a defun
? After all, this seems like a simple case of partial application, or am I missing something? Do we need a macro here just because use-package
itself is a macro which we don't want a defun
body to evaluate?
And would there be a safe way to improve this macro to take care of a possibly unwanted case (use-feature foo :straight t)
?