unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* WRITE & linefeed
@ 2011-06-19 21:27 Ian Price
  2011-06-22 21:49 ` Neil Jerram
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Price @ 2011-06-19 21:27 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Hello guilers,

There's a small aesthetic issue that's been bothering me for a
while. Namely, newlines aren't treated like other escape sequences when
printed with WRITE.

scheme@(guile-user)> (write "\n")
"
"scheme@(guile-user)>

Now, I can see why this would be useful when printing multiple line
strings, but the inconsistency with e.g. "\t\f" irks me. What do the
rest of you think?

I've also attached the patch I've been using to fix this for me.
-- 
Ian Price

"There are only two hard problems in Computer Science: cache invalidation
and naming things." - Phil Karlton


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix write --]
[-- Type: text/x-patch, Size: 1222 bytes --]

From 81bf0d0a4c47b1146395fd9282c1fc2ac3d495d4 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Sun, 19 Jun 2011 12:30:26 +0100
Subject: [PATCH] use escape sequence when printing newlines with 'write'

* libguile/print.c (write_character_escaped, write_character):
  Use '\n' escape sequence rather than the character 0xa0 when printing
  strings with WRITE.
---
 libguile/print.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libguile/print.c b/libguile/print.c
index 4afd12c..e215f3f 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -1022,7 +1022,7 @@ write_character_escaped (scm_t_wchar ch, int string_escapes_p, SCM port)
       static const char escapes[7] = "abtnvfr";
       char buf[9];
 
-      if (ch >= 0x07 && ch <= 0x0D && ch != 0x0A)
+      if (ch >= 0x07 && ch <= 0x0D)
 	{
 	  /* Use special escapes for some C0 controls.  */
 	  buf[0] = '\\';
@@ -1119,7 +1119,7 @@ write_character (scm_t_wchar ch, SCM port, int string_escapes_p)
 	  display_character (ch, port, strategy);
 	  printed = 1;
 	}
-      else if (ch == ' ' || ch == '\n')
+      else if (ch == ' ')
 	{
 	  display_character (ch, port, strategy);
 	  printed = 1;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: WRITE & linefeed
  2011-06-19 21:27 WRITE & linefeed Ian Price
@ 2011-06-22 21:49 ` Neil Jerram
  2011-12-04 21:37   ` Andy Wingo
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Jerram @ 2011-06-22 21:49 UTC (permalink / raw)
  To: Ian Price; +Cc: guile-devel

Ian Price <ianprice90@googlemail.com> writes:

> Hello guilers,
>
> There's a small aesthetic issue that's been bothering me for a
> while. Namely, newlines aren't treated like other escape sequences when
> printed with WRITE.
>
> scheme@(guile-user)> (write "\n")
> "
> "scheme@(guile-user)>
>
> Now, I can see why this would be useful when printing multiple line
> strings, but the inconsistency with e.g. "\t\f" irks me. What do the
> rest of you think?

I agree, but I can imagine that there is a case for the current
behaviour too, and it's nice to preserve back-compatibility.  Emacs has
`print-escape-newlines', and I guess we need something like that here -
an addition to `print-options'?

       Neil



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: WRITE & linefeed
  2011-06-22 21:49 ` Neil Jerram
@ 2011-12-04 21:37   ` Andy Wingo
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2011-12-04 21:37 UTC (permalink / raw)
  To: Neil Jerram; +Cc: Ian Price, guile-devel

Hi,

On Wed 22 Jun 2011 23:49, Neil Jerram <neil@ossau.uklinux.net> writes:

> Ian Price <ianprice90@googlemail.com> writes:
>
>> There's a small aesthetic issue that's been bothering me for a
>> while. Namely, newlines aren't treated like other escape sequences when
>> printed with WRITE.
>>
>> scheme@(guile-user)> (write "\n")
>> "
>> "
>
> I agree, but I can imagine that there is a case for the current
> behaviour too, and it's nice to preserve back-compatibility.  Emacs has
> `print-escape-newlines', and I guess we need something like that here -
> an addition to `print-options'?

Good idea.  I implemented this, and will push by the time you get this
mail.  The default is to escape newlines.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-04 21:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-19 21:27 WRITE & linefeed Ian Price
2011-06-22 21:49 ` Neil Jerram
2011-12-04 21:37   ` Andy Wingo

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).