Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit f42c023e authored by Ryan C. Thompson's avatar Ryan C. Thompson

Allow version to be specified as number, string, or list.

See "el-get-version-to-list" for details.
parent 2fbf696f
...@@ -189,14 +189,35 @@ which defaults to installed, required and removed. Example: ...@@ -189,14 +189,35 @@ which defaults to installed, required and removed. Example:
def :minimum-emacs-version def :minimum-emacs-version
0))) 0)))
(defun el-get-version-to-list (version)
"Convert VERSION to a standard version list.
Like the builtin `version-to-list', this function accepts a
string. Unlike the builtin, it will also accept a single number,
which will be wrapped into a single-element list, or a or a list
of numbers, which will be returned unmodified."
(cond
;; String
((stringp version)
(version-to-list version))
;; Single number
((numberp version)
(list version))
;; List of numbers
((and (listp version)
(null (remove-if 'numberp version)))
version)
(t (error "Unrecognized version specification: %S" version))))
(defun el-get-error-unless-required-emacs-version (package-or-source) (defun el-get-error-unless-required-emacs-version (package-or-source)
"Raise an error if `emacs-major-version' is less than package's requirement. "Raise an error if `emacs-major-version' is less than package's requirement.
Second argument PACKAGE is optional and only used to construct the error message." Second argument PACKAGE is optional and only used to construct the error message."
(let ((pname (el-get-source-name package-or-source)) (let* ((pname (el-get-source-name package-or-source))
(required-version (el-get-package-required-emacs-version package-or-source))) (required-version (el-get-package-required-emacs-version package-or-source))
(when (< emacs-major-version required-version) (required-version-list (el-get-version-to-list required-version)))
(error "Package %s requires Emacs version %s, but current emacs is only version %s" (when (version-list-< (version-to-list emacs-version) required-version-list)
pname required-version emacs-major-version)))) (error "Package %s requires Emacs version %s or higher, but the current emacs is only version %s"
pname required-version emacs-version))))
(provide 'el-get-recipes) (provide 'el-get-recipes)
...@@ -2,27 +2,27 @@ ...@@ -2,27 +2,27 @@
;; ;;
;; el-get-remove needs to be more flexible ;; el-get-remove needs to be more flexible
(setq package-a-required-version 24 (setq versions-to-test (list 0 10 23 24 25 40 500 "24.1.50.1" "21.4" "500.2.3" '(23 3 50 1))
el-get-sources (list recipes-to-test (mapcar (lambda (version)
`(:name a `(:name a :type builtin :minimum-emacs-version ,version))
:type builtin versions-to-test)
:minimum-emacs-version ,package-a-required-version))
el-get-default-process-sync t) el-get-default-process-sync t)
;; Simulate same version, higher version, and lower version ;; Simulate same version, higher version, and lower version
(loop for version in (list package-a-required-version (loop for version in versions-to-test
(1+ package-a-required-version)
(1- package-a-required-version))
do do
(let ((emacs-major-version version)) (let* ((version-list (el-get-version-to-list version))
(if (>= emacs-major-version package-a-required-version) (should-install (not (version-list-< (version-to-list emacs-version)
;; Package should install without error version-list)))
(el-get-sources
(list `(:name a :type builtin :minimum-emacs-version ,version))))
(message "Testing installing a package requiring version %S. Current emacs version is %s. Package install is expected to %s."
version emacs-version (if should-install "succeed" "fail"))
(if should-install
(progn (progn
(el-get-install 'a) (el-get-install 'a)
(el-get-init 'a) (el-get-init 'a)
(el-get-remove 'a) (el-get-remove 'a))
(message "Installing package with met emacs version succeeded."))
;; Lower version: package should throw an error
(condition-case err (condition-case err
(progn (progn
(el-get-install 'a) (el-get-install 'a)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment