Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions docs/content/DSL/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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://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.
```

Specify dependencies in **recipe** format:

```elisp
Expand Down
8 changes: 8 additions & 0 deletions docs/content/DSL/_index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ weight: 200
(depends-on "lsp-ui" :vc "emacs-lsp/lsp-ui")
```

以 **try** 格式指定依賴項:

```elisp
(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) ; 只有試看看, 不安裝.
```

以 **recipe** 格式指定依賴項:

```elisp
Expand Down
92 changes: 56 additions & 36 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))

Expand Down Expand Up @@ -694,6 +698,23 @@ 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 &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
(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."
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
Expand Down Expand Up @@ -757,23 +778,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)."
Expand All @@ -783,7 +805,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
Expand All @@ -800,12 +822,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.
Expand Down Expand Up @@ -1547,6 +1570,7 @@ argument COMMAND."
"Setup dependencies list."
(setq eask-depends-on (reverse eask-depends-on)
eask-depends-on-dev (reverse eask-depends-on-dev))
;; On recipe
(when eask-depends-on-recipe-p
(eask-with-progress
(format "✓ Checking local archives %s... "
Expand Down Expand Up @@ -1593,22 +1617,18 @@ 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))
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))
Expand Down
7 changes: 4 additions & 3 deletions lisp/core/info.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))))
Expand Down
4 changes: 4 additions & 0 deletions test/jest/install/Eask
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
;;(depends-on "msgu" :vc "https://github.com/jcs-elpa/msgu")
)

;; Try out
(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"
:repo "jcs-elpa/watch-cursor" :fetcher 'github)
Expand Down