Browse Source

Fix property drawer insertion with consecutive headlines

* lisp/org.el (org-get-property-block): Fix property drawer insertion
  with consecutive headlines
* testing/lisp/test-org.el (test-org/entry-put): Add test.

Thanks to Eric Abrahamsen for reporting it.
Nicolas Goaziou 10 years ago
parent
commit
705a2cdeab
2 changed files with 8 additions and 1 deletions
  1. 1 0
      lisp/org.el
  2. 7 1
      testing/lisp/test-org.el

+ 1 - 0
lisp/org.el

@@ -15337,6 +15337,7 @@ return nil."
 	      (cons (point) (progn (goto-char (match-end 0))
 				   (line-beginning-position))))
 	     (force
+	      (goto-char beg)
 	      (org-insert-property-drawer)
 	      (let ((pos (save-excursion (search-forward ":END:")
 					 (line-beginning-position))))

+ 7 - 1
testing/lisp/test-org.el

@@ -2366,7 +2366,13 @@ Text.
    (string-match "^ *:A: +1$"
 		 (org-test-with-temp-text "* H"
 		   (org-entry-put (point) "A" "1")
-		   (buffer-string)))))
+		   (buffer-string))))
+  ;; Special case: two consecutive headlines.
+  (should
+   (string-match "\\* A\n *:PROPERTIES:"
+    (org-test-with-temp-text "* A\n** B"
+      (org-entry-put (point) "A" "1")
+      (buffer-string)))))
 
 
 ;;; Radio Targets