emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/leaf 1f51e90e99 01/28: On :package, save already instal


From: ELPA Syncer
Subject: [elpa] externals/leaf 1f51e90e99 01/28: On :package, save already installed pkgs into selected-packages
Date: Wed, 19 Jan 2022 18:58:33 -0500 (EST)

branch: externals/leaf
commit 1f51e90e99283e733c59c49cecb7d5db8c0d0833
Author: Genki Sato <13384803+gksato@users.noreply.github.com>
Commit: Genki Sato <13384803+gksato@users.noreply.github.com>

    On :package, save already installed pkgs into selected-packages
    
    Make sure the `:package`'s target packages are always saved into
    the variable `packages-selected-packages`, whether or not
    the packages are already installed. This way we can more easily
    use package.el-related utilities like `package-autoremove`.
    
    Fixes:
    - https://github.com/conao3/leaf.el/issues/504
    - https://github.com/conao3/leaf.el/issues/294
---
 README.md     | 10 ++++++----
 README.org    | 10 ++++++----
 leaf-tests.el | 10 ++++++----
 leaf.el       |  6 ++++--
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index abaa2f29b0..0bbdd99c3d 100644
--- a/README.md
+++ b/README.md
@@ -396,11 +396,13 @@ Since `:ensure` is to use `package.el` by default, 
`:ensure` and `:package` prod
      (prog1 'macrostep
        (leaf-handler-package macrostep macrostep nil)))
 
-    ;; `leaf-handler-package' expandion example.
-    ;; If `macrostep' isn't installed, try to install.
-    ;; If fail install, update local cache and retry to install.
+    ;; `leaf-handler-package' expansion example.
+    ;; If `macrostep' is installed, set it as a selected package;
+    ;; otherwise try to install it.
+    ;; If installation fails, update local cache and retry to install.
     ((leaf-handler-package macrostep macrostep nil)
-     (unless (package-installed-p 'macrostep)
+     (if (package-installed-p 'macrostep)
+         (package--update-selected-packages '(macrostep) nil)
        (unless (assoc 'macrostep package-archive-contents)
          (package-refresh-contents))
        (condition-case err
diff --git a/README.org b/README.org
index 251288f56e..6d4a49bf2c 100644
--- a/README.org
+++ b/README.org
@@ -414,11 +414,13 @@ Since ~:ensure~ is to use ~package.el~ by default, 
~:ensure~ and
        (prog1 'macrostep
          (leaf-handler-package macrostep macrostep nil)))
 
-      ;; `leaf-handler-package' expandion example.
-      ;; If `macrostep' isn't installed, try to install.
-      ;; If fail install, update local cache and retry to install.
+      ;; `leaf-handler-package' expansion example.
+      ;; If `macrostep' is installed, set it as a selected package;
+      ;; otherwise try to install it.
+      ;; If installation fails, update local cache and retry to install.
       ((leaf-handler-package macrostep macrostep nil)
-       (unless (package-installed-p 'macrostep)
+       (if (package-installed-p 'macrostep)
+           (package--update-selected-packages '(macrostep) nil)
          (unless (assoc 'macrostep package-archive-contents)
            (package-refresh-contents))
          (condition-case err
diff --git a/leaf-tests.el b/leaf-tests.el
index 3fb5534298..86bf79fdec 100644
--- a/leaf-tests.el
+++ b/leaf-tests.el
@@ -2385,11 +2385,13 @@ Example:
      (prog1 'macrostep
        (leaf-handler-package macrostep macrostep nil)))
 
-    ;; `leaf-handler-package' expandion example.
-    ;; If `macrostep' isn't installed, try to install.
-    ;; If fail install, update local cache and retry to install.
+    ;; `leaf-handler-package' expansion example.
+    ;; If `macrostep' is installed, set it as a selected package;
+    ;; otherwise try to install it.
+    ;; If installation fails, update local cache and retry to install.
     ((leaf-handler-package macrostep macrostep nil)
-     (unless (package-installed-p 'macrostep)
+     (if (package-installed-p 'macrostep)
+         (package--update-selected-packages '(macrostep) nil)
        (unless (assoc 'macrostep package-archive-contents)
          (package-refresh-contents))
        (condition-case _err
diff --git a/leaf.el b/leaf.el
index 49937269c9..1f579f84c1 100644
--- a/leaf.el
+++ b/leaf.el
@@ -1074,8 +1074,10 @@ FN also accept list of FN."
       (add-to-list 'leaf--paths (cons ',name file)))))
 
 (defmacro leaf-handler-package (name pkg _pin)
-  "Handler ensure PKG via PIN in NAME leaf block."
-  `(unless (package-installed-p ',pkg)
+  "Handler for ensuring the installation of PKG with package.el
+via PIN in the leaf block NAME."
+  `(if (package-installed-p ',pkg)
+       (package--update-selected-packages '(,pkg) nil)
      (unless (assoc ',pkg package-archive-contents)
        (package-refresh-contents))
      (condition-case _err



reply via email to

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