Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add priority as the 3rd argument to source alias #78

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 @@ -23,6 +23,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* Adapt `-a`/`--all` option for archives command (#83)
* Merge command `list-all` to list with `-a`/`--all` option (#84)
* Support JSON format with Eask-file linter (#85)
* Add priority as the 3rd argument to source alias (#78)

## 0.7.x
> Released Sep 08, 2022
Expand Down
14 changes: 3 additions & 11 deletions docs/content/en/DSL/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ scripts.

# 🚩 Dependencies

## 🔍 **source** (`alias`)

## 🔍 **source** (`name` `url`)
## 🔍 **source** (`alias-or-name` &optional `url` `priority`)

Add a package archive to install dependencies from.

```elisp
(source "gnu")
(source "gnu" "https://elpa.gnu.org/packages/")
(source "gnu" "https://elpa.gnu.org/packages/" 10)
(source "gnu" nil 10)
```

Available aliases:
Expand All @@ -96,14 +96,6 @@ Available aliases:
💡 Use **--insecure** to make **https** to **http**, but not recommended
{{< /hint >}}

## 🔍 **source-priority** (`name` `priority`)

Set archive priority.

```elisp
(source-priority "gnu" 5)
```

## 🔍 **depends-on** (`package-name` `&optional minimum-version`)

## 🔍 **depends-on** (`package-name` `&rest recipe`)
Expand Down
6 changes: 1 addition & 5 deletions docs/content/en/Development API/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,10 @@ Alias of `files`.

Alias of `script`.

## 🔍 Function: eask-f-source (`name` &optional `location`)
## 🔍 Function: eask-f-source (`name` &optional `location` `priority`)

Alias of `source`.

## 🔍 Function: eask-f-source-priority (`name` &optional `priority`)

Alias of `source-priority`.

## 🔍 Function: eask-f-depends-on (`pkg` &rest `args`)

Alias of `depends-on`.
Expand Down
29 changes: 20 additions & 9 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ other scripts internally. See function `eask-call'.")
'("package" "website-url" "keywords"
"package-file" "files"
"script"
"source" "source-priority"
"source"
"depends-on" "development"
"exec-paths" "load-paths")
"List of Eask file keywords.")
Expand Down Expand Up @@ -786,21 +786,32 @@ Eask file in the workspace."
(mapconcat #'identity (append (list command) args) " "))
eask-scripts))

(defun eask-f-source (name &optional location)
"Add archive NAME with LOCATION."
(defun eask-f-source (name &optional location priority)
"Add archive NAME alias.

If LOCATION is a URL string, replace the default URL from `eask-source-mapping'
to it's value. Optional argument PRIORITY can be use to register to variable
`package-archive-priorities'.

If LOCATION is a number, it will be treated like PRIORITY. When both optional
arguments LOCATION and PRIORITY are defined in number, then we will respect the
latter one."
(when (assoc name package-archives)
(eask-error "Multiple definition of source `%s'" name))
(setq location (or location (cdr (assq (intern name) eask-source-mapping))))
(let ((default-location (cdr (assq (intern name) eask-source-mapping))))
(cond ((numberp location)
(setq priority (or priority location) ; still respect priority
location default-location))
(t
(setq location (or location default-location)))))
(unless location (eask-error "Unknown package archive `%s'" name))
(when (and location
(gnutls-available-p)
(not (eask-network-insecure-p)))
(setq location (s-replace "https://" "http://" location)))
(add-to-list 'package-archives (cons name location) t))

(defun eask-f-source-priority (archive-id &optional priority)
"Add PRIORITY for to ARCHIVE-ID."
(add-to-list 'package-archive-priorities (cons archive-id priority) t))
(add-to-list 'package-archives (cons name location) t)
(when priority
(add-to-list 'package-archive-priorities (cons name priority) t)))

(defvar eask-depends-on-recipe-p nil
"Set to t if package depends on recipe.")
Expand Down