Previous: , Up: Working With Source Code   [Contents][Index]

14.12 Batch execution

It is possible to call functions from the command line. This shell script calls org-babel-tangle on every one of its arguments.

Be sure to adjust the paths to fit your system.

# -*- mode: shell-script -*-
# tangle files with org-mode

# wrap each argument in the code required to call tangle on it
for i in $@; do
    FILES="$FILES \"$i\""

emacs -Q --batch \
--eval "(progn
(add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
(add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
(require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
(mapc (lambda (file)
       (find-file (expand-file-name file \"$DIR\"))
       (kill-buffer)) '($FILES)))" 2>&1 |grep tangled