mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-27 10:55:04 +00:00
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser, org-element-drawer-parser, org-element-dynamic-block-parser, org-element-footnote-definition-parser, org-element-plain-list-parser, org-element-quote-block-parser, org-element-special-block-parser, org-element-babel-call-parser, org-element-comment-parser, org-element-comment-block-parser, org-element-example-block-parser, org-element-export-block-parser, org-element-fixed-width-parser, org-element-horizontal-rule-parser, org-element-keyword-parser, org-element-latex-environment-parser, org-element-paragraph-parser, org-element-property-drawer-parser, org-element-src-block-parser, org-element-table-parser, org-element-verse-block-parser): Change signature. Now use an additional argument: affiliated. (org-element--current-element): Skip affiliated keywords and pass them as an argument to parsers. It prevents to walk through these keywords twice: the first time to get to the first line of the element, and a second time to collect the affiliated keywords. * contrib/lisp/org-export.el (org-export-get-caption): Update function since multiple affiliated keywords are now reversed. * testing/lisp/test-org-element.el: Update tests.
This commit is contained in:
parent
7c40e0c6ba
commit
baed7dc7db
@ -2912,7 +2912,7 @@ Caption lines are separated by a white space."
|
||||
(dolist (line full-caption (cdr caption))
|
||||
(let ((cap (funcall (if shortp 'cdr 'car) line)))
|
||||
(when cap
|
||||
(setq caption (nconc caption (list " ") (copy-sequence cap))))))))
|
||||
(setq caption (nconc (list " ") (copy-sequence cap) caption)))))))
|
||||
|
||||
|
||||
;;;; For Export Snippets
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -168,7 +168,7 @@ Some other text
|
||||
;; Parse multiple keywords.
|
||||
(should
|
||||
(equal
|
||||
'("line1" "line2")
|
||||
'("line2" "line1")
|
||||
(org-element-property
|
||||
:attr_ascii
|
||||
(org-test-with-temp-text
|
||||
@ -189,7 +189,7 @@ Some other text
|
||||
;; Allow multiple caption keywords.
|
||||
(should
|
||||
(equal
|
||||
'((("l1") "s1") (("l2") "s2"))
|
||||
'((("l2") "s2") (("l1") "s1"))
|
||||
(org-test-with-temp-text "#+CAPTION[s1]: l1\n#+CAPTION[s2]: l2\nParagraph"
|
||||
(org-element-property :caption (org-element-at-point))))))
|
||||
|
||||
@ -1692,7 +1692,7 @@ Outside list"
|
||||
(should
|
||||
(equal
|
||||
(org-element-interpret-data
|
||||
'(org-data nil (paragraph (:attr_ascii ("line1" "line2")) "Paragraph")))
|
||||
'(org-data nil (paragraph (:attr_ascii ("line2" "line1")) "Paragraph")))
|
||||
"#+ATTR_ASCII: line1\n#+ATTR_ASCII: line2\nParagraph\n"))
|
||||
;; Interpret parsed keywords.
|
||||
(should
|
||||
@ -1711,7 +1711,7 @@ Outside list"
|
||||
(equal
|
||||
(org-element-interpret-data
|
||||
'(org-data nil (paragraph
|
||||
(:caption ((("l1") "s1") (("l2") "s2"))) "Paragraph")))
|
||||
(:caption ((("l2") "s2") (("l1") "s1"))) "Paragraph")))
|
||||
"#+CAPTION[s1]: l1\n#+CAPTION[s2]: l2\nParagraph\n")))
|
||||
|
||||
(ert-deftest test-org-element/center-block-interpreter ()
|
||||
|
Loading…
Reference in New Issue
Block a user