GNU bug report logs - #22933
M-x guix-edit fails gracelessly when passed an nonexistent package name

Previous Next

Package: guix;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Mon, 7 Mar 2016 16:30:02 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

Full log


Message #28 received at 22933-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 22933-done <at> debbugs.gnu.org, Alex Kost <alezost <at> gmail.com>
Subject: Re: bug#22933: M-x guix-edit fails gracelessly when passed an
 nonexistent package name
Date: Tue, 08 Mar 2016 11:14:33 +0100
Mathieu Lirzin <mthl <at> gnu.org> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
>> index 34da6ac..c5d5d75 100644
>> --- a/emacs/guix-main.scm
>> +++ b/emacs/guix-main.scm
>> @@ -954,10 +954,14 @@ 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)))
>> +  (define package
>> +    (or (package-by-id id-or-name)
>> +        (match (packages-by-name id-or-name)
>> +          (() #f)
>> +          ((first . rest) first))))
>> +
>> +  (and package
>> +       (location->string (package-location package))))
>
> Not related to the bug.  but it feels weird to use internal defines for
> something else than a procedure.
>
> what about using (not tested):
>
>   (and=> (or (package-by-id id-or-name)
>              (match (packages-by-name id-or-name)
>                (()        #f)
>                ((pkg ..1) pkg)))
>          (compose location->string package-location))
>
> I know you love my 'pkg' identifier.  ;)

Fixed along these lines in commit
16f4acbddbb38275a52554caf693017465586ac6.

(Note that ..1 matches a list of one or more element, not the first
element of a list.)

Ludo’.




This bug report was last modified 9 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.