branch: externals/leaf commit 61365188be30c34c0e8b6f2004488e60a83dfcd6 Merge: 0ccc52bb85 1f51e90e99 Author: Naoya Yamashita <con...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #505 from gksato/feature#504-package-save-selected On :package, save already installed pkgs into selected-packages --- 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