GNU bug report logs - #9664
(format #t "~3tX") fails in the REPL

Previous Next

Package: guile;

Reported by: rixed <at> happyleptic.org

Date: Mon, 3 Oct 2011 20:05:02 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9664 in the body.
You can then email your comments to 9664 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#9664; Package guile. (Mon, 03 Oct 2011 20:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to rixed <at> happyleptic.org:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Mon, 03 Oct 2011 20:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: rixed <at> happyleptic.org
To: bug-guile <at> gnu.org
Subject: (format #t "~3tX") fails in the REPL
Date: Mon, 3 Oct 2011 21:59:48 +0200
The ~t formater is not working according to spec in the REPL.
Try this for instance:

(format #t "~10tA~20tB~30tC~40tD")

will print:

AB       C         D

Although it works from a script or when outputing to a sting.

Also, it works after a newline.





Information forwarded to bug-guile <at> gnu.org:
bug#9664; Package guile. (Tue, 04 Oct 2011 16:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 9664 <at> debbugs.gnu.org (full text, mbox):

From: Ian Price <ianprice90 <at> googlemail.com>
To: 9664 <at> debbugs.gnu.org
Subject: bug#9664: (format #t "~3tX") fails in the REPL
Date: Tue, 04 Oct 2011 11:59:11 +0100
[Message part 1 (text/plain, inline)]
When an expression is evaluated, the port-column is not 0. You can see
this by typing (write (port-column (current-output-port))) at the
repl. This means that when you do ~3t, it will not generate any spaces
as it is already past column 3.

This can be fixed by resetting port-position before we evaluate the REPL
expression.

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
[0001-Reset-port-column-before-evaluating-at-REPL.patch (text/x-patch, inline)]
From 7a457be8c43051817b18d425a76b296f0f1fc730 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90 <at> googlemail.com>
Date: Tue, 4 Oct 2011 00:30:39 +0100
Subject: [PATCH] Reset port column before evaluating at REPL.

* module/system/repl/repl.scm (run-repl): Column-dependant commands
  like the '~t' directive to format behave unexpectedly if column
  number isn't reset.
---
 module/system/repl/repl.scm |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index 1cffa71..d028f38 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -190,6 +190,7 @@
                                (run-hook before-eval-hook exp)
                                (call-with-error-handling
                                 (lambda ()
+                                  (set-port-column! (current-output-port) 0)
                                   (with-stack-and-prompt thunk))
                                 #:on-error (repl-option-ref repl 'on-error)))
                              (lambda (k) (values))))
-- 
1.7.6.4


Information forwarded to bug-guile <at> gnu.org:
bug#9664; Package guile. (Wed, 05 Oct 2011 18:19:02 GMT) Full text and rfc822 format available.

Message #11 received at 9664 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: rixed <at> happyleptic.org
Cc: 9664 <at> debbugs.gnu.org
Subject: Re: bug#9664: (format #t "~3tX") fails in the REPL
Date: Wed, 05 Oct 2011 20:18:26 +0200
On Mon 03 Oct 2011 21:59, rixed <at> happyleptic.org writes:

> The ~t formater is not working according to spec in the REPL.
> Try this for instance:
>
> (format #t "~10tA~20tB~30tC~40tD")
>
> will print:
>
> AB       C         D
>
> Although it works from a script or when outputing to a sting.
>
> Also, it works after a newline.

It appears that there is some difference between the readline-enabled
reader and the normal one.

    $ meta/guile -q
    scheme@(guile-user)> (port-column (current-output-port))
    $1 = 21

It is 0 with the readline reader.

I don't think the set-port-column! fix is right.  Why is the newline not
being chomped after the `(read)', I wonder?

Andy
-- 
http://wingolog.org/




Reply sent to Andy Wingo <wingo <at> pobox.com>:
You have taken responsibility. (Wed, 16 Nov 2011 22:16:01 GMT) Full text and rfc822 format available.

Notification sent to rixed <at> happyleptic.org:
bug acknowledged by developer. (Wed, 16 Nov 2011 22:16:02 GMT) Full text and rfc822 format available.

Message #16 received at 9664-done <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: rixed <at> happyleptic.org
Cc: 9664-done <at> debbugs.gnu.org
Subject: Re: bug#9664: (format #t "~3tX") fails in the REPL
Date: Wed, 16 Nov 2011 23:15:00 +0100
On Wed 05 Oct 2011 20:18, Andy Wingo <wingo <at> pobox.com> writes:

> It appears that there is some difference between the readline-enabled
> reader and the normal one.
>
>     $ meta/guile -q
>     scheme@(guile-user)> (port-column (current-output-port))
>     $1 = 21
>
> It is 0 with the readline reader.
>
> I don't think the set-port-column! fix is right.  Why is the newline not
> being chomped after the `(read)', I wonder?

That isn't the right question, it turns out.  21 is the length of the
`scheme@(guile-user)> ' prompt.  We need to set the output port column
to 0 after printing a prompt.  In the readline case it's different
because readline is the part that prints the prompt.

Fixed in stable-2.0.

Thanks for the report,

Andy
-- 
http://wingolog.org/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Dec 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 248 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.