From bfcb656cd2f17b6cfc90afa0c535c95294863558 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 2 May 2009 22:38:32 +0200 Subject: PLT: better module name in REPL prompt. --- scheme/plt/geiser/eval.ss | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'scheme') diff --git a/scheme/plt/geiser/eval.ss b/scheme/plt/geiser/eval.ss index ad69836..0490c1e 100644 --- a/scheme/plt/geiser/eval.ss +++ b/scheme/plt/geiser/eval.ss @@ -32,7 +32,7 @@ compile-file make-repl-reader) -(require scheme/enter) +(require scheme/enter srfi/13) (define last-result (void)) (define nowhere (open-output-nowhere)) @@ -66,9 +66,20 @@ (resolved-module-path-name rmp)))) (define (namespace->module-name ns) - (let ((path (or (namespace->module-path-name ns) ""))) - (call-with-values (lambda () (split-path path)) - (lambda (_ basename __) basename)))) + (let ((path (namespace->module-path-name ns))) + (if (not path) + "" + (let* ((path (path->string path)) + (cpaths (map path->string (current-library-collection-paths))) + (prefix-len (lambda (p) + (let ((pl (string-length p))) + (if (= pl (string-prefix-length p path)) pl 0)))) + (lens (map prefix-len cpaths)) + (real-path (substring path (apply max lens)))) + (if (absolute-path? real-path) + (call-with-values (lambda () (split-path path)) + (lambda (_ basename __) basename)) + (regexp-replace "\\.[^./]*$" real-path "")))))) (define last-namespace (make-parameter (current-namespace))) -- cgit v1.2.3