,option evaluates its right-hand-side
authorAndy Wingo <wingo@pobox.com>
Thu, 7 Mar 2013 10:29:01 +0000 (11:29 +0100)
committerAndy Wingo <wingo@pobox.com>
Thu, 7 Mar 2013 10:29:01 +0000 (11:29 +0100)
* doc/ref/scheme-using.texi (System Commands): Better documentation for
  ,option.

* module/system/repl/command.scm (option): Evaluate the RHS when setting
  an option.  Fixes bug 13076.

doc/ref/scheme-using.texi
module/system/repl/command.scm

index e0f91af..8157660 100644 (file)
@@ -430,8 +430,11 @@ Garbage collection.
 Display statistics.
 @end deffn
 
-@deffn {REPL Command} option [key value]
-List/show/set options.
+@deffn {REPL Command} option [name] [exp]
+With no arguments, lists all options.  With one argument, shows the
+current value of the @var{name} option.  With two arguments, sets the
+@var{name} option to the result of evaluating the Scheme expression
+@var{exp}.
 @end deffn
 
 @deffn {REPL Command} quit
index c4e9e2c..8ad00da 100644 (file)
@@ -351,18 +351,20 @@ Show description/documentation."
   (newline))
 
 (define-meta-command (option repl . args)
-  "option [KEY VALUE]
+  "option [NAME] [EXP]
 List/show/set options."
   (pmatch args
     (()
      (for-each (lambda (spec)
                 (format #t "  ~A~24t~A\n" (car spec) (cadr spec)))
               (repl-options repl)))
-    ((,key)
-     (display (repl-option-ref repl key))
+    ((,name)
+     (display (repl-option-ref repl name))
      (newline))
-    ((,key ,val)
-     (repl-option-set! repl key val))))
+    ((,name ,exp)
+     ;; Would be nice to evaluate in the current language, but the REPL
+     ;; option parser doesn't permit that, currently.
+     (repl-option-set! repl name (eval exp (current-module))))))
 
 (define-meta-command (quit repl)
   "quit