unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* propagating a coding setting across source files
@ 2011-12-02  8:06 Sven Hartrumpf
  2011-12-02 10:41 ` rixed
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Sven Hartrumpf @ 2011-12-02  8:06 UTC (permalink / raw)
  To: guile-user

Hi all.

After a long period of working with other Schemes,
I am returning to guile for some tests to see what
Guile has achieved in recent years.

My test program is made up of around 100 scheme files, all
encoded in latin-1.
I added to the master file the following comment:

; coding: iso-8859-1

which works as documented.
How can I avoid to add this comment line to all the other files
which are currently included by the master file using "load"?

Ciao
Sven



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

* Re: propagating a coding setting across source files
  2011-12-02  8:06 propagating a coding setting across source files Sven Hartrumpf
@ 2011-12-02 10:41 ` rixed
  2011-12-02 12:41   ` Paul Smith
  2011-12-02 12:55 ` Mike Gran
  2012-01-09 22:51 ` Andy Wingo
  2 siblings, 1 reply; 16+ messages in thread
From: rixed @ 2011-12-02 10:41 UTC (permalink / raw)
  To: guile-user

-[ Fri, Dec 02, 2011 at 09:06:07AM +0100, Sven Hartrumpf ]----
> How can I avoid to add this comment line to all the other files
> which are currently included by the master file using "load"?

You very possibly have better reasons to refuse to add this line
to your files than the mere trouble of the trouble doing it by
hand, but anyway just in case you need a command to do this
operation here it is:

$ find where-your-files-are -type f -name '*.scm' |
	while read f; do echo '; coding: iso-8859-1' > $f ; done

Although it may be shorter in scheme...



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

* Re: propagating a coding setting across source files
  2011-12-02 10:41 ` rixed
@ 2011-12-02 12:41   ` Paul Smith
  2011-12-02 12:46     ` rixed
  0 siblings, 1 reply; 16+ messages in thread
From: Paul Smith @ 2011-12-02 12:41 UTC (permalink / raw)
  To: rixed; +Cc: guile-user

On Fri, 2011-12-02 at 11:41 +0100, rixed@happyleptic.org wrote:
> $ find where-your-files-are -type f -name '*.scm' |
>         while read f; do echo '; coding: iso-8859-1' > $f ; done

Boy I _really_ don't think you want to do that.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




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

* Re: propagating a coding setting across source files
  2011-12-02 12:41   ` Paul Smith
@ 2011-12-02 12:46     ` rixed
  0 siblings, 0 replies; 16+ messages in thread
From: rixed @ 2011-12-02 12:46 UTC (permalink / raw)
  To: guile-user

-[ Fri, Dec 02, 2011 at 07:41:40AM -0500, Paul Smith ]----
> On Fri, 2011-12-02 at 11:41 +0100, rixed@happyleptic.org wrote:
> > $ find where-your-files-are -type f -name '*.scm' |
> >         while read f; do echo '; coding: iso-8859-1' > $f ; done
> 
> Boy I _really_ don't think you want to do that.

Sure!
That's ">>" not ">" : echo '; coding...' >> $f
                                         ^^
                                         !!

I _really_ hope every one is using a versionning system these days :)




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

* Re: propagating a coding setting across source files
  2011-12-02  8:06 propagating a coding setting across source files Sven Hartrumpf
  2011-12-02 10:41 ` rixed
@ 2011-12-02 12:55 ` Mike Gran
  2011-12-02 13:41   ` Sven Hartrumpf
  2011-12-05 17:25   ` Ludovic Courtès
  2012-01-09 22:51 ` Andy Wingo
  2 siblings, 2 replies; 16+ messages in thread
From: Mike Gran @ 2011-12-02 12:55 UTC (permalink / raw)
  To: Sven Hartrumpf, guile-user@gnu.org

> From: Sven Hartrumpf <hartrumpf@gmx.net>
>My test program is made up of around 100 scheme files, all
>encoded in latin-1.
>I added to the master file the following comment:
>
>; coding: iso-8859-1
>
>which works as documented.
>How can I avoid to add this comment line to all the other files
>which are currently included by the master file using "load"?

I'm pretty sure that, for 2.0.x at least, if you don't
specify an encoding, it presumes iso-8859-1 as the default.
 
-Mike



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

* Re: propagating a coding setting across source files
  2011-12-02 12:55 ` Mike Gran
