diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-08-24 15:51:31 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-09-02 16:43:10 +0200 |
commit | 02fa1d251c9caeba39c7593e0b8ab52b60735b17 (patch) | |
tree | f760b10c3de817a7c476537890ac9a727b9593ed /guix/discovery.scm | |
parent | 20cbd4f5f4d08bc26c22eb40b6c1e55b02e93f23 (diff) |
discovery: Add 'scheme-modules*'.
* guix/self.scm (scheme-modules*): Move to...
* guix/discovery.scm (scheme-modules*): ... here. New procedure. Make
'sub-directory' an optional parameter.
Diffstat (limited to 'guix/discovery.scm')
-rw-r--r-- | guix/discovery.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/guix/discovery.scm b/guix/discovery.scm index 2b627d108e..3fc6e2c9e7 100644 --- a/guix/discovery.scm +++ b/guix/discovery.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -27,6 +27,7 @@ #:use-module (ice-9 ftw) #:export (scheme-files scheme-modules + scheme-modules* fold-modules all-modules fold-module-public-variables)) @@ -115,6 +116,16 @@ name and the exception key and arguments." (string-append directory "/" sub-directory) directory)))) +(define* (scheme-modules* directory #:optional sub-directory) + "Return the list of module names found under SUB-DIRECTORY in DIRECTORY. +This is a source-only variant that does not try to load files." + (let ((prefix (string-length directory))) + (map (lambda (file) + (file-name->module-name (string-drop file prefix))) + (scheme-files (if sub-directory + (string-append directory "/" sub-directory) + directory))))) + (define* (fold-modules proc init path #:key (warn (const #f))) "Fold over all the Scheme modules present in PATH, a list of directories. Call (PROC MODULE RESULT) for each module that is found." |