diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f8337c..bc916eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * fix(lint): match behavior of declare linter to checkdoc (#272) * fix(test): ERT test fails on Emacs 30+ (cc1f4e15b7b40b986ad1a93f6e40d121340598de) * fix(test): eask options should not be passed to buttercup (#281) +* feat(core): Lazy install on required packages (#284) ## 0.10.x > Released Jun 13, 2024 diff --git a/docs/content/Development-API/_index.en.md b/docs/content/Development-API/_index.en.md index 31d4bc95..20aeb244 100644 --- a/docs/content/Development-API/_index.en.md +++ b/docs/content/Development-API/_index.en.md @@ -249,7 +249,7 @@ Initialize packages for use. Scope that temporary makes archives available. -`ARCHIVES` can either be a string or a list of strings. +The argument `ARCHIVES` can either be a string or a list of strings. ```elisp (eask-with-archives "melpa" @@ -260,6 +260,21 @@ Scope that temporary makes archives available. 💡 This is handy when you need certain packages from certain archives. {{< /hint >}} +## 🔍 Function: eask-archive-install-packages (`archives` `names`) + +Install packages with archives setup. + +The arugment `names` can be a symbol or list of symbols. + +```elisp +(eask-archive-install-packages '("gnu" "melpa") + 'el2org) ; accept list +``` + +{{< hint info >}} +💡 This only installs packages if they are missing. +{{< /hint >}} + ## 🔍 Function: eask-package-desc (`name` &optional `current`) Build package descriptor for a package. @@ -975,7 +990,7 @@ Return size of the current package. Create execution with the responsive message output. ```elisp -(eask-with-progress +(eask-with-progress "Downloading files... " (eask-with-verbosity 'debug ; Often used with `eask-with-verbosity' ;; Execute some operations.. diff --git a/docs/content/Development-API/_index.zh-tw.md b/docs/content/Development-API/_index.zh-tw.md index a7b9cc7f..84397c7c 100644 --- a/docs/content/Development-API/_index.zh-tw.md +++ b/docs/content/Development-API/_index.zh-tw.md @@ -179,7 +179,7 @@ $ eask init 💡 我們不經常呼叫它,因為我們不希望直接執行另一個命令! {{< /hint >}} -## 🔍 Function: eask-import (`url`) +## 🔍 函式: eask-import (`url`) 從 url 載入並評估腳本。 @@ -246,7 +246,7 @@ $ eask init 臨時使存檔可用的範圍。 -`ARCHIVES` 可以是字符串或字符串列表。 +參數 `archives` 可以是字串或字串列表。 ```elisp (eask-with-archives "melpa" @@ -254,7 +254,22 @@ $ eask init ``` {{< hint info >}} -💡 當您需要某些檔案中的某些包時,這很方便。 +💡 當您需要某些存檔中的特定套件時,這非常方便。 +{{< /hint >}} + +## 🔍 函式: eask-archive-install-packages (`archives` `names`) + +使用 archives 設定安裝套件。 + +參數 `names` 可以是符號或符號列表。 + +```elisp +(eask-archive-install-packages '("gnu" "melpa") + 'el2org) ; 接受列表 +``` + +{{< hint info >}} +💡 這只會在套件遺失時安裝套件。 {{< /hint >}} ## 🔍 函式: eask-package-desc (`name` &optional `current`) @@ -965,7 +980,7 @@ This will kill Emacs process. 使用響應消息輸出創建執行。 ```elisp -(eask-with-progress +(eask-with-progress "檔案下載中s... " (eask-with-verbosity 'debug ; 通常與 `eask-with-verbosity` 一起使用 ;; 執行一些操作.. @@ -1011,6 +1026,6 @@ This will kill Emacs process. 返回可能的包名稱。 -## 🔍 Function: eask-guess-entry-point () +## 🔍 函式: eask-guess-entry-point () 返回可能的包的入口點。 diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 55765a33..73275280 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -569,8 +569,8 @@ scope of the dependencies (it's either `production' or `development')." (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x (when eask-depends-on-recipe-p (eask-log "Installing required external packages...") - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'package-build)) + (eask-archive-install-packages '("gnu" "melpa") + 'package-build) (eask-with-progress "Building temporary archives (this may take a while)... " (eask-with-verbosity 'debug (github-elpa-build)) @@ -656,6 +656,14 @@ Argument BODY are forms for execution." "done ✓")) ,@body)) +(defun eask-archive-install-packages (archives names) + "Install package NAMES with ARCHIVES setup." + (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x + (when-let* ((names (eask-listify names)) + ((cl-some (lambda (pkg) (not (package-installed-p pkg))) names))) + (eask-with-archives archives + (eask--package-mapc #'eask-package-install names)))) + (defun eask-package-installable-p (pkg) "Return non-nil if package (PKG) is installable." (assq (eask-intern pkg) package-archive-contents)) diff --git a/lisp/core/cat.el b/lisp/core/cat.el index ab5938a9..6640f9e7 100644 --- a/lisp/core/cat.el +++ b/lisp/core/cat.el @@ -25,8 +25,8 @@ (eask-start ;; Preparation - (eask-with-archives "melpa" - (eask-package-install 'e2ansi)) + (eask-archive-install-packages '("gnu" "melpa") + 'e2ansi) (eask-msg "") ;; Start the task diff --git a/lisp/core/docs.el b/lisp/core/docs.el index 8bc8de57..dd4cd83b 100644 --- a/lisp/core/docs.el +++ b/lisp/core/docs.el @@ -43,8 +43,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'el2org)) + (eask-archive-install-packages '("gnu" "melpa") + 'el2org) ;; Start building... (require 'el2org) diff --git a/lisp/core/loc.el b/lisp/core/loc.el index a19455cb..62c82cd7 100644 --- a/lisp/core/loc.el +++ b/lisp/core/loc.el @@ -36,14 +36,14 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'markdown-mode)) + (eask-archive-install-packages '("gnu" "melpa") + 'markdown-mode) (require 'markdown-mode) ;; Start LOC (if-let* ((files (or (eask-expand-file-specs (eask-args)) (eask-package-files))) - (eask-output (get-buffer-create "*eask-output*"))) + (eask-output (get-buffer-create "*eask-output*"))) (with-current-buffer eask-output (erase-buffer) (progn ; Print header diff --git a/lisp/core/package.el b/lisp/core/package.el index d5bb43ba..e10dc29a 100644 --- a/lisp/core/package.el +++ b/lisp/core/package.el @@ -74,8 +74,8 @@ Argument VERSION is a string represent the version number of this package." (ignore-errors (make-directory eask-dist-path t)) (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'package-build)) + (eask-archive-install-packages '("gnu" "melpa") + 'package-build) (eask-load "extern/package-build") ; override (let* ((version (eask-package-version)) diff --git a/lisp/format/elfmt.el b/lisp/format/elfmt.el index 234de463..5ac0f810 100644 --- a/lisp/format/elfmt.el +++ b/lisp/format/elfmt.el @@ -46,8 +46,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa" "jcs-elpa") - (eask-package-install 'elfmt)) + (eask-archive-install-packages '("gnu" "melpa" "jcs-elpa") + 'elfmt) (setq eask-format-elfmt--version (eask-package--version-string 'elfmt)) ;; Start formatting diff --git a/lisp/format/elisp-autofmt.el b/lisp/format/elisp-autofmt.el index eedb2332..9a729c58 100644 --- a/lisp/format/elisp-autofmt.el +++ b/lisp/format/elisp-autofmt.el @@ -46,8 +46,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'elisp-autofmt)) + (eask-archive-install-packages '("gnu" "melpa") + 'elisp-autofmt) (setq eask-format-elisp-autofmt--version (eask-package--version-string 'elisp-autofmt)) ;; Start formatting diff --git a/lisp/generate/ignore.el b/lisp/generate/ignore.el index ff337b66..ece2c2c3 100644 --- a/lisp/generate/ignore.el +++ b/lisp/generate/ignore.el @@ -44,8 +44,8 @@ (eask-start ;; Preparation - (eask-with-archives "melpa" - (eask-package-install 'gitignore-templates)) + (eask-archive-install-packages '("gnu" "melpa") + 'gitignore-templates) ;; Start the task (require 'gitignore-templates) diff --git a/lisp/generate/license.el b/lisp/generate/license.el index 5cd7ab8a..a9deffeb 100644 --- a/lisp/generate/license.el +++ b/lisp/generate/license.el @@ -48,8 +48,8 @@ (eask-start ;; Preparation - (eask-with-archives "melpa" - (eask-package-install 'license-templates)) + (eask-archive-install-packages '("gnu" "melpa") + 'license-templates) ;; Start the task (require 'license-templates) diff --git a/lisp/generate/test/buttercup.el b/lisp/generate/test/buttercup.el index 6ef83ca1..3f3d726f 100644 --- a/lisp/generate/test/buttercup.el +++ b/lisp/generate/test/buttercup.el @@ -41,9 +41,8 @@ " test-file name test-file)))))) (eask-start - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'buttercup) - (eask-package-install 'f)) + (eask-archive-install-packages '("gnu" "melpa") + '(buttercup f)) (require 'buttercup) (require 'f) (eask-generate-test-buttercup--init (eask-guess-package-name))) diff --git a/lisp/generate/test/ecukes.el b/lisp/generate/test/ecukes.el index a03fabd5..f165df7b 100644 --- a/lisp/generate/test/ecukes.el +++ b/lisp/generate/test/ecukes.el @@ -15,8 +15,8 @@ nil t)) (eask-start - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'ecukes)) + (eask-archive-install-packages '("gnu" "melpa") + 'ecukes) (require 'ecukes-new) (ecukes-new)) diff --git a/lisp/generate/test/ert-runner.el b/lisp/generate/test/ert-runner.el index 645447da..6c113a77 100644 --- a/lisp/generate/test/ert-runner.el +++ b/lisp/generate/test/ert-runner.el @@ -31,8 +31,8 @@ " name)))) (eask-start - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'ert-runner)) + (eask-archive-install-packages '("gnu" "melpa") + 'ert-runner) (advice-add 'ert-runner/run :override #'ignore) (load-library "ert-runner") (load-library "f") diff --git a/lisp/init/cask.el b/lisp/init/cask.el index 1d245372..4226277e 100644 --- a/lisp/init/cask.el +++ b/lisp/init/cask.el @@ -206,9 +206,8 @@ Optional argument CONTENTS is used for nested directives. e.g. development." (eask-start ;; Preparation - (eask-with-archives `("gnu" "melpa" "jcs-elpa") - (eask-package-install 'package-build) - (eask-package-install 'cask)) + (eask-archive-install-packages '("gnu" "melpa" "jcs-elpa") + '(package-build cask)) ;; Start Converting (require 'cask) diff --git a/lisp/init/eldev.el b/lisp/init/eldev.el index 5363a3f8..8c6c5de3 100644 --- a/lisp/init/eldev.el +++ b/lisp/init/eldev.el @@ -77,8 +77,8 @@ (eask-start ;; Preparation - (eask-with-archives "melpa" - (eask-package-install 'eldev)) + (eask-archive-install-packages '("gnu" "melpa") + 'eldev) ;; Start Converting (require 'eldev) diff --git a/lisp/init/keg.el b/lisp/init/keg.el index 03c7b323..1d2d455f 100644 --- a/lisp/init/keg.el +++ b/lisp/init/keg.el @@ -125,8 +125,8 @@ If no found the Keg file, returns nil." (eask-start ;; Preparation - (eask-with-archives "melpa" - (eask-package-install 'keg)) + (eask-archive-install-packages '("gnu" "melpa") + 'keg) ;; Start Converting (require 'keg) diff --git a/lisp/lint/elisp-lint.el b/lisp/lint/elisp-lint.el index 9506761f..dc5de0b0 100644 --- a/lisp/lint/elisp-lint.el +++ b/lisp/lint/elisp-lint.el @@ -52,8 +52,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'elisp-lint)) + (eask-archive-install-packages '("gnu" "melpa") + 'elisp-lint) (setq eask-lint-elisp-lint--version (eask-package--version-string 'elisp-lint)) ;; Start Linting diff --git a/lisp/lint/elsa.el b/lisp/lint/elsa.el index b04dccbc..a3a19a16 100644 --- a/lisp/lint/elsa.el +++ b/lisp/lint/elsa.el @@ -60,8 +60,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'elsa)) + (eask-archive-install-packages '("gnu" "melpa") + 'elsa) (setq eask-lint-elsa--version (eask-package--version-string 'elsa)) ;; Start Linting diff --git a/lisp/lint/package.el b/lisp/lint/package.el index 866eb20f..3fdaa56a 100644 --- a/lisp/lint/package.el +++ b/lisp/lint/package.el @@ -59,8 +59,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'package-lint)) + (eask-archive-install-packages '("gnu" "melpa") + 'package-lint) (setq eask-lint-package--version (eask-package--version-string 'package-lint)) ;; Start Linting diff --git a/lisp/lint/regexps.el b/lisp/lint/regexps.el index a631d6e0..78d46b34 100644 --- a/lisp/lint/regexps.el +++ b/lisp/lint/regexps.el @@ -60,8 +60,8 @@ (eask-start ;; Preparation - (eask-with-archives "gnu" - (eask-package-install 'relint)) + (eask-archive-install-packages '("gnu") + 'relint) (setq eask-lint-regexps--relint-version (eask-package--version-string 'relint)) ;; Start Linting diff --git a/lisp/test/buttercup.el b/lisp/test/buttercup.el index d403fd57..264a244e 100644 --- a/lisp/test/buttercup.el +++ b/lisp/test/buttercup.el @@ -16,8 +16,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'buttercup)) + (eask-archive-install-packages '("gnu" "melpa") + 'buttercup) ;; Start Testing (require 'buttercup) diff --git a/lisp/test/ecukes.el b/lisp/test/ecukes.el index 2c096455..ebbc3e0b 100644 --- a/lisp/test/ecukes.el +++ b/lisp/test/ecukes.el @@ -29,8 +29,8 @@ Modified from function `ecukes-cli/run'." (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'ecukes)) + (eask-archive-install-packages '("gnu" "melpa") + 'ecukes) ;; Start Testing (require 'ecukes) diff --git a/lisp/test/ert-runner.el b/lisp/test/ert-runner.el index 0019ff06..feb167d3 100644 --- a/lisp/test/ert-runner.el +++ b/lisp/test/ert-runner.el @@ -21,8 +21,8 @@ (setq ert-runner-verbose t)))) (eask-start - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'ert-runner)) + (eask-archive-install-packages '("gnu" "melpa") + 'ert-runner) (require 'ert-runner)) ;;; test/ert-runner.el ends here diff --git a/lisp/test/melpazoid.el b/lisp/test/melpazoid.el index eb5bd9d8..85bbc23d 100644 --- a/lisp/test/melpazoid.el +++ b/lisp/test/melpazoid.el @@ -30,9 +30,8 @@ (eask-start ;; Preparation - (eask-with-archives '("gnu" "melpa") - (eask-package-install 'package-lint) - (eask-package-install 'pkg-info)) + (eask-archive-install-packages '("gnu" "melpa") + '(package-lint pkg-info)) ;; Start Testing (let* ((dirs (or (eask-args) `(,default-directory))))