Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2013-06-17 17:17:24 +02:00
commit 5e3c3f93bf
2 changed files with 27 additions and 18 deletions

View File

@ -1436,11 +1436,12 @@ containing `:type', `:begin', `:end', `:hiddenp',
Assume point is at the beginning of the block."
(let* ((case-fold-search t)
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(S-+\\)")
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
(upcase (match-string-no-properties 1)))))
(if (not (save-excursion
(re-search-forward
(format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t)))
(format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type))
limit t)))
;; Incomplete block: parse it as a paragraph.
(org-element-paragraph-parser limit affiliated)
(let ((block-end-line (match-beginning 0)))

View File

@ -1648,25 +1648,33 @@ Outside list"
(ert-deftest test-org-element/special-block-parser ()
"Test `special-block' parser."
;; Standard test.
(let ((special-block
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(org-element-map
(org-element-parse-buffer) 'special-block 'identity nil t))))
(should (equal (org-element-property :type special-block) "SPECIAL"))
(should (org-element-map special-block 'paragraph 'identity)))
(should
(equal "SPECIAL"
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(org-element-property :type (org-element-at-point)))))
;; Special blocks can contain paragraphs.
(should
(eq 'paragraph
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(forward-line)
(org-element-type (org-element-at-point)))))
;; Test folded block.
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(org-cycle)
(should
(org-element-property
:hiddenp
(org-element-map
(org-element-parse-buffer) 'special-block 'identity nil t))))
(should
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(org-cycle)
(org-element-property :hiddenp (org-element-at-point))))
;; Ignore incomplete block.
(should-not
(org-test-with-temp-text "#+BEGIN_SPECIAL"
(org-element-map
(org-element-parse-buffer) 'special-block 'identity nil t))))
(eq 'special-block
(org-test-with-temp-text "#+BEGIN_SPECIAL"
(org-element-type (org-element-at-point)))))
;; Allow special characters in type.
(should
(equal '(special-block "SPECIAL*")
(org-test-with-temp-text "#+BEGIN_SPECIAL*\nContents\n#+END_SPECIAL*"
(let ((element (org-element-at-point)))
(list (org-element-type element)
(org-element-property :type element)))))))
;;;; Src Block