From 16f4acbddbb38275a52554caf693017465586ac6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 8 Mar 2016 10:59:27 +0100 Subject: emacs: Gracefully handle wrong package names passed to 'guix-edit'. Fixes . * 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 --- emacs/guix-main.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'emacs') 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." -- cgit v1.2.3