From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCHES] Keyword args for file openers; coding scan off by default Date: Sun, 07 Apr 2013 15:00:37 +0200 Message-ID: <87y5cuv6kq.fsf@gnu.org> References: <878v4uu92d.fsf@tines.lan> 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 1365339660 9448 80.91.229.3 (7 Apr 2013 13:01:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Apr 2013 13:01:00 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Apr 07 15:01:04 2013 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 1UOpDQ-0002Nr-Ua for guile-devel@m.gmane.org; Sun, 07 Apr 2013 15:01:01 +0200 Original-Received: from localhost ([::1]:41514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOpDQ-0003Ou-Hk for guile-devel@m.gmane.org; Sun, 07 Apr 2013 09:01:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOpDK-0003On-AP for guile-devel@gnu.org; Sun, 07 Apr 2013 09:00:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UOpDI-0004cs-Kc for guile-devel@gnu.org; Sun, 07 Apr 2013 09:00:54 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOpDI-0004ch-7i for guile-devel@gnu.org; Sun, 07 Apr 2013 09:00:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UOpDE-00028k-Q5 for guile-devel@gnu.org; Sun, 07 Apr 2013 15:00:48 +0200 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Apr 2013 15:00:48 +0200 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Apr 2013 15:00:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 Germinal an 221 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:VmNujmL5KMn04zl/M7X55Y4yFYo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:16185 Archived-At: Mark H Weaver skribis: > From bb621dbbc0df691bcad541267a08c86c36d9062b Mon Sep 17 00:00:00 2001 > From: Mark H Weaver > Date: Wed, 30 Jan 2013 14:45:28 -0500 > Subject: [PATCH 1/3] Do not scan for coding declarations in open-file. > > * libguile/fports.c (scm_open_file): Do not scan for coding > declarations. Replace 'use_encoding' local variable with > 'binary'. Update documentation string. > > * module/ice-9/psyntax.scm (include): Add the same file-encoding > logic that's used in compile-file and scm_primitive_load. > > * module/ice-9/psyntax-pp.scm: Regenerate. > > * doc/ref/api-io.texi (File Ports): Update docs. > > * test-suite/tests/ports.test: Change "open-file HONORS file coding > declarations" test to "open-file IGNORES file coding declaration". > > * test-suite/tests/coding.test (scan-coding): Use 'file-encoding' to > scan for the encoding, since 'open-input-file' no longer does so. Perfect! > @@ -903,13 +903,6 @@ because of its port encoding ramifications. > If a file cannot be opened with the access > requested, @code{open-file} throws an exception. > > -When the file is opened, this procedure will scan for a coding > -declaration (@pxref{Character Encoding of Source Files}). If a coding > -declaration is found, it will be used to interpret the file. Otherwise, > -the port's encoding will be used. To suppress this behavior, open the > -file in binary mode and then set the port encoding explicitly using > -@code{set-port-encoding!}. Can we change that to something like: When the file is opened, its encoding is inherited set to the current @code{%default-port-encoding}, unless the @code{b} flag was supplied. Sometimes it is desirable to honor Emacs-style coding declarations in files@footnote{Guile 2.0.0 to 2.0.7 would do this by default. This behavior was deemed inappropriate and disabled starting from Guile 2.0.8.}. When that is the case, the @code{file-encoding} declaration can be used as follows (@pxref{Character Encoding of Source Files, @code{file-encoding}}): @example (let* ((port (open-input-file file)) (encoding (file-encoding port))) (set-port-encoding! port (or encoding (port-encoding port)))) @end example (I let you choose whether to also add it to the docstring or not.) Ludo’.