From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Let `package-install-selected-packages' install packages without asking for confirmation. Date: Fri, 16 Jul 2021 22:41:23 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21559"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Arthur Miller Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 16 16:42:03 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m4P2P-0005OH-5b for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 16:42:01 +0200 Original-Received: from localhost ([::1]:53194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4P2O-0000oP-3A for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 10:42:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4P22-0000mQ-Be for help-gnu-emacs@gnu.org; Fri, 16 Jul 2021 10:41:38 -0400 Original-Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]:38891) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4P1z-00067T-Fu for help-gnu-emacs@gnu.org; Fri, 16 Jul 2021 10:41:38 -0400 Original-Received: by mail-yb1-xb35.google.com with SMTP id r132so15221921yba.5 for ; Fri, 16 Jul 2021 07:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RXADQtU4JMo/T75KC5jkKLsFQxsm5ooKF/KRuqq2iK0=; b=PA67smpYot5nweM3mUDYUK+hbBnGQakh2yuhR4mBbeBpAoyWLgBA4qvPAQNWAx4jRK cThhQvrriiqg1F4a+KTTLsXnxlscR2MqHS+hwxs5hWlF0WIeOmVreVyHWSSJdH/yrQPF t0zB9UZu1z7Qe2gsEMB/kmY6DR5Wgp9MVooWRIQ94WOV+XD3xt1t03YOwPa3FwmFv5zH pYDhEPuLvgJr6tdD81100GCffYuRjV4jgw0tk8ouIe5wWDSUwEolY8S4ac3BOG87g1VX msxZ0FF4A2Dxoc+T2KItj5T5cTIDKatUofLBxZEMeMtsNCKIhDcAOg0gGT43CbO6A9wX OuHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RXADQtU4JMo/T75KC5jkKLsFQxsm5ooKF/KRuqq2iK0=; b=BVd2GLlmGx1CrFxFMdV2hwHc5x/wNS/2lcbGTKd6dqTmzR5PjtFgA8hrSGMTtg+4R9 oI4MLWcb8dsHpbGLKbP/d8v7S7R7Jx1ge7PGuz0yDEoQpqyyyOnYqJAx5Qh0menr57ZP y2Os0C28JKa7/WPKtk0Pj8NFpSnVdNIFFT4lluzI8lhehm1lnBhP5XbjNZN8YCzRGrYV J+idxxOHuNocSFMWZe8zRiV8Z9vT3NcuCIP2YUlK+oOU0UFQuAXwLrV1IgT0UryrY3Up U60ozhQL+tXFPR25kUa7h6EMCSgxwl/ULENdxD2rcSYrcOONYKPAgFCFIqhCGVvZ82Dc 5c5g== X-Gm-Message-State: AOAM531N0C4bFMyhKfaDf1bwIDpEzlEwsDTKjOjxEkWpYAfyI8LPYQ5K 94FkPtsQE4TkHxB24MK57k6BSeg5tUiDDQaceTk= X-Google-Smtp-Source: ABdhPJx3VMmC0WWjVFEGY6UAC82hL0EtbT6ijOoCr8s1yS64Y3ArqXWCf8l+ETDzbfd7RUuCi6Pj5L8gCSJCuTnpYtA= X-Received: by 2002:a25:694f:: with SMTP id e76mr12728432ybc.119.1626446494341; Fri, 16 Jul 2021 07:41:34 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::b35; envelope-from=hongyi.zhao@gmail.com; helo=mail-yb1-xb35.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131751 Archived-At: On Fri, Jul 16, 2021 at 10:22 PM Arthur Miller wrote: > > Hongyi Zhao 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) The above line is redundant. If I delete it, all will work just as I want. > > > > > > (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. Thank you very much for your suggestions. But as I've told, the method posted here really works perfectly after my later revision, as mentioned above. Regards -- Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province