[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/organizing-package.el 3d2409a 1/5: Move package-ve
From: |
Artur Malabarba |
Subject: |
[Emacs-diffs] scratch/organizing-package.el 3d2409a 1/5: Move package-version-join to subr.el as version-join |
Date: |
Sun, 29 Mar 2015 10:33:24 +0000 |
branch: scratch/organizing-package.el
commit 3d2409abcd1ace91f5d4f90d01d60264460cc4ab
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Move package-version-join to subr.el as version-join
---
lisp/emacs-lisp/package.el | 30 +-----------------------------
lisp/subr.el | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0d001bf..fffa181 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -485,35 +485,7 @@ version higher than the one being used. To check for
package
"List of the names of currently activated packages.")
(put 'package-activated-list 'risky-local-variable t)
-(defun package-version-join (vlist)
- "Return the version string corresponding to the list VLIST.
-This is, approximately, the inverse of `version-to-list'.
-\(Actually, it returns only one of the possible inverses, since
-`version-to-list' is a many-to-one operation.)"
- (if (null vlist)
- ""
- (let ((str-list (list "." (int-to-string (car vlist)))))
- (dolist (num (cdr vlist))
- (cond
- ((>= num 0)
- (push (int-to-string num) str-list)
- (push "." str-list))
- ((< num -4)
- (error "Invalid version list `%s'" vlist))
- (t
- ;; pre, or beta, or alpha
- (cond ((equal "." (car str-list))
- (pop str-list))
- ((not (string-match "[0-9]+" (car str-list)))
- (error "Invalid version list `%s'" vlist)))
- (push (cond ((= num -1) "pre")
- ((= num -2) "beta")
- ((= num -3) "alpha")
- ((= num -4) "snapshot"))
- str-list))))
- (if (equal "." (car str-list))
- (pop str-list))
- (apply 'concat (nreverse str-list)))))
+(define-obsolete-function-alias 'package-version-join 'version-join)
(defun package-load-descriptor (pkg-dir)
"Load the description file in directory PKG-DIR."
diff --git a/lisp/subr.el b/lisp/subr.el
index 163a1c4..4de6095 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4846,6 +4846,33 @@ which is higher than \"1alpha\", which is higher than
\"1snapshot\".
Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
(version-list-= (version-to-list v1) (version-to-list v2)))
+(defun version-join (vlist)
+ "Return the version string corresponding to the list VLIST.
+This is, approximately, the inverse of `version-to-list'.
+\(Actually, it returns only one of the possible inverses, since
+`version-to-list' is a many-to-one operation.)"
+ (if (null vlist)
+ ""
+ (let ((str-list (list "." (int-to-string (car vlist)))))
+ (dolist (num (cdr vlist))
+ (cond
+ ((>= num 0)
+ (push (int-to-string num) str-list)
+ (push "." str-list))
+ ((< num -4)
+ (error "Invalid version list `%s', number < -4" vlist))
+ (t
+ ;; pre, or beta, or alpha
+ (cond ((equal "." (car str-list))
+ (pop str-list))
+ ((not (string-match "[0-9]+" (car str-list)))
+ (error "Invalid version list `%s'" vlist)))
+ (push (elt ["pre" "beta" "alpha" "snapshot"] (- 0 1 num))
+ str-list))))
+ (when (equal "." (car str-list))
+ (pop str-list))
+ (apply #'concat (nreverse str-list)))))
+
(defvar package--builtin-versions
;; Mostly populated by loaddefs.el via autoload-builtin-package-versions.
(purecopy `((emacs . ,(version-to-list emacs-version))))