@ 2011-12-02 13:41   ` Sven Hartrumpf
  2011-12-02 14:23     ` Mike Gran
  2011-12-05 17:25   ` Ludovic Courtès
  1 sibling, 1 reply; 16+ messages in thread
From: Sven Hartrumpf @ 2011-12-02 13:41 UTC (permalink / raw)
  To: guile-user

Fri, 2 Dec 2011 04:55:39 -0800 (PST), spk121 wrote:
> I'm pretty sure that, for 2.0.x at least, if you don't
> specify an encoding, it presumes iso-8859-1 as the default.

Not when loading a file with Latin-1 characters:

> cat aa.scm
(define c #\ä)

> guile
GNU Guile 2.0.3
...
scheme@(guile-user)> (load "aa.scm")
;;; compiling /home/s/aa.scm
;;; WARNING: compilation of /home/s/aa.scm failed:
;;; ERROR: In procedure scm_lreadr: /home/s/aa.scm:1:13: unknown character name 
ERROR: In procedure primitive-load:
ERROR: In procedure scm_lreadr: /home/s/aa.scm:1:13: unknown character name 

Sven



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

* Re: propagating a coding setting across source files
  2011-12-02 13:41   ` Sven Hartrumpf
@ 2011-12-02 14:23     ` Mike Gran
  0 siblings, 0 replies; 16+ messages in thread
From: Mike Gran @ 2011-12-02 14:23 UTC (permalink / raw)
  To: Sven Hartrumpf; +Cc: Guile User

>Not when loading a file with Latin-1 characters:

>
>> cat aa.scm
>(define c #\ä)
>
>> guile
>GNU Guile 2.0.3
>...
>scheme@(guile-user)> (load "aa.scm")
>;;; compiling /home/s/aa.scm
>;;; WARNING: compilation of /home/s/aa.scm failed:
>;;; ERROR: In procedure scm_lreadr: /home/s/aa.scm:1:13: unknown character name 
>ERROR: In procedure primitive-load:
>ERROR: In procedure scm_lreadr: /home/s/aa.scm:1:13: unknown character name 


I guess you're right.  Looks like, at some point, the default for files with
no 'coding:' line got hard set to UTF-8 in 'scm_primitive_load' and 'compile-file'
and friends.


At first, I thought you could do something with %load-hook, or by setting
the %default-port-encoding, but that isn't going to work either.

No workaround is obvious to me.  Hrm.  Unfortunate.

-Mike




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

* Re: propagating a coding setting across source files
  2011-12-02 12:55 ` Mike Gran
  2011-12-02 13:41   ` Sven Hartrumpf
@ 2011-12-05 17:25   ` Ludovic Courtès
  1 sibling, 0 replies; 16+ messages in thread
From: Ludovic Courtès @ 2011-12-05 17:25 UTC (permalink / raw)
  To: guile-user

Hi!

Mike Gran <spk121@yahoo.com> skribis:

> I'm pretty sure that, for 2.0.x at least, if you don't
> specify an encoding, it presumes iso-8859-1 as the default.

No, UTF-8 is the default (info "(guile) Compilation").

Thanks,
Ludo’.




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

* Re: propagating a coding setting across source files
  2011-12-02  8:06 propagating a coding setting across source files Sven Hartrumpf
  2011-12-02 10:41 ` rixed
  2011-12-02 12:55 ` Mike Gran
@ 2012-01-09 22:51 ` Andy Wingo
  2012-01-10  8:51   ` Sven Hartrumpf
  2 siblings, 1 reply; 16+ messages in thread
From: Andy Wingo @ 2012-01-09 22:51 UTC (permalink / raw)
  To: Sven Hartrumpf; +Cc: guile-user

Hi Sven,

On Fri 02 Dec 2011 09:06, Sven Hartrumpf <hartrumpf@gmx.net> writes:

> After a long period of working with other Schemes,
> I am returning to guile for some tests to see what
> Guile has achieved in recent years.

Cool!  Let us know if you find something that smells bad.

> My test program is made up of around 100 scheme files, all
> encoded in latin-1.
> I added to the master file the following comment:
>
> ; coding: iso-8859-1
>
> which works as documented.
> How can I avoid to add this comment line to all the other files
> which are currently included by the master file using "load"?

You can (fluid-set! %default-port-encoding "iso-8859-1").

Let us know if this doesn't work.

Andy
-- 
http://wingolog.org/



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

