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>
This commit is contained in:
Ludovic Courtès 2016-03-08 10:59:27 +01:00
parent e224495ce1
commit 16f4acbddb

View file

@ -954,10 +954,11 @@ (define (delete-generations* profile generations)
(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."