emacs-devel
[Top][All Lists]
Advanced

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

Re: package.el dependencies


From: Thierry Volpiatto
Subject: Re: package.el dependencies
Date: Thu, 29 Jan 2015 06:31:00 +0100

Stefan Monnier <address@hidden> 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 



reply via email to

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