jwiegley/use-package

Install a list of packages via a loop

adamoudad opened this issue · 2 comments

Hi,

I want to install a bunch of packages with the same call to use-package . I try the following.

(defvar packages-no-config
  '(auctex
    caml
    fish-mode
    ) "Default packages to install that do not need any further configuration.")

(dolist (package packages-no-config nil)
   (use-package package
    :ensure t))

However the dolist sexp does nothing and returns nil. My questions are

  • is it possible to programmatically install a list of packages via a loop?
  • am I doing it right? If not, how?

I searched for some code doing what I try to achieve but did not find anything, therefore I am asking here, as I am suspecting this might be an intended behaviour of use-package.

Thanks for your help.
Adam.

use-package is a macro and so the package arg you are passing to it is not being evaluated.
You could do something like the following:

(dolist (package packages-no-config)
    (eval `(use-package ,package :ensure t) t))

I see! I had to learn how to use a macro.

Sorry for the unrelated issue then, thanks!