浏览代码

DONE ensure that org-babel-tangle returns the path to the tangled file(s)

Eric Schulte 16 年之前
父节点
当前提交
cdd73500d6
共有 2 个文件被更改,包括 21 次插入9 次删除
  1. 10 7
      lisp/org-babel-tangle.el
  2. 11 2
      org-babel.org

+ 10 - 7
lisp/org-babel-tangle.el

@@ -39,11 +39,11 @@ and shebang(#!) line to use when writing out the language to
 file.")
 
 (defun org-babel-load-file (file)
-  "Load the contents of the Emacs Lisp source code blocks in
-FILE.  This function will first export the source code using
-`org-babel-tangle' and then load the resulting file using
-`load-file'."
-  (load-file (org-babel-tangle-file "emacs-lisp")))
+  "Load the contents of the Emacs Lisp source code blocks in the
+org-mode formatted FILE.  This function will first export the
+source code using `org-babel-tangle' and then load the resulting
+file using `load-file'."
+  (mapc #'load-file (org-babel-tangle-file "emacs-lisp")))
 
 (defun org-babel-tangle-file (file &optional lang)
   "Extract the bodies of all source code blocks in FILE with
@@ -59,7 +59,8 @@ language."
   (interactive)
   (save-excursion
     (let ((base-name (file-name-sans-extension (buffer-file-name)))
-          (block-counter 0))
+          (block-counter 0)
+          path-collector)
       (mapc ;; for every language create a file
        (lambda (by-lang)
          (let* ((lang (car by-lang))
@@ -69,6 +70,7 @@ language."
                 (she-bang (second lang-specs))
                 (by-session (cdr by-lang)))
            (flet ((to-file (filename specs)
+                           (add-to-list 'path-collector filename)
                            (with-temp-file filename
                              (funcall lang-f)
                              (when she-bang (insert (concat she-bang "\n")))
@@ -85,7 +87,8 @@ language."
                (setq block-counter (+ block-counter (length (cdr (car by-session)))))
                (to-file (format "%s.%s" base-name ext) (cdr (car by-session)))))))
        (org-babel-collect-blocks lang))
-      (message "tangled %d source-code blocks" block-counter))))
+      (message "tangled %d source-code blocks" block-counter)
+      path-collector)))
 
 (defun org-babel-collect-blocks (&optional lang)
   "Collect all source blocks in the current org-mode file.

+ 11 - 2
org-babel.org

@@ -200,7 +200,7 @@ would then be [[#sandbox][the sandbox]].
 
 
 * Tasks [27/44]
-** TODO singe-function tangling and loading elisp from literate org-mode file [1/2]
+** TODO singe-function tangling and loading elisp from literate org-mode file [2/2]
 
 This function should tangle the org-mode file for elisp, and then call
 `load-file' on the resulting tangled file.
@@ -208,7 +208,16 @@ This function should tangle the org-mode file for elisp, and then call
 *** DONE add optional language limiter to org-babel-tangle
 This should check to see if there is any need to re-export
 
-*** TODO ensure that org-babel-tangle returns the path to the tangled file(s)
+*** DONE ensure that org-babel-tangle returns the path to the tangled file(s)
+
+#+srcname: test-return-value-of-org-babel-tangle
+#+begin_src emacs-lisp 
+  (mapcar #'file-name-nondirectory (org-babel-tangle-file "test-tangle.org" "emacs-lisp"))
+#+end_src
+
+#+resname:
+| "test-tangle.el" |
+
 
 ** TODO support for working with =*Org Edit Src Example*= buffers [2/4]
 *** TODO optionally evaluate header references when we switch to =*Org Edit Src*= buffer