summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-04-04 11:18:01 +0200
committerBastien Guerry <bzg@altern.org>2013-04-05 08:37:51 +0200
commitd5fd2008e320449cc0229b73a09e50b3d5081bd2 (patch)
tree839c13d73d5e66cc6fe700513caf02cd1cfd0591
parentb38036dd66b7744cf1ea915a655ad77310cf909e (diff)
downloadorg-mode-d5fd2008e320449cc0229b73a09e50b3d5081bd2.tar.gz
org.el (org-babel-load-file): Move `org-babel-load-file' here
* org.el (org-babel-load-file): Move `org-babel-load-file' from ob-tangle.el to here so that it is correctly autoloaded by Emacs before Org is required. Thanks to Eric Schulte for feedback about this.
-rw-r--r--lisp/ob-tangle.el26
-rw-r--r--lisp/org.el27
2 files changed, 27 insertions, 26 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 4bcb2e3..f15567f 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -136,32 +136,6 @@ evaluating BODY."
(def-edebug-spec org-babel-with-temp-filebuffer (form body))
;;;###autoload
-(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'. 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)
- (nth 5 (or (file-attributes (file-truename file))
- (file-attributes file)))))))
- (base-name (file-name-sans-extension file))
- (exported-file (concat base-name ".el")))
- ;; tangle if the org-mode file is newer than the elisp file
- (unless (and (file-exists-p exported-file)
- (> (funcall age file) (funcall age exported-file)))
- (org-babel-tangle-file file exported-file "emacs-lisp"))
- (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)
"Extract the bodies of source code blocks in FILE.
Source code blocks are extracted with `org-babel-tangle'.
diff --git a/lisp/org.el b/lisp/org.el
index fc63733..cd6a780 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -179,6 +179,33 @@ Stars are put in group 1 and the trimmed body in group 2.")
(intern (concat "org-babel-expand-body:" lang)))))))
org-babel-load-languages))
+;;;###autoload
+(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'. With prefix
+arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp
+file to byte-code before it is loaded."
+ (interactive "fFile to load: \nP")
+ (require 'ob-core)
+ (let* ((age (lambda (file)
+ (float-time
+ (time-subtract (current-time)
+ (nth 5 (or (file-attributes (file-truename file))
+ (file-attributes file)))))))
+ (base-name (file-name-sans-extension file))
+ (exported-file (concat base-name ".el")))
+ ;; tangle if the org-mode file is newer than the elisp file
+ (unless (and (file-exists-p exported-file)
+ (> (funcall age file) (funcall age exported-file)))
+ (org-babel-tangle-file file exported-file "emacs-lisp"))
+ (message "%s %s"
+ (if compile
+ (progn (byte-compile-file exported-file 'load)
+ "Compiled and loaded")
+ (progn (load-file exported-file) "Loaded"))
+ exported-file)))
+
(defcustom org-babel-load-languages '((emacs-lisp . t))
"Languages which can be evaluated in Org-mode buffers.
This list can be used to load support for any of the languages