mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
repl: add repl-option for customized print
Closes <http://bugs.gnu.org/13077>. * module/system/repl/common.scm (repl-default-options) (repl-print): Add option to use customized print procedure. * doc/ref/scheme-using.texi (REPL Commands): Update.
This commit is contained in:
parent
9977b31643
commit
afdf5467e5
2 changed files with 19 additions and 6 deletions
|
@ -445,6 +445,10 @@ choice is available. Off by default (indicating compilation).
|
|||
@item prompt
|
||||
A customized REPL prompt. @code{#f} by default, indicating the default
|
||||
prompt.
|
||||
@item print
|
||||
A procedure of two arguments used to print the result of evaluating each
|
||||
expression. The arguments are the current REPL and the value to print.
|
||||
By default, @code{#f}, to use the default procedure.
|
||||
@item value-history
|
||||
Whether value history is on or not. @xref{Value History}.
|
||||
@item on-error
|
||||
|
|
|
@ -119,6 +119,11 @@ See <http://www.gnu.org/licenses/lgpl.html>, for more details.")
|
|||
((thunk? prompt) (lambda (repl) (prompt)))
|
||||
((procedure? prompt) prompt)
|
||||
(else (error "Invalid prompt" prompt)))))
|
||||
(print #f ,(lambda (print)
|
||||
(cond
|
||||
((not print) #f)
|
||||
((procedure? print) print)
|
||||
(else (error "Invalid print procedure" print)))))
|
||||
(value-history
|
||||
,(value-history-enabled?)
|
||||
,(lambda (x)
|
||||
|
@ -209,12 +214,16 @@ See <http://www.gnu.org/licenses/lgpl.html>, for more details.")
|
|||
(if (not (eq? val *unspecified*))
|
||||
(begin
|
||||
(run-hook before-print-hook val)
|
||||
;; The result of an evaluation is representable in scheme, and
|
||||
;; should be printed with the generic printer, `write'. The
|
||||
;; language-printer is something else: it prints expressions of
|
||||
;; a given language, not the result of evaluation.
|
||||
(write val)
|
||||
(newline))))
|
||||
(cond
|
||||
((repl-option-ref repl 'print)
|
||||
=> (lambda (print) (print repl val)))
|
||||
(else
|
||||
;; The result of an evaluation is representable in scheme, and
|
||||
;; should be printed with the generic printer, `write'. The
|
||||
;; language-printer is something else: it prints expressions of
|
||||
;; a given language, not the result of evaluation.
|
||||
(write val)
|
||||
(newline))))))
|
||||
|
||||
(define (repl-option-ref repl key)
|
||||
(cadr (or (assq key (repl-options repl))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue