diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-10-14 17:15:11 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-10-14 17:15:11 -0600 |
commit | d32c8d49e568ce0ff5dc99883ec74a778186abb8 (patch) | |
tree | bf3d0efb68bb0af503a7821a13c61fcd73953b14 | |
parent | 03cbc9fc28f5ba592b3bea67968539033b67c2aa (diff) | |
download | org-mode-d32c8d49e568ce0ff5dc99883ec74a778186abb8.tar.gz |
ob-tangle: only create links for blocks that will actually tangle
this commit includes a unit test
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): only create
links for blocks that will actually tangle
-rw-r--r-- | lisp/ob-tangle.el | 7 | ||||
-rw-r--r-- | testing/examples/babel.org | 18 | ||||
-rw-r--r-- | testing/lisp/test-ob-tangle.el | 8 |
3 files changed, 30 insertions, 3 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index adfe515..eb37600 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -276,11 +276,12 @@ code blocks by language." (let* ((start-line (save-restriction (widen) (+ 1 (line-number-at-pos (point))))) (file (buffer-file-name)) - (link (progn (call-interactively 'org-store-link) - (org-babel-clean-text-properties - (car (pop org-stored-links))))) (info (org-babel-get-src-block-info)) (params (nth 2 info)) + (link (unless (string= (cdr (assoc :tangle params)) "no") + (progn (call-interactively 'org-store-link) + (org-babel-clean-text-properties + (car (pop org-stored-links)))))) (source-name (intern (or (nth 4 info) (format "%s:%d" current-heading block-counter)))) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index c1ae57d..8294e3f 100644 --- a/testing/examples/babel.org +++ b/testing/examples/babel.org @@ -41,3 +41,21 @@ #+results: : 4 + +* excessive id links on tangling + :PROPERTIES: + :ID: ef06fd7f-012b-4fde-87a2-2ae91504ea7e + :END: + +** no, don't give me an ID +#+begin_src emacs-lisp :tangle no + (message "not to be tangled") +#+end_src + +** yes, I'd love an ID + :PROPERTIES: + :ID: ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3 + :END: +#+begin_src emacs-lisp :tangle no + (message "for tangling") +#+end_src diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index b99995e..264b77b 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -43,6 +43,14 @@ (should-not (exp-p "no")) (should (exp-p "tangle")))))) +(ert-deftest ob-tangle/no-excessive-id-insertion-on-tangle () + "Don't add IDs to headings without tangling code blocks." + (org-test-at-id "ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3" + (org-babel-next-src-block) + (org-babel-tangle) + (org-babel-previous-src-block) + (should (null (org-id-get))))) + (provide 'test-ob-tangle) ;;; test-ob-tangle.el ends here |