Browse Source

org-element--current-element: Fix #+BEGIN$ parsed as special block

* lisp/org-element.el (org-element--current-element): Use
`org-element-dynamic-block-open-re' to match blocks.

* testing/lisp/test-org-element.el (test-org-element/paragraph-parser):
Fix test relying on previous incorrect behaviour.  Empty #+BEGIN:
should be parsed as a keyword.

Reported in https://list.orgmode.org/Ycay4s3iAdEGSwgt@tuxteam.de/T/#t
Ihor Radchenko 3 years ago
parent
commit
e5e7ae36cf
2 changed files with 4 additions and 2 deletions
  1. 3 1
      lisp/org-element.el
  2. 1 1
      testing/lisp/test-org-element.el

+ 3 - 1
lisp/org-element.el

@@ -4268,7 +4268,9 @@ element it has to parse."
 	            ((looking-at "CALL:")
 		     (beginning-of-line)
 		     (org-element-babel-call-parser limit affiliated))
-	            ((looking-at "BEGIN:? ")
+	            ((save-excursion
+                       (beginning-of-line)
+                       (looking-at org-element-dynamic-block-open-re))
 		     (beginning-of-line)
 		     (org-element-dynamic-block-parser limit affiliated))
 	            ((looking-at "\\S-+:")

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

@@ -2126,7 +2126,7 @@ e^{i\\pi}+1=0
 	    (= (point-max) (org-element-property :end elem))))))
   ;; Include incomplete dynamic blocks.
   (should
-   (org-test-with-temp-text "#+BEGIN: \nParagraph"
+   (org-test-with-temp-text "#+BEGIN: \n<point>Paragraph"
      (let ((elem (org-element-at-point)))
        (and (eq (org-element-type elem) 'paragraph)
 	    (= (point-max) (org-element-property :end elem))))))