summary refs log tree commit diff
path: root/gnu/packages.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-05-01 23:11:41 +0200
committerMarius Bakke <mbakke@fastmail.com>2019-05-01 23:11:41 +0200
commit3b458d5462e6bbd852c2dc5c6670d5655abf53f5 (patch)
tree4f3ccec0de1c355134369333c17e948e3258d546 /gnu/packages.scm
parent2ca3fdc2db1aef96fbf702a2f26f5e18ce832038 (diff)
parent14da3daafc8dd92fdabd3367694c930440fd72cb (diff)
downloadguix-3b458d5462e6bbd852c2dc5c6670d5655abf53f5.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/packages.scm')
-rw-r--r--gnu/packages.scm25
1 files changed, 25 insertions, 0 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm
index f9a35588b5..4742f49405 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -32,6 +32,7 @@
                           mkdir-p))
   #:autoload   (guix profiles) (packages->manifest)
   #:use-module (guix describe)
+  #:use-module (guix deprecation)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:autoload   (ice-9 binary-ports) (put-bytevector)
@@ -55,6 +56,7 @@
             fold-packages
             fold-available-packages
 
+            find-newest-available-packages
             find-packages-by-name
             find-package-locations
             find-best-packages-by-name
@@ -190,6 +192,29 @@ flags."
               directory))
         %load-path)))
 
+;; This procedure is used by Emacs-Guix up to 0.5.1.1, so keep it for now.
+;; See <https://github.com/alezost/guix.el/issues/30>.
+(define-deprecated find-newest-available-packages
+  find-packages-by-name
+  (mlambda ()
+    "Return a vhash keyed by package names, and with
+associated values of the form
+
+  (newest-version newest-package ...)
+
+where the preferred package is listed first."
+    (fold-packages (lambda (p r)
+                     (let ((name    (package-name p))
+                           (version (package-version p)))
+                       (match (vhash-assoc name r)
+                         ((_ newest-so-far . pkgs)
+                          (case (version-compare version newest-so-far)
+                            ((>) (vhash-cons name `(,version ,p) r))
+                            ((=) (vhash-cons name `(,version ,p ,@pkgs) r))
+                            ((<) r)))
+                         (#f (vhash-cons name `(,version ,p) r)))))
+                   vlist-null)))
+
 (define (fold-available-packages proc init)
   "Fold PROC over the list of available packages.  For each available package,
 PROC is called along these lines: