guix-commits
[Top][All Lists]
Advanced

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

02/03: utils: 'current-source-directory' is now purely an expansion-time


From: Ludovic Courtès
Subject: 02/03: utils: 'current-source-directory' is now purely an expansion-time thing.
Date: Thu, 16 Jun 2016 21:51:39 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 5dbae738f0ff83bf629b53d6f4e52a8384a97fb1
Author: Ludovic Courtès <address@hidden>
Date:   Thu Jun 16 22:05:10 2016 +0200

    utils: 'current-source-directory' is now purely an expansion-time thing.
    
    * guix/utils.scm (extract-directory): Remove.
    (current-source-directory): Rewrite as a 'syntax-case' macro.
---
 guix/utils.scm |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/guix/utils.scm b/guix/utils.scm
index 19fd0b0..8aadfb0 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -702,18 +702,16 @@ output port, and PROC's result is returned."
 ;;; Source location.
 ;;;
 
-(define (extract-directory properties)
-  "Extract the directory name from source location PROPERTIES."
-  (match (assq 'filename properties)
-    (('filename . (? string? file-name))
-     (dirname file-name))
-    (_
-     #f)))
-
-(define-syntax-rule (current-source-directory)
-  "Expand to the directory of the current source file or #f if it could not
-be determined."
-  (extract-directory (current-source-location)))
+(define-syntax current-source-directory
+  (lambda (s)
+    "Return the current directory name or #f if it could not be determined."
+    (syntax-case s ()
+      ((_)
+       (match (assq 'filename (syntax-source s))
+         (('filename . (? string? file-name))
+          (dirname file-name))
+         (_
+          #f))))))
 
 ;; A source location.
 (define-record-type <location>



reply via email to

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