From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.devel Subject: Re: bug#13077: guile: add repl-option for customized print Date: Wed, 12 Dec 2012 12:03:25 +0800 Organization: HFG Message-ID: <1355285005.2835.14.camel@Renee-desktop.suse> References: <87hao21nte.fsf@gmail.com> <1354598358.25329.4.camel@Renee-desktop.suse> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1355285031 5426 80.91.229.3 (12 Dec 2012 04:03:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Dec 2012 04:03:51 +0000 (UTC) Cc: 13077@debbugs.gnu.org, guile-devel@gnu.org To: Daniel Hartwig Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 12 05:04:04 2012 Return-path: Envelope-to: guile-devel@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 1TidY7-0002bK-6Y for guile-devel@m.gmane.org; Wed, 12 Dec 2012 05:03:59 +0100 Original-Received: from localhost ([::1]:42689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TidXu-0008Sx-ID for guile-devel@m.gmane.org; Tue, 11 Dec 2012 23:03:46 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TidXm-0008S0-Ph for guile-devel@gnu.org; Tue, 11 Dec 2012 23:03:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TidXg-00077s-PD for guile-devel@gnu.org; Tue, 11 Dec 2012 23:03:38 -0500 Original-Received: from mail-qa0-f53.google.com ([209.85.216.53]:42374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TidXg-00077n-LY for guile-devel@gnu.org; Tue, 11 Dec 2012 23:03:32 -0500 Original-Received: by mail-qa0-f53.google.com with SMTP id a19so280675qad.12 for ; Tue, 11 Dec 2012 20:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:mime-version :content-transfer-encoding; bh=R7S3kV7Si5w9vtDrigyotpKeIsZkb71iMB9qZyPjmP4=; b=vymf3gTF26ufvDIJRSXoDfyooy5am2Tvv/ESeYOmxqoz2YFL++Z5SC+6dTIj4ImPnU +SX2PGuq7BEy7patALAl76DFCnLfu7A7fI39Pem+kcLPpDxSRbUCncMtZp1DoSDY7cjq bePRfF9zF78QOPQBF4Q9/ii8FJmbzfYozE3cN00RoaklK2O/RIp6Eee+IC1qBjAmeHo/ 4qO4sCRhg6QpC7Mq1Fgn5FKvulOLnvaRIjqkk4YU/t9eJZzrl4aTfPJaLXe+Wa2PH7aG 4/2sdW9XC2hzgH+TGnCq683CfoNPIx2RBJPxPkC1rA+zQN4hMobwanQyMRi9EB41x1lx MHhA== Original-Received: by 10.224.35.137 with SMTP id p9mr911217qad.85.1355285012182; Tue, 11 Dec 2012 20:03:32 -0800 (PST) Original-Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id eg9sm19035181qab.13.2012.12.11.20.03.29 (version=SSLv3 cipher=OTHER); Tue, 11 Dec 2012 20:03:31 -0800 (PST) In-Reply-To: X-Mailer: Evolution 3.4.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.53 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15332 Archived-At: hi Daniel! Custom color-scheme is done now! ;-D But we have a problem... :-( It's OK to test this code in the REPL: --------------------cut------------------- (use-modules (ice-9 colorized)) (add-color-scheme! `((,(lambda (data) (and (number? data) (> data 10000))) MY-LONG-NUM ,color-it (RED)))) (activate-colorized) --------------------end------------------- But when I put these lines into our ~/.guile, it throw error: ----------------err msg---------------- In /usr/local/share/guile/2.0/ice-9/colorized.scm: 31: 0 [activate-colorized] /usr/local/share/guile/2.0/ice-9/colorized.scm:31:20: In procedure activate-colorized: /usr/local/share/guile/2.0/ice-9/colorized.scm:31:20: In procedure car: Wrong type argument in position 1 (expecting pair): () ------------------end------------------ Seems (fluid-ref *repl-stack*) is not a pair/list when REPL is just started? Please checkout here: https://github.com/NalaGinrut/guile-colorized/blob/upstream/ice-9/colorized.scm#L31 Thanks! On Tue, 2012-12-04 at 13:34 +0800, Daniel Hartwig wrote: > On 4 December 2012 13:19, nalaginrut wrote: > > 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. > > Glad to hear it. > > Attached is an alternate patch that handles before-print-hook and > *unspecified* outside of the custom print procedure, to avoid the need > for boilerplate there. > > -- > scheme@(guile-user)> (define (repl-print* repl 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)> (use-modules (srfi srfi-1)) > scheme@(guile-user)> (iota 20) > $1 = (0 1 2 3 4 5 6 7 …)