From ff352cfb9792d6777a1240fc057708d251027e07 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 1 Sep 2012 19:21:06 +0200 Subject: Move to (guix utils). * guix/packages.scm (, location): Move to... * guix/utils.scm: ... here. --- guix/packages.scm | 34 +--------------------------------- guix/utils.scm | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 03b6174224..e41e6ed831 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -22,17 +22,10 @@ #:use-module (guix build-system) #:use-module (ice-9 match) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) - #:export (location - location? - location-file - location-line - location-column - - origin + #:export (origin origin? origin-uri origin-method @@ -78,31 +71,6 @@ ;;; ;;; Code: -;; A source location. -(define-record-type - (make-location file line column) - location? - (file location-file) ; file name - (line location-line) ; 1-indexed line - (column location-column)) ; 0-indexed column - -(define location - (memoize - (lambda (file line column) - "Return the object for the given FILE, LINE, and COLUMN." - (and line column file - (make-location file line column))))) - -(define (source-properties->location loc) - "Return a location object based on the info in LOC, an alist as returned -by Guile's `source-properties', `frame-source', `current-source-location', -etc." - (let ((file (assq-ref loc 'filename)) - (line (assq-ref loc 'line)) - (col (assq-ref loc 'column))) - (location file (and line (+ line 1)) col))) - - ;; The source of a package, such as a tarball URL and fetcher---called ;; "origin" to avoid name clash with `package-source', `source', etc. (define-record-type* diff --git a/guix/utils.scm b/guix/utils.scm index cec6df935b..a87f119558 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -48,6 +48,14 @@ define-record-type* compile-time-value memoize + + location + location? + location-file + location-line + location-column + source-properties->location + gnu-triplet->nix-system %current-system)) @@ -605,3 +613,32 @@ returned by `config.guess'." (define %current-system ;; System type as expected by Nix, usually ARCHITECTURE-KERNEL. (make-parameter (gnu-triplet->nix-system %host-type))) + + +;;; +;;; Source location. +;;; + +;; A source location. +(define-record-type + (make-location file line column) + location? + (file location-file) ; file name + (line location-line) ; 1-indexed line + (column location-column)) ; 0-indexed column + +(define location + (memoize + (lambda (file line column) + "Return the object for the given FILE, LINE, and COLUMN." + (and line column file + (make-location file line column))))) + +(define (source-properties->location loc) + "Return a location object based on the info in LOC, an alist as returned +by Guile's `source-properties', `frame-source', `current-source-location', +etc." + (let ((file (assq-ref loc 'filename)) + (line (assq-ref loc 'line)) + (col (assq-ref loc 'column))) + (location file (and line (+ line 1)) col))) -- cgit v1.2.3 7cbbcfba2df647b'>home: Add gexp-compiler for home-environments....Andrew Tropin 2021-10-09Move (gnu home-services) to (gnu home services)....Oleg Pykhalov 2021-10-08gnu: Move (gnu home-services) to (gnu home services)....Oleg Pykhalov 2021-09-09gnu: home: Add doc comment about the module....Andrew Tropin 2021-09-09home: Add home-environment....Andrew Tropin