summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2012-12-11 20:34:00 -0700
committerEric Schulte <eric.schulte@gmx.com>2012-12-12 10:48:57 -0700
commit2c34715ae653ccebd6fd3f6de465fa09c9106a73 (patch)
treea6e0bb823a3d3cb2dcf59bb129d17c48a86697cd
parent5e3b8259c7e5a8f2e09aa8e8b0769216ca9c5576 (diff)
downloadorg-mode-2c34715ae653ccebd6fd3f6de465fa09c9106a73.tar.gz
option to byte-compile elisp loaded from Org files
* lisp/ob-tangle.el (org-babel-load-file): When called with a prefix argument the tangled emacs-lisp file will be byte compiled.
-rw-r--r--lisp/ob-tangle.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 1d486a8..622a0a1 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -136,12 +136,13 @@ evaluating BODY."
(def-edebug-spec org-babel-with-temp-filebuffer (form body))
;;;###autoload
-(defun org-babel-load-file (file)
+(defun org-babel-load-file (file &optional compile)
"Load Emacs Lisp source code blocks in the Org-mode FILE.
-This function exports the source code using
-`org-babel-tangle' and then loads the resulting file using
-`load-file'."
- (interactive "fFile to load: ")
+This function exports the source code using `org-babel-tangle'
+and then loads the resulting file using `load-file'. With prefix
+arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp
+file to byte-code before it is loaded."
+ (interactive "fFile to load: \nP")
(let* ((age (lambda (file)
(float-time
(time-subtract (current-time)
@@ -153,8 +154,12 @@ This function exports the source code using
(unless (and (file-exists-p exported-file)
(> (funcall age file) (funcall age exported-file)))
(org-babel-tangle-file file exported-file "emacs-lisp"))
- (load-file exported-file)
- (message "Loaded %s" exported-file)))
+ (message "%s %s"
+ (if compile
+ (progn (byte-compile-file exported-file 'load)
+ "Compiled and loaded")
+ (progn (load-file exported-file) "Loaded"))
+ exported-file)))
;;;###autoload
(defun org-babel-tangle-file (file &optional target-file lang)