diff --git a/doc/format_code.el b/doc/format_code.el
new file mode 100644
index 0000000000000000000000000000000000000000..09f75673c43b884a479176ea42d47ae0d873a263
--- /dev/null
+++ b/doc/format_code.el
@@ -0,0 +1,14 @@
+(while argv
+  (find-file (pop argv))
+  (mark-whole-buffer)
+  (set-buffer-file-coding-system 'unix 't)
+  (setq-default c-default-style "ellemtel")
+  (setq         c-set-style     "ellemtel")
+  (setq         c-basic-offset  2)
+
+  (indent-region (point-min) (point-max) nil)
+  (delete-trailing-whitespace)
+  (untabify (point-min) (point-max))
+  (save-buffer))
+
+(kill-emacs 0)
diff --git a/doc/format_code.sh b/doc/format_code.sh
new file mode 100755
index 0000000000000000000000000000000000000000..e709b97cbad9a9b7ad830c0aa7be1c0f4651a332
--- /dev/null
+++ b/doc/format_code.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+DIR=`dirname $0`;
+
+format_file()
+{
+    echo "====  Reformatting file: $*";
+    emacs --quick --script ${DIR}/format_code.el $*;
+}
+
+arg=$1;
+
+if test -f "${arg}";
+then
+    format_file "${arg}";
+elif test -d "${arg}";
+then
+    for i in `find ${arg} \( -name '*.cpp' -o -name '*.h' -o -name '*.inl' \) -type f -print`;
+    do
+	format_file $i;
+    done;
+else
+    echo "$0: File/Directory $* does not exist or is not a regular file nor a directory!"
+fi;