emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 168165178f3 1/3: Use 'package-vc-selected-packages' to store pa


From: Philip Kaludercic
Subject: emacs-29 168165178f3 1/3: Use 'package-vc-selected-packages' to store package specs
Date: Wed, 15 Mar 2023 05:29:14 -0400 (EDT)

branch: emacs-29
commit 168165178f32fb4e20aea32858407921baf079f0
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Use 'package-vc-selected-packages' to store package specs
    
    * doc/emacs/package.texi (Fetching Package Sources): Do not promote
    the usage of 'package-vc-selected-packages' to install packages.
    * lisp/emacs-lisp/package-vc.el (package-vc-selected-packages): Remove
    custom setter and change docstring according to these changes.
    (package-vc--desc->spec): Consult 'package-vc-selected-packages' for
    package specifications.
    (package-vc--unpack): Add unknown package specifications to
    'package-vc-selected-packages'
---
 doc/emacs/package.texi        | 23 -----------------------
 lisp/emacs-lisp/package-vc.el | 38 ++++++++++++++++++++++----------------
 2 files changed, 22 insertions(+), 39 deletions(-)

diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index d993b7b071f..7a2bc11d03c 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -558,29 +558,6 @@ regular package listing.  If you just wish to clone the 
source of a
 package, without adding it to the package list, use
 @code{package-vc-checkout}.
 
-@vindex package-vc-selected-packages
-@findex package-vc-install-selected-packages
-  An alternative way to use @code{package-vc-install} is via the
-@code{package-vc-selected-packages} user option.  This is an alist of
-packages to install, where each key is a package name and the value is
-@code{nil}, indicating that any revision is to install, a string,
-indicating a specific revision or a package specification plist.  The
-side effect of setting the user option is to install the package, but
-the process can also be manually triggered using the function
-@code{package-vc-install-selected-packages}.  Here is an example of
-how the user option:
-
-@example
-@group
-(setopt package-vc-selected-packages
-        '((modus-themes . "0f39eb3fd9") ;specific revision
-          (auctex . nil)                ;any revision
-          (foo                          ;a package specification
-           :url "https://git.sv.gnu.org/r/foo-mode.git";
-           :branch "trunk")))
-@end group
-@end example
-
 @findex package-report-bug
 @findex package-vc-prepare-patch
   With the source checkout, you might want to reproduce a bug against
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index ea2766b8dc4..652f2518672 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -139,7 +139,6 @@ the `clone' function."
                (package-desc-create :name name :kind 'vc))
            spec)))))))
 
-;;;###autoload
 (defcustom package-vc-selected-packages '()
   "List of packages that must be installed.
 Each member of the list is of the form (NAME . SPEC), where NAME
@@ -174,13 +173,9 @@ is a symbol designating the package and SPEC is one of:
 
   All other keys are ignored.
 
-This user option differs from `package-selected-packages' in that
-it is meant to be specified manually.  If you want to install all
-the packages in the list, you cal also use
-`package-vc-install-selected-packages'.
-
-Note that this option will not override an existing source
-package installation or revert the checked out revision."
+This user option will be automatically updated to store package
+specifications for packages that are not specified in any
+archive."
   :type '(alist :tag "List of packages you want to be installed"
                 :key-type (symbol :tag "Package")
                 :value-type
@@ -191,10 +186,6 @@ package installation or revert the checked out revision."
                                          (:lisp-dir string)
                                          (:main-file string)
                                          (:vc-backend symbol)))))
-  :initialize #'custom-initialize-default
-  :set (lambda (sym val)
-         (custom-set-default sym val)
-         (package-vc-install-selected-packages))
   :version "29.1")
 
 (defvar package-vc--archive-spec-alist nil
@@ -224,12 +215,17 @@ All other values are ignored.")
 The optional argument NAME can be used to override the default
 name for PKG-DESC."
   (alist-get
-   (or name (package-desc-name pkg-desc))
-   (if (package-desc-archive pkg-desc)
+   (setq name (or name (package-desc-name pkg-desc)))
+   (if (and (package-desc-archive pkg-desc)
+            (not (alist-get name package-vc-selected-packages
+                            nil nil #'string=)))
        (alist-get (intern (package-desc-archive pkg-desc))
                   package-vc--archive-spec-alist)
-     (apply #'append (mapcar #'cdr package-vc--archive-spec-alist)))
-   nil nil #'string=))
+     ;; Consult both our local list of package specifications, as well
+     ;; as the lists provided by the archives.
+     (apply #'append (cons package-vc-selected-packages
+                           (mapcar #'cdr package-vc--archive-spec-alist))))
+   '() nil #'string=))
 
 (define-inline package-vc--query-spec (pkg-desc prop)
   "Query the property PROP for the package specification of PKG-DESC.
@@ -659,9 +655,19 @@ abort installation?" name))
           ;; file system or between installations.
           (throw 'done (setq lisp-dir name)))))
 
+    ;; Store the :lisp-dir
     (when lisp-dir
       (push (cons :lisp-dir lisp-dir)
             (package-desc-extras pkg-desc)))
+
+    ;; Ensure we have a copy of the package specification
+    (unless (equal (alist-get name (mapcar #'cdr 
package-vc--archive-spec-alist)) pkg-spec)
+      (customize-save-variable
+       'package-vc-selected-packages
+       (cons (cons name pkg-spec)
+             (seq-remove (lambda (spec) (string= name (car spec)))
+                         package-vc-selected-packages))))
+
     (package-vc--unpack-1 pkg-desc pkg-dir)))
 
 (defun package-vc--read-package-name (prompt &optional allow-url installed)



reply via email to

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