summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2013-10-19 15:52:31 -0600
committerEric Schulte <schulte.eric@gmail.com>2013-10-19 15:53:39 -0600
commitaf80144976cef9e5630a33f85f05a8dfc07f55d4 (patch)
tree96606fe6da0225e3d9008fff1cccab32b04d2093
parentfe27ca9906f1d6c48a93f463d85850925687b825 (diff)
downloadorg-mode-af80144976cef9e5630a33f85f05a8dfc07f55d4.tar.gz
tangle checks for COMMENT in parent headlines
* lisp/ob-tangle.el (org-babel-under-commented-heading-p): Check if the point is under a commented heading (including parents). (org-babel-tangle-collect-blocks): Don't tangle blocks is under a commented heading (including parents).
-rw-r--r--lisp/ob-tangle.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 8980746..789a759 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -355,6 +355,15 @@ that the appropriate major-mode is set. SPEC has the form:
insert-comment
(org-fill-template org-babel-tangle-comment-format-end link-data)))))
+(defun org-babel-under-commented-heading-p ()
+ "Return t if currently under a commented heading."
+ (if (string-match (concat "^" org-comment-string)
+ (nth 4 (org-heading-components)))
+ t
+ (save-excursion
+ (and (org-up-heading-safe)
+ (org-babel-under-commented-headline-p)))))
+
(defvar org-comment-string) ;; Defined in org.el
(defun org-babel-tangle-collect-blocks (&optional language tangle-file)
"Collect source blocks in the current Org-mode file.
@@ -379,7 +388,7 @@ can be used to limit the collected code blocks by target file."
(let* ((info (org-babel-get-src-block-info 'light))
(src-lang (nth 0 info))
(src-tfile (cdr (assoc :tangle (nth 2 info)))))
- (unless (or (string-match (concat "^" org-comment-string) current-heading)
+ (unless (or (org-babel-under-commented-heading-p)
(string= (cdr (assoc :tangle (nth 2 info))) "no")
(and tangle-file (not (equal tangle-file src-tfile))))
(unless (and language (not (string= language src-lang)))