add ,reload meta-command and document it and reload-module
authorAndy Wingo <wingo@pobox.com>
Fri, 17 Dec 2010 12:27:43 +0000 (13:27 +0100)
committerAndy Wingo <wingo@pobox.com>
Fri, 17 Dec 2010 12:27:43 +0000 (13:27 +0100)
* 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
doc/ref/scheme-using.texi
module/ice-9/boot-9.scm
module/system/repl/command.scm

index 709aa73..8e778c7 100644 (file)
@@ -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
index 7700cbe..126b845 100644 (file)
@@ -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
index 1b2985d..dc10567 100644 (file)
@@ -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
index 08f1c9e..2897b9b 100644 (file)
@@ -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."