From 15a5e64407ebee02733b7437b9a05bdc218c0802 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 18:25:51 -0700 Subject: [PATCH 1/7] feat: Add :try for depends-pon --- docs/content/DSL/_index.en.md | 8 +++ docs/content/DSL/_index.zh-tw.md | 8 +++ lisp/_prepare.el | 95 ++++++++++++++++++++------------ lisp/core/info.el | 7 ++- 4 files changed, 79 insertions(+), 39 deletions(-) diff --git a/docs/content/DSL/_index.en.md b/docs/content/DSL/_index.en.md index afd72e6a..f6aa1f52 100644 --- a/docs/content/DSL/_index.en.md +++ b/docs/content/DSL/_index.en.md @@ -165,6 +165,14 @@ Specify dependencies in **vc** format: (depends-on "lsp-ui" :vc "emacs-lsp/lsp-ui") ``` +Specify dependencies in **try** format: + +```elisp +(depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") + +(depends-on "lsp-ui" :vc) ; Try it, don't install it. +``` + Specify dependencies in **recipe** format: ```elisp diff --git a/docs/content/DSL/_index.zh-tw.md b/docs/content/DSL/_index.zh-tw.md index 4d6adcb2..43038b3c 100644 --- a/docs/content/DSL/_index.zh-tw.md +++ b/docs/content/DSL/_index.zh-tw.md @@ -161,6 +161,14 @@ weight: 200 (depends-on "lsp-ui" :vc "emacs-lsp/lsp-ui") ``` +以 **try** 格式指定依賴項: + +```elisp +(depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") + +(depends-on "lsp-ui" :vc) ; 只有試看看, 不安裝. +``` + 以 **recipe** 格式指定依賴項: ```elisp diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 514a5bbe..d8184c45 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -566,6 +566,10 @@ For arguments FUNC and DEPS, see function `mapc' for more information." ((memq :vc dep) (let ((spec (cdr (memq :vc dep)))) (eask-package-vc-install name spec))) + ;; Try out packages using `try'. + ((memq :try dep) + (let ((url-or-package (nth 2 dep))) + (eask-package-try name url-or-package))) ;; Fallback to archive install. (t (eask-package-install name))))) @@ -694,6 +698,17 @@ Argument BODY are forms for execution." "Return non-nil if package (PKG) is installable." (assq (eask-intern pkg) package-archive-contents)) +(defun eask-package-try (pkg url-or-package) + "To try a package without actually install it." + (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x + (require 'try) + (let ((target (or url-or-package pkg))) + (eask-with-progress + (format " - %sTrying out %s... " eask--action-prefix + (ansi-green (eask-2str target))) + (eask-with-verbosity 'debug (try target)) + "done ✓"))) + (defun eask-package-vc-install (pkg spec) "To vc install the package (PKG) by argument SPEC." (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x @@ -757,23 +772,24 @@ Argument BODY are forms for execution." (unless (eask-package-installable-p pkg) (eask-error "Package not installable `%s'; make sure the package archive (source) is included" pkg)))) (t - (eask-with-progress - (format " - %s%snstalling %s (%s)... " eask--action-prefix - (if should-reinstall-p "Rei" "I") - name version) - (eask-with-verbosity 'debug - ;; Handle `--force` flag. - (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) - ;; XXX: Without ignore-errors guard, it will trigger error - ;; - ;; Can't find library xxxxxxx.el - ;; - ;; But we can remove this after Emacs 28, since function `find-library-name' - ;; has replaced the function `signal' instead of the `error'. - ;; - ;; Install it. - (eask-ignore-errors (package-install pkg))) - "done ✓"))))) + (eask--pkg-process pkg ; Second call to force refresh the data. + (eask-with-progress + (format " - %s%snstalling %s (%s)... " eask--action-prefix + (if should-reinstall-p "Rei" "I") + name version) + (eask-with-verbosity 'debug + ;; Handle `--force` flag. + (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) + ;; XXX: Without ignore-errors guard, it will trigger error + ;; + ;; Can't find library xxxxxxx.el + ;; + ;; But we can remove this after Emacs 28, since function `find-library-name' + ;; has replaced the function `signal' instead of the `error'. + ;; + ;; Install it. + (eask-ignore-errors (package-install pkg))) + "done ✓")))))) (defun eask-package-delete (pkg) "Delete the package (PKG)." @@ -783,7 +799,7 @@ Argument BODY are forms for execution." ((not installed-p) (eask-msg " - %sSkipping %s (%s)... not installed ✗" eask--action-prefix name version)) (t - (eask--pkg-process pkg + (eask--pkg-process pkg ; Second call to force refresh the data. (eask-with-progress (format " - %sUninstalling %s (%s)... " eask--action-prefix name version) (eask-with-verbosity 'debug @@ -800,12 +816,13 @@ Argument BODY are forms for execution." (eask-msg " - %sSkipping %s (%s)... not installed ✗" eask--action-prefix name version)) (t (eask-pkg-init) - (eask-with-progress - (format " - %sReinstalling %s (%s)... " eask--action-prefix name version) - (eask-with-verbosity 'debug - (package-delete (eask-package-desc pkg t) t) - (eask-ignore-errors (package-install pkg))) - "done ✓"))))) + (eask--pkg-process pkg ; Second call to force refresh the data. + (eask-with-progress + (format " - %sReinstalling %s (%s)... " eask--action-prefix name version) + (eask-with-verbosity 'debug + (package-delete (eask-package-desc pkg t) t) + (eask-ignore-errors (package-install pkg))) + "done ✓")))))) (defun eask-package-desc (name &optional current) "Build package description by its NAME. @@ -1540,6 +1557,9 @@ argument COMMAND." (defvar eask-depends-on-recipe-p nil "Set to t if package depends on recipe.") +(defvar eask-depends-on-try-p nil + "Set to t if package depends on try.") + (defvar eask--local-archive-name "local" "The local archive name.") @@ -1547,6 +1567,10 @@ argument COMMAND." "Setup dependencies list." (setq eask-depends-on (reverse eask-depends-on) eask-depends-on-dev (reverse eask-depends-on-dev)) + ;; On try + (when eask-depends-on-try-p + (eask-archive-install-packages '("gnu" "melpa") 'try)) + ;; On recipe (when eask-depends-on-recipe-p (eask-with-progress (format "✓ Checking local archives %s... " @@ -1593,22 +1617,21 @@ ELPA)." (eask-error "This requires Emacs %s and above!" minimum-version) (push recipe eask-depends-on-emacs)) recipe))) - ;; No argument specify - ((<= (length args) 1) - (let* ((minimum-version (car args)) - (recipe (list pkg minimum-version))) - (unless (eask--check-depends-on recipe) - (push recipe eask-depends-on)) - recipe)) - ;; File packages - ((memq :file args) + ;; Specified packages + ((or (memq :file args) ; File packages + (memq :vc args) ; VC packages + (memq :try args)) ; Try packages (let* ((recipe (append (list (intern pkg)) args))) (unless (eask--check-depends-on recipe) (push recipe eask-depends-on)) + ;; Set flag. + (when (memq :try args) + (setq eask-depends-on-try-p t)) recipe)) - ;; VC packages - ((memq :vc args) - (let* ((recipe (append (list (intern pkg)) args))) + ;; No argument specify + ((<= (length args) 1) + (let* ((minimum-version (car args)) + (recipe (list pkg minimum-version))) (unless (eask--check-depends-on recipe) (push recipe eask-depends-on)) recipe)) diff --git a/lisp/core/info.el b/lisp/core/info.el index 4225098a..f844df9f 100644 --- a/lisp/core/info.el +++ b/lisp/core/info.el @@ -27,11 +27,12 @@ offset (eask-2str eask-info--max-offset)) (dolist (dep dependencies) (let* ((target-version (cdr dep)) - (target-version (cond ((= (length target-version) 1) + (target-version (cond ((memq :file dep) "file") + ((memq :vc dep) "vc") + ((memq :try dep) "try") + ((= (length target-version) 1) (or (nth 0 target-version) ; verison number "archive")) - ((memq :file dep) "file") - ((memq :vc dep) "vc") (t "recipe")))) (eask-println (concat " %-" offset "s (%s)") (car dep) target-version) (eask-debug " Recipe: %s" (car dep))))))) From 0933a2a7855dde6930c8cb30a06c13b7d663dbca Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 18:27:12 -0700 Subject: [PATCH 2/7] docs: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b2b0e40..add51ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * fix(install): Package installed calculation (a479d5355dfc832286288b790338652e174d606d) * fix(install-file): Get correct install package name (#318) +* feat: Add `:try` for `depends-on` DSL (#319) ## 0.11.x > Released Apr 03, 2025 From 23ada41d1288b6c4f6bdecaf8ece9586d3137f98 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 18:30:15 -0700 Subject: [PATCH 3/7] test: Add future test references --- test/jest/install/Eask | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/jest/install/Eask b/test/jest/install/Eask index 8f132288..cefdff08 100644 --- a/test/jest/install/Eask +++ b/test/jest/install/Eask @@ -37,6 +37,9 @@ ;;(depends-on "msgu" :vc "https://github.com/jcs-elpa/msgu") ) +;; Try out +;;(depends-on "indent-control" :vc) + ;; Recipe install (depends-on "watch-cursor" :repo "jcs-elpa/watch-cursor" :fetcher 'github) From 071e58d0de4175106f0e1de2b6b266024c71310b Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 18:33:22 -0700 Subject: [PATCH 4/7] typo --- docs/content/DSL/_index.en.md | 2 +- docs/content/DSL/_index.zh-tw.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/DSL/_index.en.md b/docs/content/DSL/_index.en.md index f6aa1f52..f792a1e8 100644 --- a/docs/content/DSL/_index.en.md +++ b/docs/content/DSL/_index.en.md @@ -170,7 +170,7 @@ Specify dependencies in **try** format: ```elisp (depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") -(depends-on "lsp-ui" :vc) ; Try it, don't install it. +(depends-on "lsp-ui" :try) ; Try it, don't install it. ``` Specify dependencies in **recipe** format: diff --git a/docs/content/DSL/_index.zh-tw.md b/docs/content/DSL/_index.zh-tw.md index 43038b3c..f4741a1b 100644 --- a/docs/content/DSL/_index.zh-tw.md +++ b/docs/content/DSL/_index.zh-tw.md @@ -166,7 +166,7 @@ weight: 200 ```elisp (depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") -(depends-on "lsp-ui" :vc) ; 只有試看看, 不安裝. +(depends-on "lsp-ui" :try) ; 只有試看看, 不安裝. ``` 以 **recipe** 格式指定依賴項: From 4536ade3849f849163b7e6a5ed28c53883dbfcf4 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 18:34:28 -0700 Subject: [PATCH 5/7] docs: should use url instead --- docs/content/DSL/_index.en.md | 2 +- docs/content/DSL/_index.zh-tw.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/DSL/_index.en.md b/docs/content/DSL/_index.en.md index f792a1e8..9d7c5c3c 100644 --- a/docs/content/DSL/_index.en.md +++ b/docs/content/DSL/_index.en.md @@ -168,7 +168,7 @@ Specify dependencies in **vc** format: Specify dependencies in **try** format: ```elisp -(depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") +(depends-on "auto-rename-tag" :try "https://raw.githubusercontent.com/emacs-vs/auto-rename-tag/refs/heads/master/auto-rename-tag.el") (depends-on "lsp-ui" :try) ; Try it, don't install it. ``` diff --git a/docs/content/DSL/_index.zh-tw.md b/docs/content/DSL/_index.zh-tw.md index f4741a1b..8674dbe7 100644 --- a/docs/content/DSL/_index.zh-tw.md +++ b/docs/content/DSL/_index.zh-tw.md @@ -164,7 +164,7 @@ weight: 200 以 **try** 格式指定依賴項: ```elisp -(depends-on "auto-rename-tag" :try "https://github.com/emacs-vs/auto-rename-tag") +(depends-on "auto-rename-tag" :try "https://raw.githubusercontent.com/emacs-vs/auto-rename-tag/refs/heads/master/auto-rename-tag.el") (depends-on "lsp-ui" :try) ; 只有試看看, 不安裝. ``` From 64c542a600949db04ced87ef5e37633f3516281f Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 19:01:08 -0700 Subject: [PATCH 6/7] fix: better integrate try --- lisp/_prepare.el | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index d8184c45..10bfd9e5 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -698,16 +698,22 @@ Argument BODY are forms for execution." "Return non-nil if package (PKG) is installable." (assq (eask-intern pkg) package-archive-contents)) -(defun eask-package-try (pkg url-or-package) - "To try a package without actually install it." +(defun eask-package-try (pkg &optional url-or-package) + "To try a package (PKG) without actually install it. + +The optional argument URL-OR-PACKAGE is used in the function `try'." (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x - (require 'try) - (let ((target (or url-or-package pkg))) - (eask-with-progress - (format " - %sTrying out %s... " eask--action-prefix - (ansi-green (eask-2str target))) - (eask-with-verbosity 'debug (try target)) - "done ✓"))) + (eask-with-progress + (format " - %sTrying out %s%s... " eask--action-prefix + (ansi-green (eask-2str pkg)) + (if url-or-package + (concat " in " (ansi-yellow url-or-package)) + "")) + (eask-with-verbosity 'debug + (eask-archive-install-packages '("gnu" "melpa") 'try) + (require 'try) + (try (or url-or-package pkg))) + "done ✓")) (defun eask-package-vc-install (pkg spec) "To vc install the package (PKG) by argument SPEC." @@ -1557,9 +1563,6 @@ argument COMMAND." (defvar eask-depends-on-recipe-p nil "Set to t if package depends on recipe.") -(defvar eask-depends-on-try-p nil - "Set to t if package depends on try.") - (defvar eask--local-archive-name "local" "The local archive name.") @@ -1567,9 +1570,6 @@ argument COMMAND." "Setup dependencies list." (setq eask-depends-on (reverse eask-depends-on) eask-depends-on-dev (reverse eask-depends-on-dev)) - ;; On try - (when eask-depends-on-try-p - (eask-archive-install-packages '("gnu" "melpa") 'try)) ;; On recipe (when eask-depends-on-recipe-p (eask-with-progress @@ -1624,9 +1624,6 @@ ELPA)." (let* ((recipe (append (list (intern pkg)) args))) (unless (eask--check-depends-on recipe) (push recipe eask-depends-on)) - ;; Set flag. - (when (memq :try args) - (setq eask-depends-on-try-p t)) recipe)) ;; No argument specify ((<= (length args) 1) From dbd06f1bfa96e2341c834a068c1f52d9d5bc2768 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 7 Apr 2025 19:10:05 -0700 Subject: [PATCH 7/7] feat: Add try test --- test/jest/install/Eask | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jest/install/Eask b/test/jest/install/Eask index cefdff08..2f93335f 100644 --- a/test/jest/install/Eask +++ b/test/jest/install/Eask @@ -38,7 +38,8 @@ ) ;; Try out -;;(depends-on "indent-control" :vc) +(depends-on "indent-control" :try) +(depends-on "auto-rename-tag" :try "https://raw.githubusercontent.com/emacs-vs/auto-rename-tag/refs/heads/master/auto-rename-tag.el") ;; Recipe install (depends-on "watch-cursor"