#!/bin/sh
# assumes that there is a ./org directory, and tangles
# each org file in it.

DIR=`pwd`
FILES=""

for i in $(find $DIR/org -name "*.org"); do
    FILES="$FILES \"$i\""
done


emacs -Q --batch  \
--eval "(progn
(add-to-list 'load-path (expand-file-name \"/home/r/config/emacs/extend/org-mode/lisp/\"))
(add-to-list 'load-path (expand-file-name \"/home/r/config/emacs/extend/org-mode/contrib/lisp/\"))
(require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
(mapc (lambda (file)
       (find-file (expand-file-name file \"$DIR\"))
       (org-babel-tangle)
       (kill-buffer)) '($FILES)))" 2>&1 | pcregrep '(Wrote)|(tangled)'
