mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-30 02:20:01 +00:00
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.
This commit is contained in:
parent
b38036dd66
commit
d5fd2008e3
|
@ -135,32 +135,6 @@ evaluating BODY."
|
||||||
,temp-result)))
|
,temp-result)))
|
||||||
(def-edebug-spec org-babel-with-temp-filebuffer (form 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
|
;;;###autoload
|
||||||
(defun org-babel-tangle-file (file &optional target-file lang)
|
(defun org-babel-tangle-file (file &optional target-file lang)
|
||||||
"Extract the bodies of source code blocks in FILE.
|
"Extract the bodies of source code blocks in FILE.
|
||||||
|
|
27
lisp/org.el
27
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)))))))
|
(intern (concat "org-babel-expand-body:" lang)))))))
|
||||||
org-babel-load-languages))
|
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))
|
(defcustom org-babel-load-languages '((emacs-lisp . t))
|
||||||
"Languages which can be evaluated in Org-mode buffers.
|
"Languages which can be evaluated in Org-mode buffers.
|
||||||
This list can be used to load support for any of the languages
|
This list can be used to load support for any of the languages
|
||||||
|
|
Loading…
Reference in a new issue