* Re: propagating a coding setting across source files
  2012-01-09 22:51 ` Andy Wingo
@ 2012-01-10  8:51   ` Sven Hartrumpf
  2012-01-11 18:00     ` Andy Wingo
  0 siblings, 1 reply; 16+ messages in thread
From: Sven Hartrumpf @ 2012-01-10  8:51 UTC (permalink / raw)
  To: guile-user

Hi Andy.

Mon, 09 Jan 2012 23:51:42 +0100, wingo wrote:
>> I added to the master file the following comment:
>>
>> ; coding: iso-8859-1
>>
>> which works as documented.
>> How can I avoid to add this comment line to all the other files
>> which are currently included by the master file using "load"?
> 
> You can (fluid-set! %default-port-encoding "iso-8859-1").
> 
> Let us know if this doesn't work.

If I add this to my master file it does not help.
Where should I put your command?

Sven



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

* Re: propagating a coding setting across source files
  2012-01-10  8:51   ` Sven Hartrumpf
@ 2012-01-11 18:00     ` Andy Wingo
  2012-01-11 18:13       ` Mike Gran
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Wingo @ 2012-01-11 18:00 UTC (permalink / raw)
  To: Sven Hartrumpf; +Cc: guile-user

On Tue 10 Jan 2012 09:51, Sven Hartrumpf <hartrumpf@gmx.net> writes:

> Hi Andy.
>
> Mon, 09 Jan 2012 23:51:42 +0100, wingo wrote:
>>> I added to the master file the following comment:
>>>
>>> ; coding: iso-8859-1
>>>
>>> which works as documented.
>>> How can I avoid to add this comment line to all the other files
>>> which are currently included by the master file using "load"?
>> 
>> You can (fluid-set! %default-port-encoding "iso-8859-1").
>> 
>> Let us know if this doesn't work.
>
> If I add this to my master file it does not help.
> Where should I put your command?

It could be that there is an issue regarding compile-time versus
run-time;

  http://www.gnu.org/software/guile/manual/html_node/Eval-When.html

If you put this at the top of your file, before any use-modules or
anything like that, does it work?

  (eval-when (eval load compile)
    (fluid-set!  %default-port-encoding "iso-8859-1"))

You might need to run with --auto-compile=fresh to invalidate the
caches.

Regards,

Andy
-- 
http://wingolog.org/



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

* Re: propagating a coding setting across source files
  2012-01-11 18:00     ` Andy Wingo
@ 2012-01-11 18:13       ` Mike Gran
  2012-01-15 21:51         ` Ludovic Courtès
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Gran @ 2012-01-11 18:13 UTC (permalink / raw)
  To: Andy Wingo, Sven Hartrumpf; +Cc: guile-user@gnu.org

>>>>  I added to the master file the following comment:
>>>> 
>>>>  ; coding: iso-8859-1
>>>> 
>>>>  which works as documented.
>>>>  How can I avoid to add this comment line to all the other files
>>>>  which are currently included by the master file using 
> "load"?
>>> 
>>>  You can (fluid-set! %default-port-encoding "iso-8859-1").
>>> 
>>>  Let us know if this doesn't work.
>> 
>>  If I add this to my master file it does not help.
>>  Where should I put your command?
> 
> It could be that there is an issue regarding compile-time versus
> run-time;
> 
>   http://www.gnu.org/software/guile/manual/html_node/Eval-When.html
> 
> If you put this at the top of your file, before any use-modules or
> anything like that, does it work?
> 
>   (eval-when (eval load compile)
>     (fluid-set!  %default-port-encoding "iso-8859-1"))
> 
> You might need to run with --auto-compile=fresh to invalidate the
> caches.
 
Hey Andy, 
 
I tried to dig through the logic of this the other day, and I'm not
sure that your suggestion can work.  If "load" ends up calling
"primitive-load", then any file without a "coding:" line is UTF-8.
%default-port-encoding doesn't enter in to it.
 
But there is a lot between "load" and "primitive-load" that I didn't
try to trace through.  I'm not sure under what conditions "load" calls
"primitive load".
 
Thanks,
 
Mike



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

* Re: propagating a coding setting across source files
  2012-01-11 18:13       ` Mike Gran
@ 2012-01-15 21:51         ` Ludovic Courtès
  2012-01-16  9:07           ` Andy Wingo
  0 siblings, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2012-01-15 21:51 UTC (permalink / raw)
  To: guile-user

Hi,

Mike Gran <spk121@yahoo.com> skribis:

> I tried to dig through the logic of this the other day, and I'm not
> sure that your suggestion can work.  If "load" ends up calling
> "primitive-load", then any file without a "coding:" line is UTF-8.
> %default-port-encoding doesn't enter in to it.

