help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Let `package-install-selected-packages' install packages without ask


From: Arthur Miller
Subject: Re: Let `package-install-selected-packages' install packages without asking for confirmation.
Date: Fri, 16 Jul 2021 16:22:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> I use the following init file:
>
> ```
> ;https://emacs.stackexchange.com/questions/34180/how-can-i-script-emacs-to-install-packages-from-list
> ;https://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name
> (require 'package)
> (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/";) t)
> (package-initialize)
>
> (setq package-selected-packages
>       '(company
>         async))
> (package-install-selected-packages)
>
>
> (unless package-archive-contents
>   (package-refresh-contents))
> (package-install-selected-packages t)
> ```
>
> But when I start Emacs, it still asks me to confirm the installation
> of the packages. See the following info shown in minibuffer:
>
> Packages to install: 2 (company async), proceed? (y or n)
>
> As you can see, I've set the `(package-install-selected-packages t)'
> option.

As I see, docs says that variable holds already installed packages, not
the packages you would like to install:

Documentation
Store here packages installed explicitly by user.

I am not sure either how is it ment to be used on another machine, with
noconfirm flag, anyway, you just use dolist and install your packages in
a loop:

(dolist (p '(company async))
  (unless (package-installed-p p)
    (package-install p)))

If you really have to save packages in a named list:

(setq packages-to-install '(company asynb))

(dolist (p packages-to-install)
  (unless (package-installed-p p)
    (package-install p)))

Hope it works for you.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]