]> git.eshelyaron.com Git - emacs.git/commitdiff
Do not consider external packages to be removable (Bug#27822)
authorYuri D'Elia <wavexx@thregr.org>
Tue, 17 Jul 2018 10:59:35 +0000 (12:59 +0200)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 12 Aug 2018 01:06:26 +0000 (21:06 -0400)
Packages which are not directly user-installed shouldn't be autoremoved,
since they can be setup through a different path (via
`package-directory-list') where we have no authority over.
* lisp/emacs-lisp/package.el (package--user-installed-p): New
function.
(package--removable-packages): Use it.

lisp/emacs-lisp/package.el

index 576a9bc7e7382f37ee05318550e4e20e5708014f..207c2e5c4890c6c24107bf91ac52b8f5b68622f9 100644 (file)
@@ -1730,6 +1730,15 @@ if it is still empty."
       (indirect indirect-deps)
       (t        (delete-dups (append direct-deps indirect-deps))))))
 
+(defun package--user-installed-p (package)
+  "Return non-nil if PACKAGE is a user-installed package.
+PACKAGE is the package name, a symbol.  Check whether the package
+was installed into `package-user-dir' where we assume to have
+control over."
+  (let* ((pkg-desc (cadr (assq package package-alist)))
+         (dir (package-desc-dir pkg-desc)))
+    (file-in-directory-p dir package-user-dir)))
+
 (defun package--removable-packages ()
   "Return a list of names of packages no longer needed.
 These are packages which are neither contained in
@@ -1739,7 +1748,9 @@ These are packages which are neither contained in
                          ;; `p' and its dependencies are needed.
                          append (cons p (package--get-deps p)))))
     (cl-loop for p in (mapcar #'car package-alist)
-             unless (memq p needed)
+             unless (or (memq p needed)
+                        ;; Do not auto-remove external packages.
+                        (not (package--user-installed-p p)))
              collect p)))
 
 (defun package--used-elsewhere-p (pkg-desc &optional pkg-list all)