Bläddra i källkod

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.
Bastien Guerry 11 år sedan
förälder
incheckning
9368d317fb
1 ändrade filer med 7 tillägg och 6 borttagningar
  1. 7 6
      lisp/ob-tangle.el

+ 7 - 6
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.