emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#22933: closed (M-x guix-edit fails gracelessly whe


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#22933: closed (M-x guix-edit fails gracelessly when passed an nonexistent package name)
Date: Tue, 08 Mar 2016 10:15:02 +0000

Your message dated Tue, 08 Mar 2016 11:14:33 +0100
with message-id <address@hidden>
and subject line Re: bug#22933: M-x guix-edit fails gracelessly when passed an 
nonexistent package name
has caused the debbugs.gnu.org bug report #22933,
regarding M-x guix-edit fails gracelessly when passed an nonexistent package 
name
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
22933: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22933
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: M-x guix-edit fails gracelessly when passed an nonexistent package name Date: Mon, 07 Mar 2016 17:28:48 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Currently M-x guix-edit fails badly (actually ‘guix-package-location’)
pwhen passed the name of a nonexistent package:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (error "Error in evaluating guile expression: 
ERROR: In procedure car:
ERROR: In procedure car: Wrong type (expecting pair): ()

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [3]> ")
  signal(error ("Error in evaluating guile expression: ERROR: In procedure 
car:\nERROR: In procedure car: Wrong type (expecting pair): ()\n\nEntering a 
new prompt.  Type `,bt' for a backtrace or `,q' to 
continue.\nscheme@(guile-user) [3]> "))
  error("Error in evaluating guile expression: %s" "ERROR: In procedure 
car:\nERROR: In procedure car: Wrong type (expecting pair): ()\n\nEntering a 
new prompt.  Type `,bt' for a backtrace or `,q' to 
continue.\nscheme@(guile-user) [3]> ")
  (if (geiser-eval--retort-error res) (error "Error in evaluating guile 
expression: %s" (geiser-eval--retort-output res)) (cdr (assq (quote result) 
res)))
  (let ((res (geiser-eval--send/wait (list (quote :eval) (list (quote :scm) 
str))))) (if (geiser-eval--retort-error res) (error "Error in evaluating guile 
expression: %s" (geiser-eval--retort-output res)) (cdr (assq (quote result) 
res))))
  (save-current-buffer (set-buffer (or repl (guix-geiser-repl))) (let ((res 
(geiser-eval--send/wait (list (quote :eval) (list (quote :scm) str))))) (if 
(geiser-eval--retort-error res) (error "Error in evaluating guile expression: 
%s" (geiser-eval--retort-output res)) (cdr (assq (quote result) res)))))
  guix-geiser-eval("(package-location-string \"foo\")" #<buffer *Guix Internal 
REPL*>)
  (car (guix-geiser-eval str repl))
  (replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl)))
  (replace-regexp-in-string "#f\\|#<unspecified>" "nil" 
(replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl))))
  (read (replace-regexp-in-string "#f\\|#<unspecified>" "nil" 
(replace-regexp-in-string "#t" "t" (car (guix-geiser-eval str repl)))))
  guix-geiser-eval-read("(package-location-string \"foo\")" #<buffer *Guix 
Internal REPL*>)
  guix-eval-read("(package-location-string \"foo\")")
  guix-package-location("foo")
  eval((guix-package-location "foo") nil)
  eval-expression((guix-package-location "foo") nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
--8<---------------cut here---------------end--------------->8---

I think this patch fixes it:

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))))
 
 (define (package-source-derivation->store-path derivation)
   "Return a store path of the package source DERIVATION."
Thoughts?

Ludo’.

--- End Message ---
--- Begin Message --- 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 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Mathieu Lirzin <address@hidden> skribis:

> address@hidden (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’.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]