From: nalaginrut <nalaginrut@gmail.com>
To: Daniel Hartwig <mandyke@gmail.com>, guile-devel@gnu.org
Cc: 13077@debbugs.gnu.org
Subject: Re: bug#13077: guile: add repl-option for customized print
Date: Tue, 04 Dec 2012 13:19:18 +0800 [thread overview]
Message-ID: <1354598358.25329.4.camel@Renee-desktop.suse> (raw)
In-Reply-To: <87hao21nte.fsf@gmail.com>
Hi Daniel!
I believe this patch simplified my work, and 'colorized' module has been
finished, I'm testing and debugging.
I'll post it when it's all done.
Thanks!
On Tue, 2012-12-04 at 11:46 +0800, Daniel Hartwig wrote:
> Package: guile
> Severity: wishlist
> Tags: patch
> X-Debbugs-CC: nalaginrut <nalaginrut@gmail.com>
>
> Dear maintainer
>
> The attached patch adds a new repl-option to set a custom print
> procedure.
>
> --
> scheme@(guile-user)> (use-modules (srfi srfi-1))
> scheme@(guile-user)> (iota 20)
> $1 = (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
> scheme@(guile-user)> (define (repl-print* repl val)
> (if (not (eq? val *unspecified*))
> (begin
> (run-hook before-print-hook val)
> (format #t "~20@y" val)
> (newline))))
> scheme@(guile-user)> (use-modules (system repl common))
> scheme@(guile-user)> (repl-option-set! (car (fluid-ref *repl-stack*)) 'print repl-print*)
> scheme@(guile-user)> (iota 20)
> $2 = (0 1 2 3 4 5 6 7 …)
> differences between files attachment
> (0001-repl-add-repl-option-for-customized-print.patch)
> From b0cadcb69a12a4ed2a205f4854af41bf926da20b Mon Sep 17 00:00:00 2001
> From: Daniel Hartwig <mandyke@gmail.com>
> Date: Tue, 4 Dec 2012 11:41:35 +0800
> Subject: [PATCH] repl: add repl-option for customized print
>
> * 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.
> ---
> doc/ref/scheme-using.texi | 4 ++++
> module/system/repl/common.scm | 26 +++++++++++++++++---------
> 2 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi
> index 7eb84de..4f9e6db 100644
> --- a/doc/ref/scheme-using.texi
> +++ b/doc/ref/scheme-using.texi
> @@ -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
> diff --git a/module/system/repl/common.scm b/module/system/repl/common.scm
> index 346ba99..fd41b09 100644
> --- a/module/system/repl/common.scm
> +++ b/module/system/repl/common.scm
> @@ -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)
> @@ -206,15 +211,18 @@ See <http://www.gnu.org/licenses/lgpl.html>, for more details.")
> (% (thunk))))
>
> (define (repl-print repl val)
> - (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)))
> + ((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)))))
>
> (define (repl-option-ref repl key)
> (cadr (or (assq key (repl-options repl))
next parent reply other threads:[~2012-12-04 5:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87hao21nte.fsf@gmail.com>
2012-12-04 5:19 ` nalaginrut [this message]
2012-12-04 5:34 ` bug#13077: guile: add repl-option for customized print Daniel Hartwig
2012-12-04 6:30 ` nalaginrut
2012-12-04 6:34 ` Daniel Hartwig
2012-12-12 4:03 ` Nala Ginrut
2012-12-12 5:00 ` Daniel Hartwig
2012-12-12 5:49 ` Nala Ginrut
[not found] ` <CAN3veRdDA-LwBhu7_Uthfj1h7HGzvFOPLoOtkoyd-MQOA+1Xug@mail.gmail.com>
2012-12-12 6:03 ` Daniel Hartwig
[not found] ` <CAN3veReRKhsGip-jev8YyYf_xbTLFFK-bEN=9bR8BddatGWLKg__21131.9749746055$1354599399$gmane$org@mail.gmail.com>
2012-12-04 6:39 ` Thien-Thi Nguyen
2012-12-04 7:36 ` Daniel Hartwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354598358.25329.4.camel@Renee-desktop.suse \
--to=nalaginrut@gmail.com \
--cc=13077@debbugs.gnu.org \
--cc=guile-devel@gnu.org \
--cc=mandyke@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).