unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35192: `current-source-directory' fails when file-name #f
@ 2019-04-08 13:26 Alex Sassmannshausen
  2019-04-08 14:23 ` bug#35192: Patch Alex Sassmannshausen
  2019-11-18  4:24 ` bug#35192: `current-source-directory' fails when file-name #f Maxim Cournoyer
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Sassmannshausen @ 2019-04-08 13:26 UTC (permalink / raw)
  To: 35192

Hello,

re: /guix/utils.scm:748:

When file-name is #f (e.g. in a geiser repl), the procedure's match
fails. `assq' returns ('filename . #f).  This is handled in the match
bodies cond clause, but excluded as possibility by the encapsulating
match clause.

Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#35192: Patch
  2019-04-08 13:26 bug#35192: `current-source-directory' fails when file-name #f Alex Sassmannshausen
@ 2019-04-08 14:23 ` Alex Sassmannshausen
  2019-11-18  4:24 ` bug#35192: `current-source-directory' fails when file-name #f Maxim Cournoyer
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Sassmannshausen @ 2019-04-08 14:23 UTC (permalink / raw)
  To: 35192

[-- Attachment #1: Type: text/plain, Size: 62 bytes --]

Please find attached a patch for handling #f file-name.

Alex

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-utils-Handle-f-file-name.patch --]
[-- Type: text/x-diff, Size: 1307 bytes --]

From e6f7d9c4dbbf89284455d6a05488ab952d5374a4 Mon Sep 17 00:00:00 2001
From: Alex Sassmannshausen <alex@pompo.co>
Date: Mon, 8 Apr 2019 15:18:23 +0100
Subject: [PATCH] utils: Handle #f file-name.

* guix/utils.scm (current-source-directory): Change dispatch to handle #f
  file-name.
---
 guix/utils.scm | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/guix/utils.scm b/guix/utils.scm
index ed1a418cca..12765650d8 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -758,13 +758,11 @@ be determined."
           ;; the absolute file name by looking at %LOAD-PATH; doing this at
           ;; run time rather than expansion time is necessary to allow files
           ;; to be moved on the file system.
-          (cond ((not file-name)
-                 #f)                ;raising an error would upset Geiser users
-                ((string-prefix? "/" file-name)
-                 (dirname file-name))
-                (else
-                 #`(absolute-dirname #,file-name))))
-         (#f
+          (if (string-prefix? "/" file-name)
+              (dirname file-name)
+              #`(absolute-dirname #,file-name)))
+         ((or ('filename . #f) #f)
+          ;; raising an error would upset Geiser users
           #f))))))
 
 ;; A source location.
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#35192: `current-source-directory' fails when file-name #f
  2019-04-08 13:26 bug#35192: `current-source-directory' fails when file-name #f Alex Sassmannshausen
  2019-04-08 14:23 ` bug#35192: Patch Alex Sassmannshausen
@ 2019-11-18  4:24 ` Maxim Cournoyer
  1 sibling, 0 replies; 3+ messages in thread
From: Maxim Cournoyer @ 2019-11-18  4:24 UTC (permalink / raw)
  To: Alex Sassmannshausen; +Cc: 35192-done

Hello Alex!

Alex Sassmannshausen <alex.sassmannshausen@gmail.com> writes:

> Hello,
>
> re: /guix/utils.scm:748:
>
> When file-name is #f (e.g. in a geiser repl), the procedure's match
> fails. `assq' returns ('filename . #f).  This is handled in the match
> bodies cond clause, but excluded as possibility by the encapsulating
> match clause.
>
> Alex

Thank you for the fix!  I had the same problem when experimenting at the
REPL, and the comment about Geiser in the code didn't help.

I've pushed this change as commit
b997d43214445462f23947afbbcadf24c6018217.

Closing!

Maxim

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-18  4:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 13:26 bug#35192: `current-source-directory' fails when file-name #f Alex Sassmannshausen
2019-04-08 14:23 ` bug#35192: Patch Alex Sassmannshausen
2019-11-18  4:24 ` bug#35192: `current-source-directory' fails when file-name #f Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).