diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index 30146af10bfe1fddbbb811ce4861a3d8a6cb8de9..fa10a16f3189f629988a1f21bfdacd6e36b9b995 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -59,6 +59,15 @@ (define (search-path* path file)
              file path))
     absolute-file-name))
 
+(define (package->location-specification package)
+  "Return the location specification for PACKAGE for a typical editor command
+line."
+  (let ((loc (package-location package)))
+    (list (string-append "+"
+                         (number->string
+                          (location-line loc)))
+          (search-path* %load-path (location-file loc)))))
+
 
 (define (guix-edit . args)
   (with-error-handling
@@ -71,10 +80,4 @@ (define (guix-edit . args)
                            (package-full-name package))))
                 packages)
       (apply execlp (%editor) (%editor)
-             (append-map (lambda (package)
-                           (let ((loc (package-location package)))
-                             (list (string-append "+"
-                                                  (number->string
-                                                   (location-line loc)))
-                                   (search-path* %load-path (location-file loc)))))
-                         packages)))))
+             (append-map package->location-specification packages)))))