From d5fd2008e320449cc0229b73a09e50b3d5081bd2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 4 Apr 2013 11:18:01 +0200 Subject: [PATCH] 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. --- lisp/ob-tangle.el | 26 -------------------------- lisp/org.el | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 4bcb2e399..f15567fda 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -135,32 +135,6 @@ evaluating BODY." ,temp-result))) (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. diff --git a/lisp/org.el b/lisp/org.el index fc6373361..cd6a7801f 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