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 08:22:08 +0100 Message-ID: <87d25yt5jz.fsf@gmail.com> References: <87wq4dpqib.fsf@gmail.com> <87zj93uzuo.fsf@gmail.com> <87egqetap7.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422516149 21786 80.91.229.3 (29 Jan 2015 07:22:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2015 07:22:29 +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 08:22:28 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 1YGjQo-0003nK-4A for ged-emacs-devel@m.gmane.org; Thu, 29 Jan 2015 08:22:26 +0100 Original-Received: from localhost ([::1]:58001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGjQn-0007j2-9O for ged-emacs-devel@m.gmane.org; Thu, 29 Jan 2015 02:22:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGjQi-0007iZ-5r for emacs-devel@gnu.org; Thu, 29 Jan 2015 02:22:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGjQe-0002o1-Vf for emacs-devel@gnu.org; Thu, 29 Jan 2015 02:22:20 -0500 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:37821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGjQe-0002nu-Jv for emacs-devel@gnu.org; Thu, 29 Jan 2015 02:22:16 -0500 Original-Received: by mail-wi0-f177.google.com with SMTP id r20so20367082wiv.4 for ; Wed, 28 Jan 2015 23:22:16 -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=iSbyM1VpzH9CChTfYcLJgZKmRS4M6ECjLSrXgn4oC6g=; b=nRo6/rRaS46cJn6GkaIuxXRZNZ8pRXuiL3w5L/Y0BvS1JMqAHn8fkuRim90RAhtHja SWHLs8rgLUk9auLPBx3WaGNqCnIiH0G/j4V5YI0XIm3ZLvgRm9kQW0zu/FhmMc+U7GtT qRj7ixnfMuOI+1VnbP1RGVZTG+UU6zxRCWC9tNsmNH5xpGfomBVg97dbx3/GHNQ/l12e /48NwcRRF2AmaiqShTkAvcC49o+Hcy5zQ79DT28rguguF7mKQ5+6c1IXPjciiTMrLCK3 Rsb9stE+si+Tl+akVgckElId2glKZzL2c/Fa7pfw2M8MADNoSbqUR1smrL4Y2W6V35CH qSKA== X-Received: by 10.194.80.193 with SMTP id t1mr15631652wjx.8.1422516135924; Wed, 28 Jan 2015 23:22:15 -0800 (PST) Original-Received: from dell-14z ([37.164.74.86]) by mx.google.com with ESMTPSA id i4sm9202007wje.20.2015.01.28.23.22.12 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 Jan 2015 23:22:14 -0800 (PST) In-reply-to: <87egqetap7.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 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:181964 Archived-At: Thierry Volpiatto writes: > 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. I have also added a reinstall command which is handy when one want to reinstall a package which is not directly installed. > 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