[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory'
From: |
Alex Kost |
Subject: |
Re: [PATCH 2/5] build: emacs-utils: Add 'emacs-byte-compile-directory' |
Date: |
Sun, 21 Jun 2015 23:40:23 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
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