unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Andy Wingo <wingo@pobox.com>
Cc: Mark H Weaver <mhw@netris.org>, guile-devel@gnu.org
Subject: Re: [PATCH] Do not scan for coding declarations in open-file
Date: Thu, 31 Jan 2013 23:00:54 +0100	[thread overview]
Message-ID: <87ip6dhv5l.fsf@gnu.org> (raw)
In-Reply-To: <87mwvpwu2b.fsf@pobox.com> (Andy Wingo's message of "Thu, 31 Jan 2013 11:00:44 +0100")

Andy Wingo <wingo@pobox.com> skribis:

> On Thu 31 Jan 2013 06:06, Mark H Weaver <mhw@netris.org> writes:
>
>> From: Mark H Weaver <mhw@netris.org>
>> Date: Wed, 30 Jan 2013 14:45:28 -0500
>> Subject: [PATCH] Do not scan for coding declarations in open-file.
>
> The patch looks good to me but I am concerned about the behavior
> change, and that it is inconvenient to get the previous behavior.

I’m concerned too.

However, I’ve been explicitly using ‘file-encoding’ “forever” when I
really wanted to handle coding cookies.  Actually the doc even
explicitly recommends this (info "(guile) Character Encoding of Source
Files"):

     If a port is used to read code of unknown character encoding, it can
  accomplish this in three steps.  First, the character encoding of the
  port should be set to ISO-8859-1 using `set-port-encoding!'.  Then, the
  procedure `file-encoding', described below, is used to scan for a
  coding declaration when reading from the port.  As a side effect, it
  rewinds the port after its scan is complete. After that, the port's
  character encoding should be set to the encoding returned by
  `file-encoding', if any, again by using `set-port-encoding!'.  Then the
  code can be read as normal.

Considering this, it is tempting to think that removing that
scm_i_scan_for_encoding call would be a bug fix.

WDYT?

> My instinct is that we should not merge this patch without including a
> way to enable the coding sniff; which seems to mean adding keywords or
> somehow extending the arguments of:
>
>   open-file
>   with-input-from-file
>   with-output-to-file
>   call-with-output-file
>   call-with-input-file
>   open-input-file
>
> Dunno; that is a larger task.  I'd be interested in Ludovic's thoughts
> as well.

There are several issues IMO.  First, some are subrs, so handling
keyword arguments is going to be painful.  Second, keyword arguments are
inelegant IMO compared to:

  (set-port-encoding! port (file-encoding port))

Thanks,
Ludo’.



  parent reply	other threads:[~2013-01-31 22:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13 18:25 Scanning for coding declarations in all files (not just source) Mark H Weaver
2013-01-13 19:51 ` Mike Gran
2013-01-15  9:32 ` Ludovic Courtès
2013-01-22 11:38   ` Andy Wingo
2013-01-31  5:06     ` [PATCH] Do not scan for coding declarations in open-file Mark H Weaver
2013-01-31 10:00       ` Andy Wingo
2013-01-31 18:58         ` Mark H Weaver
2013-01-31 20:04           ` Andy Wingo
2013-01-31 22:00         ` Ludovic Courtès [this message]
2013-01-31 22:19           ` Noah Lavine
2013-01-31 21:51       ` Ludovic Courtès

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=87ip6dhv5l.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    --cc=wingo@pobox.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).