Explorar el Código

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.
Bastien Guerry hace 12 años
padre
commit
d5fd2008e3
Se han modificado 2 ficheros con 27 adiciones y 26 borrados
  1. 0 26
      lisp/ob-tangle.el
  2. 27 0
      lisp/org.el

+ 0 - 26
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.

+ 27 - 0
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