From: ludo@gnu.org (Ludovic Courtès)
To: Huang Ying <huang.ying.caritas@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH -v2 2/2] guix: profiles: create fonts.dir/scale for all fonts directories
Date: Wed, 08 Mar 2017 18:24:29 +0100 [thread overview]
Message-ID: <878toflm0i.fsf@gnu.org> (raw)
In-Reply-To: <20170307110749.31614-2-huang.ying.caritas@gmail.com> (Huang Ying's message of "Tue, 7 Mar 2017 19:07:49 +0800")
Huang Ying <huang.ying.caritas@gmail.com> skribis:
> * guix/profiles.scm (fonts-dir-file): Create fonts.dir/scale files for all
> fonts directories.
Looks cool, modulo Danny’s suggestions and minor issues below.
BTW, could you explain (probably as a comment in the code) why we need
to do all this? What is it fixing? :-)
> + (union-build fonts-dir fonts-dirs
> + #:log-port (%make-void-port "w")
> + #:create-all-directories? #t)
> + (ftw fonts-dir
> + (lambda (dir statinfo flag)
‘ftw’ is not great IMO and not used in Guix.
I would suggest using ‘find-files’ from (guix build utils). You could
write something like:
(let ((directories (find-files fonts-dir
(lambda (file stat)
(eq? 'directory (stat:type stat)))
#:directories? #t)))
(for-each do-something directories))
This also has the advantage of separating the generation of the
directory list from the actual action.
> + (and (eq? flag 'directory)
> + (with-directory-excursion dir
> + (and (file-exists? fonts-scale-file)
> + (delete-file fonts-scale-file))
Here, since ‘delete-file’ has a side-effect and a meaningless return
value, we conventionally avoid ‘and’ and instead write:
(when (file-exists? fonts-scale-file)
(delete-file fonts-scale-file))
for clarity.
> + (and (file-exists? fonts-dir-file)
> + (delete-file fonts-dir-file))
> + (system* mkfontscale)
> + (system* mkfontdir)
> + (and (empty-file? fonts-scale-file)
> + (delete-file fonts-scale-file))
> + (and (empty-file? fonts-dir-file)
> + (delete-file fonts-dir-file))))
Same as above.
Thank you!
Ludo’.
next prev parent reply other threads:[~2017-03-08 17:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 11:07 [PATCH -v2 1/2] build: union: Add create-all-directories? parameter to union-build Huang Ying
2017-03-07 11:07 ` [PATCH -v2 2/2] guix: profiles: create fonts.dir/scale for all fonts directories Huang Ying
2017-03-07 20:24 ` Danny Milosavljevic
2017-03-08 7:44 ` huang ying
2017-03-08 17:18 ` Ludovic Courtès
2017-03-09 11:42 ` Huang, Ying
2017-03-08 17:24 ` Ludovic Courtès [this message]
2017-03-09 11:41 ` Huang, Ying
2017-03-07 20:35 ` [PATCH -v2 1/2] build: union: Add create-all-directories? parameter to union-build Danny Milosavljevic
2017-03-07 20:54 ` Danny Milosavljevic
2017-03-08 7:43 ` huang ying
2017-03-08 17:16 ` Ludovic Courtès
2017-03-09 11:43 ` Huang, Ying
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://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878toflm0i.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=huang.ying.caritas@gmail.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.
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).