Re: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'

2015-06-24 Thread Ludovic Courtès
Federico Beffa be...@ieee.org skribis:

 From ec5fbc02e09359bf64b69efed314471e5f409fa4 Mon Sep 17 00:00:00 2001
 From: Federico Beffa be...@fbengineering.ch
 Date: Tue, 16 Jun 2015 21:09:57 +0200
 Subject: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'.

 * guix/build/emacs-utils.scm (emacs-byte-compile-directory): New procedure.

LGTM, thanks!

Ludo’.



Re: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'

2015-06-24 Thread Federico Beffa
Thanks.

On Sun, Jun 21, 2015 at 10:40 PM, Alex Kost alez...@gmail.com wrote:
 Federico Beffa (2015-06-21 11:29 +0300) wrote:

 [...]
 +(define* (emacs-byte-compile-directory dir #:optional (dependency-dirs '()))
 +  Byte compile all files in DIR and its sub-directories.  Before compiling
 +the files, add DIR and all directories in DEPENDENCY-DIRS to 'load-path'.
 +  (let ((expr `(progn
 +(add-to-list 'load-path ,dir)
 +(unless (null ,(if (null? dependency-dirs)
 +   'nil
 +   dependency-dirs))
 +  (setq load-path (append load-path ,dependency-dirs)))
 +(byte-recompile-directory (file-name-as-directory ,dir) 
 0
 +(emacs-batch-eval expr)))
 +
  (define-syntax emacs-substitute-sexps
(syntax-rules ()
  Substitute the S-expression immediately following the first occurrence 
 of

 Shouldn't there be problems with unquoted 'dependency-dirs' list?  IIUC
 the following:

   (emacs-byte-compile-directory /tmp/foo '(one two))

 will produce the following elisp expression:

 (progn
   (add-to-list (quote load-path) /tmp/foo)
   (unless (null (one two))
 (setq load-path (append load-path (one two
   (byte-recompile-directory (file-name-as-directory /tmp/foo) 0))

 but that will raise an error ‘(invalid-function one)’.  Or did I miss
 anything?

 Also I believe dependency-dirs should have a preference over other
 'load-path' directories.

 So what about the following variant:



 --
 Alex

From ec5fbc02e09359bf64b69efed314471e5f409fa4 Mon Sep 17 00:00:00 2001
From: Federico Beffa be...@fbengineering.ch
Date: Tue, 16 Jun 2015 21:09:57 +0200
Subject: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'.

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

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 0cff28b..fd06aad 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-directory
 emacs-substitute-sexps
 emacs-substitute-variables))
 
@@ -57,6 +58,16 @@
   (update-directory-autoloads ,directory
 (emacs-batch-eval expr)))
 
+(define* (emacs-byte-compile-directory dir #:optional (dependency-dirs '()))
+  Byte compile all files in DIR and its sub-directories.  Before compiling
+the files, add DIR and all directories in DEPENDENCY-DIRS to 'load-path'.
+  (let ((expr `(progn
+(add-to-list 'load-path ,dir)
+(when ',dependency-dirs
+  (setq load-path (append ',dependency-dirs load-path)))
+(byte-recompile-directory (file-name-as-directory ,dir) 0
+(emacs-batch-eval expr)))
+
 (define-syntax emacs-substitute-sexps
   (syntax-rules ()
 Substitute the S-expression immediately following the first occurrence of
-- 
2.2.1



Re: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'

2015-06-21 Thread Alex Kost
Federico Beffa (2015-06-21 11:29 +0300) wrote:

[...]
 +(define* (emacs-byte-compile-directory dir #:optional (dependency-dirs '()))
 +  Byte compile all files in DIR and its sub-directories.  Before compiling
 +the files, add DIR and all directories in DEPENDENCY-DIRS to 'load-path'.
 +  (let ((expr `(progn
 +(add-to-list 'load-path ,dir)
 +(unless (null ,(if (null? dependency-dirs)
 +   'nil
 +   dependency-dirs))
 +  (setq load-path (append load-path ,dependency-dirs)))
 +(byte-recompile-directory (file-name-as-directory ,dir) 0
 +(emacs-batch-eval expr)))
 +
  (define-syntax emacs-substitute-sexps
(syntax-rules ()
  Substitute the S-expression immediately following the first occurrence 
 of

Shouldn't there be problems with unquoted 'dependency-dirs' list?  IIUC
the following:

  (emacs-byte-compile-directory /tmp/foo '(one two))

will produce the following elisp expression:

(progn
  (add-to-list (quote load-path) /tmp/foo)
  (unless (null (one two))
(setq load-path (append load-path (one two
  (byte-recompile-directory (file-name-as-directory /tmp/foo) 0))

but that will raise an error ‘(invalid-function one)’.  Or did I miss
anything?

Also I believe dependency-dirs should have a preference over other
'load-path' directories.

So what about the following variant:

(define* (emacs-byte-compile-directory dir #:optional (dependency-dirs '()))
  Byte compile all files in DIR and its sub-directories.  Before compiling
the files, add DIR and all directories in DEPENDENCY-DIRS to 'load-path'.
  (let ((expr `(progn
 (add-to-list 'load-path ,dir)
 (when ',dependency-dirs
   (setq load-path (append ',dependency-dirs load-path)))
 (byte-recompile-directory (file-name-as-directory ,dir) 0
(emacs-batch-eval expr)))

-- 
Alex


[PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'

2015-06-21 Thread Federico Beffa
A new general utility for Emacs.

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

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

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 0cff28b..3ecccd9 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-directory
 emacs-substitute-sexps
 emacs-substitute-variables))
 
@@ -57,6 +58,18 @@
   (update-directory-autoloads ,directory
 (emacs-batch-eval expr)))
 
+(define* (emacs-byte-compile-directory dir #:optional (dependency-dirs '()))
+  Byte compile all files in DIR and its sub-directories.  Before compiling
+the files, add DIR and all directories in DEPENDENCY-DIRS to 'load-path'.
+  (let ((expr `(progn
+(add-to-list 'load-path ,dir)
+(unless (null ,(if (null? dependency-dirs)
+   'nil
+   dependency-dirs))
+  (setq load-path (append load-path ,dependency-dirs)))
+(byte-recompile-directory (file-name-as-directory ,dir) 0
+(emacs-batch-eval expr)))
+
 (define-syntax emacs-substitute-sexps
   (syntax-rules ()
 Substitute the S-expression immediately following the first occurrence of
-- 
2.2.1