Browse Source

org-babel-load-file now working under new tangling schema

Eric Schulte 12 years ago
parent
commit
5c6308d804
2 changed files with 17 additions and 2 deletions
  1. 5 2
      lisp/org-babel-tangle.el
  2. 12 0
      org-babel.org

+ 5 - 2
lisp/org-babel-tangle.el

@@ -49,6 +49,7 @@ file using `load-file'."
                               (sixth (file-attributes file))))))
     (let* ((base-name (file-name-sans-extension file))
            (exported-file (concat base-name ".el")))
+      (message "building %s" exported-file) ;; debugging
       ;; tangle if the org-mode file is newer than the elisp file
       (unless (and (file-exists-p exported-file) (> (age file) (age exported-file)))
         (org-babel-tangle-file file base-name "emacs-lisp"))
@@ -87,13 +88,15 @@ exported source code blocks by language."
               (let* ((tangle (cdr (assoc :tangle params)))
                      (base-name (or (when (not (or (string= tangle "yes")
                                                    (string= tangle "no")))
-                                      tangle)
+                                      (when (> (length tangle) 0) tangle))
                                     target-file))
                      (file-name (when base-name
                                   (concat base-name "." ext))))
+                (message "tangle=%S base-name=%S file-name=%S" tangle base-name file-name)
                 (when file-name
                   ;; delete any old versions of file
-                  (unless (member file-name path-collector)
+                  (when (and (file-exists-p file-name)
+                             (not (member file-name path-collector)))
                     (delete-file file-name))
                   ;; drop source-block to file
                   (with-temp-buffer

+ 12 - 0
org-babel.org

@@ -262,6 +262,18 @@ can happen in two ways...
 2) if the value of the =tangle= header argument is anything other than
    =no= or =yes= then it is used as the file name
 
+#+srcname: test-new-tangling
+#+begin_src emacs-lisp 
+  (org-babel-load-file "test-tangle.org")
+  (if (string= test-tangle-advert "use org-babel-tangle for all your emacs initialization files!!")
+      "succeed"
+    "fail")
+#+end_src
+
+#+resname:
+: succeed
+
+
 ** PROPOSED raise elisp error when source-blocks return errors
 Not sure how/if this would work, but it may be desirable.