Browse Source

tangling now preserves order of source-code blocks from the original file

Eric Schulte 16 years ago
parent
commit
9df56be538
3 changed files with 23 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 4 1
      lisp/org-babel-tangle.el
  3. 18 0
      test-tangle-load.org

+ 1 - 0
.gitignore

@@ -8,3 +8,4 @@ other
 test-tangle.sh
 test-tangle.sh
 test-tangle-none.rb
 test-tangle-none.rb
 test-tangle-special.rb
 test-tangle-special.rb
+test-tangle-load.el

+ 4 - 1
lisp/org-babel-tangle.el

@@ -142,8 +142,11 @@ code blocks by language."
             (setq by-lang (cdr (assoc src-lang blocks)))
             (setq by-lang (cdr (assoc src-lang blocks)))
             (setq blocks (delq (assoc src-lang blocks) blocks))
             (setq blocks (delq (assoc src-lang blocks) blocks))
             (setq blocks (cons (cons src-lang (cons spec by-lang)) blocks))))))
             (setq blocks (cons (cons src-lang (cons spec by-lang)) blocks))))))
+    ;; ensure blocks in the correct order
+    (setq blocks
+          (mapcar (lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang)))) blocks))
     ;; blocks should contain all source-blocks organized by language
     ;; blocks should contain all source-blocks organized by language
-    ;; (message "blocks=%S" blocks) ;; debugging
+    (message "blocks=%S" blocks) ;; debugging
     blocks))
     blocks))
 
 
 (defun org-babel-spec-to-string (spec)
 (defun org-babel-spec-to-string (spec)

+ 18 - 0
test-tangle-load.org

@@ -0,0 +1,18 @@
+#+TITLE: testing org-babel-load
+#+OPTIONS: toc:nil num:nil ^:nil
+
+* elisp blocks
+
+** lets look at the order
+
+#+begin_src emacs-lisp 
+(message "I'm the first")
+#+end_src
+
+#+begin_src emacs-lisp
+(message "I'm the second")
+#+end_src
+
+#+begin_src emacs-lisp
+(message "I'm the third")
+#+end_src