Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

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:
def :minimum-emacs-version
(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."
;; String
((stringp version)
(version-to-list version))
;; Single number
((numberp version)
(list version))
;; List of numbers
((and (listp version)
(null (remove-if 'numberp version)))
(t (error "Unrecognized version specification: %S" version))))
(defun el-get-error-unless-required-emacs-version (package-or-source)
"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."
(let ((pname (el-get-source-name package-or-source))
(required-version (el-get-package-required-emacs-version package-or-source)))
(when (< emacs-major-version required-version)
(error "Package %s requires Emacs version %s, but current emacs is only version %s"
pname required-version emacs-major-version))))
(let* ((pname (el-get-source-name package-or-source))
(required-version (el-get-package-required-emacs-version package-or-source))
(required-version-list (el-get-version-to-list required-version)))
(when (version-list-< (version-to-list emacs-version) required-version-list)
(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)
......@@ -2,27 +2,27 @@
;; el-get-remove needs to be more flexible
(setq package-a-required-version 24
el-get-sources (list
`(:name a
:type builtin
:minimum-emacs-version ,package-a-required-version))
(setq versions-to-test (list 0 10 23 24 25 40 500 "" "21.4" "500.2.3" '(23 3 50 1))
recipes-to-test (mapcar (lambda (version)
`(:name a :type builtin :minimum-emacs-version ,version))
el-get-default-process-sync t)
;; Simulate same version, higher version, and lower version
(loop for version in (list package-a-required-version
(1+ package-a-required-version)
(1- package-a-required-version))
(loop for version in versions-to-test
(let ((emacs-major-version version))
(if (>= emacs-major-version package-a-required-version)
;; Package should install without error
(let* ((version-list (el-get-version-to-list version))
(should-install (not (version-list-< (version-to-list emacs-version)
(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
(el-get-install 'a)
(el-get-init 'a)
(el-get-remove 'a)
(message "Installing package with met emacs version succeeded."))
;; Lower version: package should throw an error
(el-get-remove 'a))
(condition-case err
(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