From 518d4939f7dc2583e2e162839277a9e5f6d91198 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sun, 18 Dec 2022 17:29:57 +0800 Subject: [PATCH 1/3] feat: Add priority as the 3rd arugment to source alias --- docs/content/en/DSL/_index.md | 14 +++----------- docs/content/en/Development API/_index.md | 6 +----- lisp/_prepare.el | 18 ++++++++++-------- package-lock.json | 4 ++-- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/docs/content/en/DSL/_index.md b/docs/content/en/DSL/_index.md index 1205ce7a..db86c64c 100644 --- a/docs/content/en/DSL/_index.md +++ b/docs/content/en/DSL/_index.md @@ -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: @@ -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`) diff --git a/docs/content/en/Development API/_index.md b/docs/content/en/Development API/_index.md index dfd78681..1b06cffc 100644 --- a/docs/content/en/Development API/_index.md +++ b/docs/content/en/Development API/_index.md @@ -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`. diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 20a323d7..06baa3ab 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -553,7 +553,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.") @@ -780,8 +780,12 @@ 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'." (when (assoc name package-archives) (eask-error "Multiple definition of source `%s'" name)) (setq location (or location (cdr (assq (intern name) eask-source-mapping)))) @@ -790,11 +794,9 @@ Eask file in the workspace." (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.") diff --git a/package-lock.json b/package-lock.json index 7529e8e8..04efb1ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@emacs-eask/cli", - "version": "0.7.4", + "version": "0.7.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@emacs-eask/cli", - "version": "0.7.4", + "version": "0.7.5", "license": "GPL-3.0", "dependencies": { "yargs": "^17.0.0" From 3746052a3116bf78915f9e250f29e8c6f2d82a94 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sun, 18 Dec 2022 15:37:46 +0800 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd06a02..e38eca6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * Merge `clean` commands to one subcommand (#71) * Fix void function `eask-source` to `eask-f-source` (#75) * Fix upcoming breaking changes from `package-build` (#65) +* Add priority as the 3rd argument to source alias (#78) ## 0.7.x > Released Sep 08, 2022 From 6fa98aa64e3ee1236ad1920c59d287c0f9cf7db6 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sun, 18 Dec 2022 16:39:21 +0800 Subject: [PATCH 3/3] Allow location to be priority --- lisp/_prepare.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 06baa3ab..7fe42a2b 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -785,10 +785,19 @@ Eask file in the workspace." 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'." +`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)