From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Hartwig Newsgroups: gmane.lisp.guile.bugs Subject: bug#13077: guile: add repl-option for customized print Date: Tue, 04 Dec 2012 11:46:53 +0800 Message-ID: <87hao21nte.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1354592864 21333 80.91.229.3 (4 Dec 2012 03:47:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Dec 2012 03:47:44 +0000 (UTC) Cc: nalaginrut To: 13077@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Dec 04 04:47:57 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TfjUA-0006Iy-3b for guile-bugs@m.gmane.org; Tue, 04 Dec 2012 04:47:54 +0100 Original-Received: from localhost ([::1]:58978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfjTx-0004kO-QL for guile-bugs@m.gmane.org; Mon, 03 Dec 2012 22:47:41 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfjTu-0004kI-RX for bug-guile@gnu.org; Mon, 03 Dec 2012 22:47:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfjTt-0004I6-Fn for bug-guile@gnu.org; Mon, 03 Dec 2012 22:47:38 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfjTt-0004I1-9S for bug-guile@gnu.org; Mon, 03 Dec 2012 22:47:37 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TfjWE-0003kQ-EX; Mon, 03 Dec 2012 22:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Hartwig Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: nalaginrut@gmail.com, bug-guile@gnu.org Resent-Date: Tue, 04 Dec 2012 03:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13077 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: submit@debbugs.gnu.org X-Debbugs-Original-Xcc: nalaginrut Original-Received: via spool by submit@debbugs.gnu.org id=B.135459298014372 (code B ref -1); Tue, 04 Dec 2012 03:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Dec 2012 03:49:40 +0000 Original-Received: from localhost ([127.0.0.1]:52288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfjVr-0003jk-An for submit@debbugs.gnu.org; Mon, 03 Dec 2012 22:49:39 -0500 Original-Received: from mail-pa0-f44.google.com ([209.85.220.44]:33892) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfjVp-0003jd-Mz for submit@debbugs.gnu.org; Mon, 03 Dec 2012 22:49:38 -0500 Original-Received: by mail-pa0-f44.google.com with SMTP id hz11so2272102pad.3 for ; Mon, 03 Dec 2012 19:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=pekVStJZGAr8avkbE0QW2kettPcm1hlcIfBHPKhmz4U=; b=JaDTT7+1SeXCFY2vxFpZkSVO8BzZfsXNUfuIZg/l3Sh77Ze0yM4MifMI5Eevoht2C1 4xwrn6I+sX1sy1fhFsLd7dbivdp9n3y69aLtSR1lGXhiBIVCfoZpvfgpbnjjmi4Yg9yo 3dwwKdHoFCfIwDYA/uuceP94xH9q0Fb24rY9uop8G9yz9YNbxJ+XzNENprwGuZfO0vKZ kRXbHAo5VpoSmqCs/xkOCySFu9eqdI+pq+TOtgT2IsUPL7sCiIHt3zkv9596v9TdCkNO MztALLSH5vYha88PbIPZaWMK6cg6TnOjTWPLau6G9FiIlmfKVF241VOM/6I+5bv0nf/Q 1sbw== Original-Received: by 10.66.80.194 with SMTP id t2mr31450608pax.43.1354592830181; Mon, 03 Dec 2012 19:47:10 -0800 (PST) Original-Received: from io ([101.119.31.219]) by mx.google.com with ESMTPS id ju7sm207199pbb.60.2012.12.03.19.47.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 19:47:09 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6634 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Package: guile Severity: wishlist Tags: patch X-Debbugs-CC: nalaginrut 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 =3D (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*)) 'prin= t repl-print*) scheme@(guile-user)> (iota 20) $2 =3D (0 1 2 3 4 5 6 7 =E2=80=A6) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-repl-add-repl-option-for-customized-print.patch >From b0cadcb69a12a4ed2a205f4854af41bf926da20b Mon Sep 17 00:00:00 2001 From: Daniel Hartwig 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 , 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 , 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)) -- 1.7.10.4 --=-=-=--