unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
@ 2021-06-18  4:15 Andrew Tropin
  2021-06-18  7:55 ` Leo Prikler
  2021-06-23 21:39 ` bug#49082: " Ludovic Courtès
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Tropin @ 2021-06-18  4:15 UTC (permalink / raw)
  To: 49082


guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
appear in configuration, resulting file in the store will contain ? instead of
it.
---
 guix/gexp.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index afb935761e..187f5c5e85 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1921,6 +1921,7 @@ This is the declarative counterpart of 'text-file*'."
   (define build
     (gexp (call-with-output-file (ungexp output "out")
             (lambda (port)
+              (set-port-encoding! port "UTF-8")
               (display (string-append (ungexp-splicing text)) port)))))
 
   (computed-file name build))
-- 
2.32.0





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

* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-18  4:15 [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file Andrew Tropin
@ 2021-06-18  7:55 ` Leo Prikler
  2021-06-18 16:21   ` Andrew Tropin
  2021-06-23 21:39 ` bug#49082: " Ludovic Courtès
  1 sibling, 1 reply; 7+ messages in thread
From: Leo Prikler @ 2021-06-18  7:55 UTC (permalink / raw)
  To: 49082; +Cc: andrew

I appreciate this change, but how many rebuilds will it cause? It might
need to go to core-updates.
Regards, Leo





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

* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-18  7:55 ` Leo Prikler
@ 2021-06-18 16:21   ` Andrew Tropin
  2021-06-18 16:39     ` Leo Prikler
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Tropin @ 2021-06-18 16:21 UTC (permalink / raw)
  To: Leo Prikler, 49082

Leo Prikler <leo.prikler@student.tugraz.at> writes:

> I appreciate this change, but how many rebuilds will it cause? It might
> need to go to core-updates.
> Regards, Leo

Not so many I suppose, AFAIK, it's not used by any packages, so it will
cause rebuild only for users of 2 dozens of system services during
system reconfigure, which should be quite cheap, because it's just
string concatenation.  Let me know if my understanding is wrong here.

Anyway, I don't mind it going to core-updates if you think it's
necessary.







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

* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-18 16:21   ` Andrew Tropin
@ 2021-06-18 16:39     ` Leo Prikler
  2021-06-18 17:21       ` Andrew Tropin
  0 siblings, 1 reply; 7+ messages in thread
From: Leo Prikler @ 2021-06-18 16:39 UTC (permalink / raw)
  To: Andrew Tropin, 49082

Am Freitag, den 18.06.2021, 19:21 +0300 schrieb Andrew Tropin:
> Leo Prikler <leo.prikler@student.tugraz.at> writes:
> 
> > I appreciate this change, but how many rebuilds will it cause? It
> > might
> > need to go to core-updates.
> > Regards, Leo
> 
> Not so many I suppose, AFAIK, it's not used by any packages, so it
> will
> cause rebuild only for users of 2 dozens of system services during
> system reconfigure, which should be quite cheap, because it's just
> string concatenation.  Let me know if my understanding is wrong here.
> 
> Anyway, I don't mind it going to core-updates if you think it's
> necessary.
In that case it's probably good to go to master.
One thing to note however, is that we typically bind %default-port-
encoding throughout Guix.  I suppose this doesn't work for stuff like
mixed-text-file, since it's executed in a different context?





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

* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-18 16:39     ` Leo Prikler
@ 2021-06-18 17:21       ` Andrew Tropin
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Tropin @ 2021-06-18 17:21 UTC (permalink / raw)
  To: Leo Prikler, 49082

Leo Prikler <leo.prikler@student.tugraz.at> writes:

> Am Freitag, den 18.06.2021, 19:21 +0300 schrieb Andrew Tropin:
>> Leo Prikler <leo.prikler@student.tugraz.at> writes:
>> 
>> > I appreciate this change, but how many rebuilds will it cause? It
>> > might
>> > need to go to core-updates.
>> > Regards, Leo
>> 
>> Not so many I suppose, AFAIK, it's not used by any packages, so it
>> will
>> cause rebuild only for users of 2 dozens of system services during
>> system reconfigure, which should be quite cheap, because it's just
>> string concatenation.  Let me know if my understanding is wrong here.
>> 
>> Anyway, I don't mind it going to core-updates if you think it's
>> necessary.
> In that case it's probably good to go to master.
Good!
> One thing to note however, is that we typically bind %default-port-
> encoding throughout Guix.  I suppose this doesn't work for stuff like
> mixed-text-file, since it's executed in a different context?
Very probably.

Have a good weekend!




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

* bug#49082: [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-18  4:15 [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file Andrew Tropin
  2021-06-18  7:55 ` Leo Prikler
@ 2021-06-23 21:39 ` Ludovic Courtès
  2021-06-24  4:41   ` [bug#49082] " Andrew Tropin
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2021-06-23 21:39 UTC (permalink / raw)
  To: Andrew Tropin; +Cc: 49082-done

Hi,

Andrew Tropin <andrew@trop.in> skribis:

> guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
> appear in configuration, resulting file in the store will contain ? instead of
> it.

Good catch!  Applied as 1f3d7b45349d43e5cc02594083e0cd44ef730992.

Please look how I modified the commit log, in line with our conventions
and previous entries for this file.

>    (define build
>      (gexp (call-with-output-file (ungexp output "out")
>              (lambda (port)
> +              (set-port-encoding! port "UTF-8")

Leo is right that we’d often write:

  (parameterize ((%default-port-encoding "UTF-8"))
    (call-with-output-file …))

because it’s marginally cleaner (the port is created with the right
encoding from the start).  In this case it doesn’t matter much though.

Thank you!

Ludo’.




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

* [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
  2021-06-23 21:39 ` bug#49082: " Ludovic Courtès
@ 2021-06-24  4:41   ` Andrew Tropin
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Tropin @ 2021-06-24  4:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49082-done

Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Andrew Tropin <andrew@trop.in> skribis:
>
>> guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
>> appear in configuration, resulting file in the store will contain ? instead of
>> it.
>
> Good catch!  Applied as 1f3d7b45349d43e5cc02594083e0cd44ef730992.

Thank you very much!)

> Please look how I modified the commit log, in line with our conventions
> and previous entries for this file.
>
>>    (define build
>>      (gexp (call-with-output-file (ungexp output "out")
>>              (lambda (port)
>> +              (set-port-encoding! port "UTF-8")
>
> Leo is right that we’d often write:
>
>   (parameterize ((%default-port-encoding "UTF-8"))
>     (call-with-output-file …))
>
> because it’s marginally cleaner (the port is created with the right
> encoding from the start).  In this case it doesn’t matter much though.

Got it, I thought Leo meant to wrap (mixed-text-file ...) into
parametrize, which probably won't work, because gexp will be avaluated
in different environment.  Sorry for missunderstanding!)  Leo, Ludo,
thank you for explanation!

> Thank you!
>
> Ludo’.




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

end of thread, other threads:[~2021-06-24  4:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  4:15 [bug#49082] [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file Andrew Tropin
2021-06-18  7:55 ` Leo Prikler
2021-06-18 16:21   ` Andrew Tropin
2021-06-18 16:39     ` Leo Prikler
2021-06-18 17:21       ` Andrew Tropin
2021-06-23 21:39 ` bug#49082: " Ludovic Courtès
2021-06-24  4:41   ` [bug#49082] " Andrew Tropin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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