summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2014-01-29 23:57:24 (GMT)
committer Bastien Guerry <bzg@altern.org>2014-01-29 23:57:24 (GMT)
commit9368d317fb8488e7f379164b7c02d22e88254449 (patch)
treec289fc3b8e85176b89eeabc018c4631642123088
parent72ad5257fcd40d899eae980a987733fda993c916 (diff)
downloadorg-mode-9368d317fb8488e7f379164b7c02d22e88254449.zip
org-mode-9368d317fb8488e7f379164b7c02d22e88254449.tar.gz
ob-tangle.el (org-babel-under-commented-heading-p): Throw nil when called before the first heading
* ob-tangle.el (org-babel-under-commented-heading-p): Throw nil when called before the first heading. Thanks to John Kitchin for reporting this.
-rw-r--r--lisp/ob-tangle.el13
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 581142b..a44d585 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -358,12 +358,13 @@ that the appropriate major-mode is set. SPEC has the form:
(defvar org-comment-string) ;; Defined in org.el
(defun org-babel-under-commented-heading-p ()
"Return t if currently under a commented heading."
- (if (let ((hd (nth 4 (org-heading-components))))
- (and hd (string-match (concat "^" org-comment-string) hd)))
- t
- (save-excursion
- (and (org-up-heading-safe)
- (org-babel-under-commented-heading-p)))))
+ (unless (org-before-first-heading-p)
+ (if (let ((hd (nth 4 (org-heading-components))))
+ (and hd (string-match (concat "^" org-comment-string) hd)))
+ t
+ (save-excursion
+ (and (org-up-heading-safe)
+ (org-babel-under-commented-heading-p))))))
(defun org-babel-tangle-collect-blocks (&optional language tangle-file)
"Collect source blocks in the current Org-mode file.