diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-05-08 01:48:52 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-05-08 01:48:52 +0200 |
commit | c09f5bbaa836d04a9babdff0943dc596dbc68e38 (patch) | |
tree | e2c9c91fa86534ba9479c03a067164947fb034d1 /scheme/plt/geiser | |
parent | 9127a121c76f5d5606bca9a668bda5509ec3b830 (diff) | |
download | geiser-chez-c09f5bbaa836d04a9babdff0943dc596dbc68e38.tar.gz geiser-chez-c09f5bbaa836d04a9babdff0943dc596dbc68e38.tar.bz2 |
Module completion generalized and implemented for PLT.
Diffstat (limited to 'scheme/plt/geiser')
-rw-r--r-- | scheme/plt/geiser/modules.ss | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/scheme/plt/geiser/modules.ss b/scheme/plt/geiser/modules.ss index 9ccb421..a1094af 100644 --- a/scheme/plt/geiser/modules.ss +++ b/scheme/plt/geiser/modules.ss @@ -26,7 +26,8 @@ module-spec->namespace namespace->module-path-name module-path-name->name - module-spec->path-name) + module-spec->path-name + module-list) (require srfi/13 scheme/enter) @@ -84,4 +85,43 @@ ((symbol? path) (symbol->string path)) (else "<top>"))) + +(define (skippable-dir? path) + (call-with-values (lambda () (split-path path)) + (lambda (_ basename __) + (member (path->string basename) '(".svn" "compiled"))))) + +(define path->symbol (compose string->symbol path->string)) + +(define (path->entry path) + (and (bytes=? (or (filename-extension path) #"") #"ss") + (let ((path (path->string path))) + (substring path 0 (- (string-length path) 3))))) + +(define (visit-module-path path kind acc) + (case kind + ((file) (let ((entry (path->entry path))) + (if entry (cons entry acc) acc))) + ((dir) (cond ((skippable-dir? path) (values acc #f)) + ((file-exists? (build-path path "main.ss")) + (cons (path->string path) acc)) + (else acc))) + (else acc))) + +(define (find-modules path acc) + (if (directory-exists? path) + (parameterize ((current-directory path)) + (fold-files visit-module-path acc)) + acc)) + +(define module-cache #f) + +(define (module-list) + (when (not module-cache) + (set! module-cache + (sort (foldl find-modules '() (current-library-collection-paths)) + string<?))) + module-cache) + + ;;; modules.ss ends here |