summary refs log tree commit diff
path: root/emacs/guix-main.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-03-08 10:59:27 +0100
committerLudovic Courtès <ludo@gnu.org>2016-03-08 11:11:28 +0100
commit16f4acbddbb38275a52554caf693017465586ac6 (patch)
treedc6557825244fd10b7b7788fedfa9b76497c6684 /emacs/guix-main.scm
parente224495ce1ce373cc43b49faa538116c9cac1466 (diff)
downloadguix-16f4acbddbb38275a52554caf693017465586ac6.tar.gz
emacs: Gracefully handle wrong package names passed to 'guix-edit'.
Fixes <http://bugs.gnu.org/22933>.

* emacs/guix-main.scm (package-location-string): Rewrite to handle the
case where 'packages-by-name' returns the empty list.

Co-authored-by: Mathieu Lirzin <mthl@gnu.org>
Diffstat (limited to 'emacs/guix-main.scm')
-rw-r--r--emacs/guix-main.scm9
1 files changed, 5 insertions, 4 deletions
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 34da6ac6b6..86cedfd459 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -954,10 +954,11 @@ GENERATIONS is a list of generation numbers."
 
 (define (package-location-string id-or-name)
   "Return a location string of a package with ID-OR-NAME."
-  (and-let* ((package  (or (package-by-id id-or-name)
-                           (first (packages-by-name id-or-name))))
-             (location (package-location package)))
-    (location->string location)))
+  (and=> (or (package-by-id id-or-name)
+             (match (packages-by-name id-or-name)
+               (()              #f)
+               ((package _ ...) package)))
+         (compose location->string package-location)))
 
 (define (package-source-derivation->store-path derivation)
   "Return a store path of the package source DERIVATION."