Merge branch 'master' into next

This commit is contained in:
Nicolas Goaziou 2018-10-11 00:02:46 +02:00
commit 5341312b79
2 changed files with 47 additions and 1 deletions

View File

@ -407,7 +407,8 @@ can be used to limit the collected code blocks by target file."
(if by-lang (setcdr by-lang (cons block (cdr by-lang))) (if by-lang (setcdr by-lang (cons block (cdr by-lang)))
(push (cons src-lang (list block)) blocks))))))) (push (cons src-lang (list block)) blocks)))))))
;; Ensure blocks are in the correct order. ;; Ensure blocks are in the correct order.
(mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks))) (mapcar (lambda (b) (cons (car b) (nreverse (cdr b))))
(nreverse blocks))))
(defun org-babel-tangle-single-block (block-counter &optional only-this-block) (defun org-babel-tangle-single-block (block-counter &optional only-this-block)
"Collect the tangled source for current block. "Collect the tangled source for current block.

View File

@ -222,6 +222,51 @@ another block
(buffer-string))) (buffer-string)))
(delete-file "test-ob-tangle.org")))))) (delete-file "test-ob-tangle.org"))))))
(ert-deftest ob-tangle/block-order ()
"Test order of tangled blocks."
;; Order per language.
(should
(equal '("1" "2")
(let ((file (make-temp-file "org-tangle-")))
(unwind-protect
(progn
(org-test-with-temp-text-in-file
(format "#+property: header-args :tangle %S
#+begin_src emacs-lisp
1
#+end_src
#+begin_src emacs-lisp
2
#+end_src"
file)
(org-babel-tangle))
(with-temp-buffer
(insert-file-contents file)
(org-split-string (buffer-string))))
(delete-file file)))))
;; Order per source block.
(should
(equal '("1" "2")
(let ((file (make-temp-file "org-tangle-")))
(unwind-protect
(progn
(org-test-with-temp-text-in-file
(format "#+property: header-args :tangle %S
#+begin_src foo
1
#+end_src
#+begin_src bar
2
#+end_src"
file)
(org-babel-tangle))
(with-temp-buffer
(insert-file-contents file)
(org-split-string (buffer-string))))
(delete-file file))))))
(provide 'test-ob-tangle) (provide 'test-ob-tangle)
;;; test-ob-tangle.el ends here ;;; test-ob-tangle.el ends here