From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: package.el dependencies Date: Thu, 29 Jan 2015 06:31:00 +0100 Message-ID: <87egqetap7.fsf@gmail.com> References: <87wq4dpqib.fsf@gmail.com> <87zj93uzuo.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422509493 15734 80.91.229.3 (29 Jan 2015 05:31:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2015 05:31:33 +0000 (UTC) Cc: Artur Malabarba , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 29 06:31:33 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YGhhR-0005gd-5t for ged-emacs-devel@m.gmane.org; Thu, 29 Jan 2015 06:31:29 +0100 Original-Received: from localhost ([::1]:57734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGhhQ-0004rC-B9 for ged-emacs-devel@m.gmane.org; Thu, 29 Jan 2015 00:31:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGhhB-0004r1-Lg for emacs-devel@gnu.org; Thu, 29 Jan 2015 00:31:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGhh7-0007Vx-5Q for emacs-devel@gnu.org; Thu, 29 Jan 2015 00:31:13 -0500 Original-Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:45158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGhh6-0007Vj-Vh for emacs-devel@gnu.org; Thu, 29 Jan 2015 00:31:09 -0500 Original-Received: by mail-wi0-f174.google.com with SMTP id n3so20525901wiv.1 for ; Wed, 28 Jan 2015 21:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; bh=1kiPi4oTswmQAK3AKSxHvqklZjrRQbvR/Qj9OyI17TQ=; b=0QCrVophQGCKAzhLtH8pA7HTBbyJirASWNNGc0v5BvN42XOfawlMVcj02JkCYnAk9/ y9TnLiP8QE6eqlRKG3cGPRKM7PAiSSSnJn9fYzjTV1F5aH+9eLL4QgTG2YqQ9LWhe/G+ chxG4HrIRGcVzBby32+0PS2Oq0gimlHm/o25BO2dIvDEshafe9RsDCXv1J3X2r8oaZL7 Xp0ns3nzdrpa2lT+YcpuaKkCwlClYuEuygSaieZs5ucY+EVz9zxIqexPTAimfeQVeSZv aIhbTQ+9Yvq6AIajf1f02S/QcOJVXHUHJLx/gRP/hQwJdwL5hEzSe5wMgE2WaoqF22vm CD/Q== X-Received: by 10.194.109.9 with SMTP id ho9mr14856946wjb.29.1422509468363; Wed, 28 Jan 2015 21:31:08 -0800 (PST) Original-Received: from dell-14z ([37.161.217.9]) by mx.google.com with ESMTPSA id u17sm912286wij.2.2015.01.28.21.31.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 Jan 2015 21:31:06 -0800 (PST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181959 Archived-At: Stefan Monnier writes: >>> +(defcustom packages-installed-directly nil >>> + "Store here packages installed explicitely by user. >>> +This variable will be feeded automaticaly by emacs, >>> +so you should not modify it yourself. >> Then don't make it a defcustom :-). > > I agree with Arthur's reaction to the docstring's message. But I think > in reality the problem is in the docstring: there's nothing wrong with > setting this variable via Custom (or via setq). > We should very much support such usage. > > E.g. we should provide a command which makes sure that all packages in > packages-installed-directly are indeed installed. So a user can copy > her init file to a new computer and then use this command to > auto-install all the packages she likes. > > Of course, this also hints at the fact that the name is not right. > The name should be more along the lines of "user selected packages", or > something like that. Ok done, I haven't done the rename of `packages-installed-directly' though, I leave you the choice of the name. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index ba9fcd2..92bcbf1 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -335,10 +335,12 @@ contents of the archive." (defcustom packages-installed-directly nil "Store here packages installed explicitely by user. -This variable will be feeded automaticaly by emacs, -so you should not modify it yourself. +This variable will be feeded automatically by emacs, +when installing a new package. This variable will be used by `package-autoremove' to decide -which packages are no more needed." +which packages are no more needed. +You can use it to (re)install packages on other machines +by running `package-user-selected-packages-install'." :group 'package :type '(repeat (choice symbol))) @@ -1428,6 +1430,27 @@ The file can either be a tar file or an Emacs Lisp file." (indirect indirect-deps) (t (append direct-deps indirect-deps))))) +(defun package-user-selected-packages-installed-p () + (cl-loop for p in packages-installed-directly + always (package-installed-p p))) + +;;;###autoload +(defun package-user-selected-packages-install () + "Ensure packages in `packages-installed-directly' are installed. +If some packages are not installed propose to install them." + (interactive) + (cl-loop for p in packages-installed-directly + unless (package-installed-p p) + collect p into lst + finally + (if lst + (when (y-or-n-p + (format "%s packages will be installed:\n%s, proceed?" + (length lst) + (mapconcat 'symbol-name lst ", "))) + (mapc 'package-install lst)) + (message "All your packages are already installed")))) + (defun package-used-elsewhere-p (pkg &optional pkg-list) "Check in PKG-LIST if PKG is used elsewhere as dependency. When not specified, PKG-LIST default to `package-alist' with PKG entry removed. @@ -1618,6 +1641,9 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages." (unless no-activate (dolist (elt package-alist) (package-activate (car elt)))) + (unless (package-user-selected-packages-installed-p) + (when (y-or-n-p "It seems some user-installed packages are missing, update now? ") + (package-user-selected-packages-install))) (setq package--initialized t)) -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997