Right.  So what Sven is asking for, propagating source file encoding
programmatically, is not possible AFAIK.  Sven: you really need to add
the “coding:” cookie to each and every file.

Thanks,
Ludo’.




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

* Re: propagating a coding setting across source files
  2012-01-15 21:51         ` Ludovic Courtès
@ 2012-01-16  9:07           ` Andy Wingo
  2012-01-16 23:41             ` Ludovic Courtès
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Wingo @ 2012-01-16  9:07 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-user

On Sun 15 Jan 2012 22:51, ludo@gnu.org (Ludovic Courtès) writes:

> Mike Gran <spk121@yahoo.com> skribis:
>
>> I tried to dig through the logic of this the other day, and I'm not
>> sure that your suggestion can work.  If "load" ends up calling
>> "primitive-load", then any file without a "coding:" line is UTF-8.
>> %default-port-encoding doesn't enter in to it.
>
> Right.  So what Sven is asking for, propagating source file encoding
> programmatically, is not possible AFAIK.  Sven: you really need to add
> the “coding:” cookie to each and every file.

Is possible to provide such an interface?

I agree that coding: is the right thing, but there's a lot of legacy
code out there.  If it's possible to support without much effort, we
probably should do so.

Andy
-- 
http://wingolog.org/



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

* Re: propagating a coding setting across source files
  2012-01-16  9:07           ` Andy Wingo
@ 2012-01-16 23:41             ` Ludovic Courtès
  2013-01-07 21:28               ` Andy Wingo
  0 siblings, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2012-01-16 23:41 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-user

Hi!

Andy Wingo <wingo@pobox.com> skribis:

> On Sun 15 Jan 2012 22:51, ludo@gnu.org (Ludovic Courtès) writes:
>
>> Mike Gran <spk121@yahoo.com> skribis:
>>
>>> I tried to dig through the logic of this the other day, and I'm not
>>> sure that your suggestion can work.  If "load" ends up calling
>>> "primitive-load", then any file without a "coding:" line is UTF-8.
>>> %default-port-encoding doesn't enter in to it.
>>
>> Right.  So what Sven is asking for, propagating source file encoding
>> programmatically, is not possible AFAIK.  Sven: you really need to add
>> the “coding:” cookie to each and every file.
>
> Is possible to provide such an interface?

Maybe a ‘guild compile’ option?

Ludo’.



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

* Re: propagating a coding setting across source files
  2012-01-16 23:41             ` Ludovic Courtès
@ 2013-01-07 21:28               ` Andy Wingo
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Wingo @ 2013-01-07 21:28 UTC (permalink / raw)
  To: guile-user, bug-guile

Hi,

Forwarding this one to bug-guile to make a bug report.  I guess we need
a (default-source-file-encoding) parameter.

Andy

On Tue 17 Jan 2012 00:41, ludo@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wingo@pobox.com> skribis:
>
>> On Sun 15 Jan 2012 22:51, ludo@gnu.org (Ludovic Courtès) writes:
>>
>>> Mike Gran <spk121@yahoo.com> skribis:
>>>
>>>> I tried to dig through the logic of this the other day, and I'm not
>>>> sure that your suggestion can work.  If "load" ends up calling
>>>> "primitive-load", then any file without a "coding:" line is UTF-8.
>>>> %default-port-encoding doesn't enter in to it.
>>>
>>> Right.  So what Sven is asking for, propagating source file encoding
>>> programmatically, is not possible AFAIK.  Sven: you really need to add
>>> the “coding:” cookie to each and every file.
>>
>> Is possible to provide such an interface?
>
> Maybe a ‘guild compile’ option?
>
> Ludo’.

-- 
http://wingolog.org/



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

end of thread, other threads:[~2013-01-07 21:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02  8:06 propagating a coding setting across source files Sven Hartrumpf
2011-12-02 10:41 ` rixed
2011-12-02 12:41   ` Paul Smith
2011-12-02 12:46     ` rixed
2011-12-02 12:55 ` Mike Gran
2011-12-02 13:41   ` Sven Hartrumpf
2011-12-02 14:23     ` Mike Gran
2011-12-05 17:25   ` Ludovic Courtès
2012-01-09 22:51 ` Andy Wingo
2012-01-10  8:51   ` Sven Hartrumpf
2012-01-11 18:00     ` Andy Wingo
2012-01-11 18:13       ` Mike Gran
2012-01-15 21:51         ` Ludovic Courtès
2012-01-16  9:07           ` Andy Wingo
2012-01-16 23:41             ` Ludovic Courtès
2013-01-07 21:28               ` 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).