From ec94d552fc16162c21fb60c908cee98234841d4b Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 13 Oct 2016 17:21:23 +0200 Subject: [PATCH] Change recompile-files shell script to pure Elisp It still calls `find(1)`, but everything else is Elisp. This means it is generally faster. It still has some buffer processing overhead, though. --- lisp/recompile-files.el | 26 ++++++++++++++++++++++++++ recompile-files.sh | 22 ---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 lisp/recompile-files.el delete mode 100755 recompile-files.sh diff --git a/lisp/recompile-files.el b/lisp/recompile-files.el new file mode 100644 index 0000000..c3ae626 --- /dev/null +++ b/lisp/recompile-files.el @@ -0,0 +1,26 @@ +(defun recompile-stale-elcs () + (interactive) + + (with-temp-buffer + (setq-local default-directory user-emacs-directory) + + (let ((find-command (find-cmd '(prune (name ".git")) + '(name "*.elc")))) + + (shell-command find-command t t)) + + (goto-char (point-min)) + + (setq more-lines t) + + (while more-lines + (let ((start (progn (beginning-of-line) + (point))) + (end (progn (end-of-line) + (point)))) + (let ((el (buffer-substring start (- end 1))) + (elc (buffer-substring start end))) + + (if (file-newer-than-file-p el elc) + (byte-compile-file (buffer-substring start (- end 1)))))) + (setq more-lines (= 0 (forward-line 1)))))) diff --git a/recompile-files.sh b/recompile-files.sh deleted file mode 100755 index 7a93f1e..0000000 --- a/recompile-files.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -cd `dirname $0` -pwd=`pwd` - -for file in `find -iname '*.elc'` -do - elc=`basename "$file"` - el="${elc%c}" - dir=`dirname "$file"` - - cd "$dir" - - if test "$elc" -ot "$el" - then - echo "Recompiling ${el}" - - emacs --batch --eval '(byte-compile-file "'${el}'")' - fi - - cd $pwd -done