jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.37k stars 260 forks source link

Install a list of packages via a loop #1031

Closed adamoudad closed 1 year ago

adamoudad commented 1 year ago

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

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.

progfolio commented 1 year ago

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))
adamoudad commented 1 year ago

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

Sorry for the unrelated issue then, thanks!