From cdab9fc6250ffa86467156d50b88834c28922b16 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 17 Dec 2010 13:27:43 +0100 Subject: [PATCH] add ,reload meta-command and document it and reload-module * module/ice-9/boot-9.scm (reload-module): Add docstring. * module/system/repl/command.scm (reload): New meta-command. * doc/ref/scheme-using.texi (Module Commands): Document the ,reload meta-command. * doc/ref/api-modules.texi (Module System Reflection): Document reload-module. --- doc/ref/api-modules.texi | 5 +++++ doc/ref/scheme-using.texi | 4 ++++ module/ice-9/boot-9.scm | 1 + module/system/repl/command.scm | 11 ++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi index 709aa7312..8e778c735 100644 --- a/doc/ref/api-modules.texi +++ b/doc/ref/api-modules.texi @@ -563,6 +563,11 @@ arguments should be module objects, and @var{interface} should very likely be a module returned by @code{resolve-interface}. @end deffn +@deffn {Scheme Procedure} reload-module module +Revisit the source file that corresponds to @var{module}. Raises an +error if no source file is associated with the given module. +@end deffn + @node Included Guile Modules @subsection Included Guile Modules diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi index 7700cbe9b..126b84590 100644 --- a/doc/ref/scheme-using.texi +++ b/doc/ref/scheme-using.texi @@ -223,6 +223,10 @@ Import modules / List those imported. Load a file in the current module. @end deffn +@deffn {REPL Command} reload [module] +Reload the given module, or the current module if none was given. +@end deffn + @deffn {REPL Command} binding List current bindings. @end deffn diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 1b2985d25..dc1056706 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -2276,6 +2276,7 @@ VALUE." (try-module-autoload name version)) (define (reload-module m) + "Revisit the source file corresponding to the module @var{m}." (let ((f (module-filename m))) (if f (save-module-excursion diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm index 08f1c9e08..2897b9bad 100644 --- a/module/system/repl/command.scm +++ b/module/system/repl/command.scm @@ -50,7 +50,7 @@ (define *command-table* '((help (help h) (show) (apropos a) (describe d)) - (module (module m) (import use) (load l) (binding b) (in)) + (module (module m) (import use) (load l) (reload re) (binding b) (in)) (language (language L)) (compile (compile c) (compile-file cc) (disassemble x) (disassemble-file xx)) @@ -391,6 +391,15 @@ Import modules / List those imported." Load a file in the current module." (load (->string file))) +(define-meta-command (reload repl . args) + "reload [MODULE] +Reload the given module, or the current module if none was given." + (pmatch args + (() (reload-module (current-module))) + ((,mod-name) (guard (list? mod-name)) + (reload-module (resolve-module mod-name))) + (,mod-name (reload-module (resolve-module mod-name))))) + (define-meta-command (binding repl) "binding List current bindings."