On Tue, Jun 16, 2015 at 6:24 PM, Mark H Weaver <m...@netris.org> wrote:
> FYI, this pattern of using 'fold' with 'and' and a boolean seed would be
> more transparent if handled by 'every' from (srfi srfi-1):
>
>   (every (lambda (f)
>            (zero? (system* emacs "--batch" "-Q" "-L" el-dir
>                            "-f" "batch-byte-compile" f)))
>          (find-files "." "\\.el$"))

Thanks for the comment. I saw the form 'every' in the past, but 'fold'
always come first to my mind.  Probably because it took me more
neurons to understand how to use it :-)

> However, this won't be needed here if you use 'emacs-batch-eval' or add
> 'emacs-byte-compile' as suggested by Ludovic, which I agree is the right
> approach.

What do you think about the attached implementation?

Thanks,
Fede
From d5c33d5237bb371ab3bea88eb78a9ccac583de1d Mon Sep 17 00:00:00 2001
From: Federico Beffa <be...@fbengineering.ch>
Date: Tue, 16 Jun 2015 21:09:57 +0200
Subject: [PATCH] build: emacs-utils: Add 'emacs-byte-compile'.

* guix/build/emacs-utils.scm (emacs-byte-compile): New procedure.
---
 guix/build/emacs-utils.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 0cff28b..88eda78 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -22,6 +22,7 @@
             emacs-batch-eval
             emacs-batch-edit-file
             emacs-generate-autoloads
+            emacs-byte-compile
             emacs-substitute-sexps
             emacs-substitute-variables))
 
@@ -57,6 +58,17 @@
                   (update-directory-autoloads ,directory))))
     (emacs-batch-eval expr)))
 
+(define (emacs-byte-compile files)
+  "Byte compile FILES, a list of file names."
+  (if (pair? files)
+      (for-each (lambda (f)
+                  (let ((expr `(let ()
+                                 (push ,(dirname f) load-path)
+                                 (byte-compile-file ,f))))
+                    (emacs-batch-eval expr)))
+                files)
+      (error "emacs-byte-compile failed: not a list of files!" files)))
+
 (define-syntax emacs-substitute-sexps
   (syntax-rules ()
     "Substitute the S-expression immediately following the first occurrence of
-- 
2.2.1

Reply via email to