]> git.eshelyaron.com Git - emacs.git/commitdiff
* package.el (package--get-activatable-pkg): Prefer source packages
authorPhilip Kaludercic <philipk@posteo.net>
Thu, 11 Aug 2022 11:35:47 +0000 (13:35 +0200)
committerPhilip Kaludercic <philipk@posteo.net>
Thu, 11 Aug 2022 11:35:47 +0000 (13:35 +0200)
lisp/emacs-lisp/package.el

index 1ee39f875296b095b4776d811fe34d3ba8e47287..0145306dc4e3b23c8f07de995b5db017399453da 100644 (file)
@@ -898,14 +898,22 @@ correspond to previously loaded files (those returned by
 
 (defun package--get-activatable-pkg (pkg-name)
   ;; Is "activatable" a word?
-  (let ((pkg-descs (cdr (assq pkg-name package-alist))))
+  (let ((pkg-descs (sort (cdr (assq pkg-name package-alist))
+                         (lambda (p1 p2)
+                           (let ((v1 (package-desc-version p1))
+                                 (v2 (package-desc-version p2)))
+                             (or
+                              ;; Prefer source packages.
+                              (eq (package-desc-kind p1) 'vc)
+                              (not (eq (package-desc-kind p2) 'vc))
+                              ;; Prefer builtin packages.
+                              (package-disabled-p p1 v1)
+                              (not (package-disabled-p p2 v2))))))))
     ;; Check if PACKAGE is available in `package-alist'.
     (while
         (when pkg-descs
           (let ((available-version (package-desc-version (car pkg-descs))))
-            (or (package-disabled-p pkg-name available-version)
-                ;; Prefer a builtin package.
-                (package-built-in-p pkg-name available-version))))
+            (package-disabled-p pkg-name available-version)))
       (setq pkg-descs (cdr pkg-descs)))
     (car pkg-descs)))