Use new function names `org-element-extract' and `org-element-set'

This commit is contained in:
Ihor Radchenko 2023-05-14 20:39:05 +02:00
parent 29cb0b370b
commit c22697f472
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
11 changed files with 229 additions and 229 deletions

View File

@ -77,7 +77,7 @@
(declare-function org-element-class "org-element" (datum &optional parent))
(declare-function org-element-contents "org-element" (element))
(declare-function org-element-create "org-element" (type &optional props &rest children))
(declare-function org-element-extract-element "org-element" (element))
(declare-function org-element-extract "org-element" (element))
(declare-function org-element-insert-before "org-element" (element location))
(declare-function org-element-lineage "org-element" (datum &optional types with-self))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
@ -88,7 +88,7 @@
(declare-function org-element-property "org-element" (property element))
(declare-function org-element-put-property "org-element" (element property value))
(declare-function org-element-restriction "org-element" (element))
(declare-function org-element-set-element "org-element" (old new))
(declare-function org-element-set "org-element" (old new))
(declare-function org-element-type "org-element" (element))
(declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
@ -472,7 +472,7 @@ by side-effect."
(org-element-put-property datum :post-blank blanks)
;; Remove any blank from string before DATUM so it is exported
;; with exactly BLANKS white spaces.
(org-element-set-element
(org-element-set
datum
(replace-regexp-in-string
"[ \t\n]*\\'" (make-string blanks ?\s) datum))))
@ -496,7 +496,7 @@ This function assumes S precedes CITATION."
(when (and post-blank (> post-blank 0))
(org-element-insert-before (make-string post-blank ?\s) citation)))
(org-element-insert-before
(org-element-put-property (org-element-extract-element citation)
(org-element-put-property (org-element-extract citation)
:post-blank 0)
s)
(string-match regexp s)
@ -510,15 +510,15 @@ This function assumes S precedes CITATION."
(substring s split))))
(when (org-string-nw-p first-part)
(org-element-insert-before first-part citation))
(org-element-set-element s last-part)))
(org-element-set s last-part)))
(defun org-cite--move-punct-before (punct citation s info)
"Move punctuation PUNCT before CITATION object.
String S contains PUNCT. INFO is the export state, as a property list.
The function assumes S follows CITATION. Parse tree is modified by side-effect."
(if (equal s punct)
(org-element-extract-element s) ;it would be empty anyway
(org-element-set-element s (substring s (length punct))))
(org-element-extract s) ;it would be empty anyway
(org-element-set s (substring s (length punct))))
;; Remove blanks before citation.
(org-cite--set-previous-post-blank citation 0 info)
(org-element-insert-before
@ -983,7 +983,7 @@ Return newly created footnote object."
;; Footnote swallows citation.
(org-element-insert-before footnote citation)
(org-element-adopt-elements footnote
(org-element-extract-element citation))))
(org-element-extract citation))))
(defun org-cite-adjust-note (citation info &optional rule punct)
"Adjust note number location for CITATION object, and punctuation around it.
@ -1062,8 +1062,8 @@ the same object, call `org-cite-adjust-note' first."
;; as an argument is not available.
(rx-to-string `(seq string-start ,final-punct) t)
"" next)))
(org-element-set-element previous new-prev)
(org-element-set-element next new-next)
(org-element-set previous new-prev)
(org-element-set next new-next)
(setq previous new-prev)
(setq next new-next)
(setq punct final-punct)
@ -1082,10 +1082,10 @@ the same object, call `org-cite-adjust-note' first."
(replace-regexp-in-string
previous-punct-re "" previous nil nil 1))
(new-next (if (stringp next) (concat punct next) punct)))
(org-element-set-element previous new-prev)
(org-element-set previous new-prev)
(cond
((stringp next)
(org-element-set-element next new-next))
(org-element-set next new-next))
(next
(org-element-insert-before new-next next))
(t
@ -1405,7 +1405,7 @@ by side-effect."
(_
(error "Invalid return value from citation export processor: %S"
replacement))))
(org-element-extract-element cite))))
(org-element-extract cite))))
(defun org-cite-process-bibliography (info)
"Replace all \"print_bibliography\" keywords in the parse tree.
@ -1422,12 +1422,12 @@ by side effect."
;; `:post-blank' property to the element before, if any.
('nil
(org-cite--set-previous-post-blank keyword blanks info)
(org-element-extract-element keyword))
(org-element-extract keyword))
;; Handle `:post-blank' before replacing keyword with string.
((pred stringp)
(let ((output (concat (org-element-normalize-string replacement)
(make-string blanks ?\n))))
(org-element-set-element keyword (org-export-raw-string output))))
(org-element-set keyword (org-export-raw-string output))))
;; List of elements: splice contents before keyword and
;; remove the latter. Transfer `:post-blank' to last
;; element.
@ -1437,11 +1437,11 @@ by side effect."
(setq last datum)
(org-element-insert-before datum keyword))
(org-cite--set-post-blank last blanks)
(org-element-extract-element keyword)))
(org-element-extract keyword)))
;; Single element: replace the keyword.
(`(,(pred symbolp) . ,_)
(org-cite--set-post-blank replacement blanks)
(org-element-set-element keyword replacement))
(org-element-set keyword replacement))
(_
(error "Invalid return value from citation export processor: %S"
replacement))))))

View File

@ -37,7 +37,7 @@
(declare-function org-agenda-redo "org-agenda" (&optional all))
(declare-function org-agenda-do-context-action "org-agenda" ())
(declare-function org-clock-sum-today "org-clock" (&optional headline-filter))
(declare-function org-element-extract-element "org-element" (element))
(declare-function org-element-extract "org-element" (element))
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
@ -1422,7 +1422,7 @@ an inline src-block."
(org-element-map data
'(footnote-reference inline-babel-call inline-src-block target
radio-target statistics-cookie)
#'org-element-extract-element)
#'org-element-extract)
(org-no-properties (org-element-interpret-data data))))
;;;###autoload

View File

@ -497,8 +497,8 @@ past the brackets."
;; There is `org-element-put-property', `org-element-set-contents'.
;; These low-level functions are useful to build a parse tree.
;;
;; `org-element-adopt-elements', `org-element-set-element',
;; `org-element-extract-element' and `org-element-insert-before' are
;; `org-element-adopt-elements', `org-element-set',
;; `org-element-extract' and `org-element-insert-before' are
;; high-level functions useful to modify a parse tree.
;;
;; `org-element-secondary-p' is a predicate used to know if a given
@ -4181,7 +4181,7 @@ Assume point is at the first equal sign marker."
(defvar org-inlinetask-min-level); Declared in org-inlinetask.el
(defvar org-element--cache-sync-requests); Declared later
(defun org-element--current-element (limit &optional granularity mode structure)
"Parse the element starting at point.
"Parse the element starting at point.
Return value is a list like (TYPE PROPS) where TYPE is the type
of the element and PROPS a plist of properties associated to the
@ -4207,175 +4207,175 @@ computed.
This function assumes point is always at the beginning of the
element it has to parse."
(save-excursion
(let ((case-fold-search t)
;; Determine if parsing depth allows for secondary strings
;; parsing. It only applies to elements referenced in
;; `org-element-secondary-value-alist'.
(raw-secondary-p (and granularity (not (eq granularity 'object))))
result at-task?)
(setq
result
;; Regexp matches below should avoid modifying match data,
;; if possible. Doing it unnecessarily degrades regexp
;; matching performance an order of magnitude, which
;; becomes important when parsing large buffers with huge
;; amount of elements to be parsed.
;;
;; In general, the checks below should be as efficient as
;; possible, especially early in the `cond' form. (The
;; early checks will contribute to al subsequent parsers as
;; well).
(cond
;; Item.
((eq mode 'item) (org-element-item-parser limit structure raw-secondary-p))
;; Table Row.
((eq mode 'table-row) (org-element-table-row-parser limit))
;; Node Property.
((eq mode 'node-property) (org-element-node-property-parser limit))
;; Headline.
((and (looking-at-p "^\\*+ ")
(setq at-task? t)
(or (not (featurep 'org-inlinetask))
(save-excursion
(< (skip-chars-forward "*")
(if org-odd-levels-only
(1- (* org-inlinetask-min-level 2))
org-inlinetask-min-level)))))
(org-element-headline-parser limit raw-secondary-p))
;; Sections (must be checked after headline).
((memq mode '(section first-section)) (org-element-section-parser nil))
;; Comments.
((looking-at-p "^[ \t]*#\\(?: \\|$\\)") (org-element-comment-parser limit))
;; Planning.
((and (eq mode 'planning)
(eq ?* (char-after (line-beginning-position 0)))
(looking-at-p org-element-planning-line-re))
(org-element-planning-parser limit))
;; Property drawer.
((and (pcase mode
(`planning (eq ?* (char-after (line-beginning-position 0))))
((or `property-drawer `top-comment)
(save-excursion
(beginning-of-line 0)
(not (looking-at-p "[[:blank:]]*$"))))
(_ nil))
(looking-at-p org-property-drawer-re))
(org-element-property-drawer-parser limit))
;; When not at bol, point is at the beginning of an item or
;; a footnote definition: next item is always a paragraph.
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
;; Clock.
((looking-at-p org-element-clock-line-re) (org-element-clock-parser limit))
;; Inlinetask.
(at-task? (org-element-inlinetask-parser limit raw-secondary-p))
;; From there, elements can have affiliated keywords.
(t (let ((affiliated (org-element--collect-affiliated-keywords
limit (memq granularity '(nil object)))))
(cond
;; Jumping over affiliated keywords put point off-limits.
;; Parse them as regular keywords.
((and (cdr affiliated) (>= (point) limit))
(goto-char (car affiliated))
(org-element-keyword-parser limit nil))
;; LaTeX Environment.
((looking-at-p org-element--latex-begin-environment)
(org-element-latex-environment-parser limit affiliated))
;; Drawer.
((looking-at-p org-element-drawer-re)
(org-element-drawer-parser limit affiliated))
;; Fixed Width
((looking-at-p "[ \t]*:\\( \\|$\\)")
(org-element-fixed-width-parser limit affiliated))
;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
;; Keywords.
((looking-at "[ \t]*#\\+")
(goto-char (match-end 0))
(save-excursion
(let ((case-fold-search t)
;; Determine if parsing depth allows for secondary strings
;; parsing. It only applies to elements referenced in
;; `org-element-secondary-value-alist'.
(raw-secondary-p (and granularity (not (eq granularity 'object))))
result at-task?)
(setq
result
;; Regexp matches below should avoid modifying match data,
;; if possible. Doing it unnecessarily degrades regexp
;; matching performance an order of magnitude, which
;; becomes important when parsing large buffers with huge
;; amount of elements to be parsed.
;;
;; In general, the checks below should be as efficient as
;; possible, especially early in the `cond' form. (The
;; early checks will contribute to al subsequent parsers as
;; well).
(cond
;; Item.
((eq mode 'item) (org-element-item-parser limit structure raw-secondary-p))
;; Table Row.
((eq mode 'table-row) (org-element-table-row-parser limit))
;; Node Property.
((eq mode 'node-property) (org-element-node-property-parser limit))
;; Headline.
((and (looking-at-p "^\\*+ ")
(setq at-task? t)
(or (not (featurep 'org-inlinetask))
(save-excursion
(< (skip-chars-forward "*")
(if org-odd-levels-only
(1- (* org-inlinetask-min-level 2))
org-inlinetask-min-level)))))
(org-element-headline-parser limit raw-secondary-p))
;; Sections (must be checked after headline).
((memq mode '(section first-section)) (org-element-section-parser nil))
;; Comments.
((looking-at-p "^[ \t]*#\\(?: \\|$\\)") (org-element-comment-parser limit))
;; Planning.
((and (eq mode 'planning)
(eq ?* (char-after (line-beginning-position 0)))
(looking-at-p org-element-planning-line-re))
(org-element-planning-parser limit))
;; Property drawer.
((and (pcase mode
(`planning (eq ?* (char-after (line-beginning-position 0))))
((or `property-drawer `top-comment)
(save-excursion
(beginning-of-line 0)
(not (looking-at-p "[[:blank:]]*$"))))
(_ nil))
(looking-at-p org-property-drawer-re))
(org-element-property-drawer-parser limit))
;; When not at bol, point is at the beginning of an item or
;; a footnote definition: next item is always a paragraph.
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
;; Clock.
((looking-at-p org-element-clock-line-re) (org-element-clock-parser limit))
;; Inlinetask.
(at-task? (org-element-inlinetask-parser limit raw-secondary-p))
;; From there, elements can have affiliated keywords.
(t (let ((affiliated (org-element--collect-affiliated-keywords
limit (memq granularity '(nil object)))))
(cond
((looking-at "BEGIN_\\(\\S-+\\)")
(beginning-of-line)
(funcall (pcase (upcase (match-string 1))
("CENTER" #'org-element-center-block-parser)
("COMMENT" #'org-element-comment-block-parser)
("EXAMPLE" #'org-element-example-block-parser)
("EXPORT" #'org-element-export-block-parser)
("QUOTE" #'org-element-quote-block-parser)
("SRC" #'org-element-src-block-parser)
("VERSE" #'org-element-verse-block-parser)
(_ #'org-element-special-block-parser))
limit
affiliated))
((looking-at-p "CALL:")
(beginning-of-line)
(org-element-babel-call-parser limit affiliated))
((save-excursion
(beginning-of-line)
(looking-at-p org-element-dynamic-block-open-re))
(beginning-of-line)
(org-element-dynamic-block-parser limit affiliated))
((looking-at-p "\\S-+:")
(beginning-of-line)
(org-element-keyword-parser limit affiliated))
(t
(beginning-of-line)
(org-element-paragraph-parser limit affiliated))))
;; Footnote Definition.
((looking-at-p org-footnote-definition-re)
(org-element-footnote-definition-parser limit affiliated))
;; Horizontal Rule.
((looking-at-p "[ \t]*-\\{5,\\}[ \t]*$")
(org-element-horizontal-rule-parser limit affiliated))
;; Diary Sexp.
((looking-at-p "%%(")
(org-element-diary-sexp-parser limit affiliated))
;; Table.
((or (looking-at-p "[ \t]*|")
;; There is no strict definition of a table.el
;; table. Try to prevent false positive while being
;; quick.
(let ((rule-regexp
(rx (zero-or-more (any " \t"))
"+"
(one-or-more (one-or-more "-") "+")
(zero-or-more (any " \t"))
eol))
(non-table.el-line
(rx bol
(zero-or-more (any " \t"))
(or eol (not (any "+| \t")))))
(next (line-beginning-position 2)))
;; Start with a full rule.
(and
(looking-at-p rule-regexp)
(< next limit) ;no room for a table.el table
(save-excursion
(end-of-line)
(cond
;; Must end with a full rule.
((not (re-search-forward non-table.el-line limit 'move))
(if (bolp) (forward-line -1) (beginning-of-line))
(looking-at-p rule-regexp))
;; Ignore pseudo-tables with a single
;; rule.
((= next (line-beginning-position))
nil)
;; Must end with a full rule.
(t
(forward-line -1)
(looking-at-p rule-regexp)))))))
(org-element-table-parser limit affiliated))
;; List.
((looking-at-p (org-item-re))
(org-element-plain-list-parser
limit affiliated
(or structure (org-element--list-struct limit))))
;; Default element: Paragraph.
(t (org-element-paragraph-parser limit affiliated)))))))
(when result
(org-element-put-property result :buffer (current-buffer))
(org-element-put-property result :mode mode)
(org-element-put-property result :granularity granularity))
result)))
;; Jumping over affiliated keywords put point off-limits.
;; Parse them as regular keywords.
((and (cdr affiliated) (>= (point) limit))
(goto-char (car affiliated))
(org-element-keyword-parser limit nil))
;; LaTeX Environment.
((looking-at-p org-element--latex-begin-environment)
(org-element-latex-environment-parser limit affiliated))
;; Drawer.
((looking-at-p org-element-drawer-re)
(org-element-drawer-parser limit affiliated))
;; Fixed Width
((looking-at-p "[ \t]*:\\( \\|$\\)")
(org-element-fixed-width-parser limit affiliated))
;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
;; Keywords.
((looking-at "[ \t]*#\\+")
(goto-char (match-end 0))
(cond
((looking-at "BEGIN_\\(\\S-+\\)")
(beginning-of-line)
(funcall (pcase (upcase (match-string 1))
("CENTER" #'org-element-center-block-parser)
("COMMENT" #'org-element-comment-block-parser)
("EXAMPLE" #'org-element-example-block-parser)
("EXPORT" #'org-element-export-block-parser)
("QUOTE" #'org-element-quote-block-parser)
("SRC" #'org-element-src-block-parser)
("VERSE" #'org-element-verse-block-parser)
(_ #'org-element-special-block-parser))
limit
affiliated))
((looking-at-p "CALL:")
(beginning-of-line)
(org-element-babel-call-parser limit affiliated))
((save-excursion
(beginning-of-line)
(looking-at-p org-element-dynamic-block-open-re))
(beginning-of-line)
(org-element-dynamic-block-parser limit affiliated))
((looking-at-p "\\S-+:")
(beginning-of-line)
(org-element-keyword-parser limit affiliated))
(t
(beginning-of-line)
(org-element-paragraph-parser limit affiliated))))
;; Footnote Definition.
((looking-at-p org-footnote-definition-re)
(org-element-footnote-definition-parser limit affiliated))
;; Horizontal Rule.
((looking-at-p "[ \t]*-\\{5,\\}[ \t]*$")
(org-element-horizontal-rule-parser limit affiliated))
;; Diary Sexp.
((looking-at-p "%%(")
(org-element-diary-sexp-parser limit affiliated))
;; Table.
((or (looking-at-p "[ \t]*|")
;; There is no strict definition of a table.el
;; table. Try to prevent false positive while being
;; quick.
(let ((rule-regexp
(rx (zero-or-more (any " \t"))
"+"
(one-or-more (one-or-more "-") "+")
(zero-or-more (any " \t"))
eol))
(non-table.el-line
(rx bol
(zero-or-more (any " \t"))
(or eol (not (any "+| \t")))))
(next (line-beginning-position 2)))
;; Start with a full rule.
(and
(looking-at-p rule-regexp)
(< next limit) ;no room for a table.el table
(save-excursion
(end-of-line)
(cond
;; Must end with a full rule.
((not (re-search-forward non-table.el-line limit 'move))
(if (bolp) (forward-line -1) (beginning-of-line))
(looking-at-p rule-regexp))
;; Ignore pseudo-tables with a single
;; rule.
((= next (line-beginning-position))
nil)
;; Must end with a full rule.
(t
(forward-line -1)
(looking-at-p rule-regexp)))))))
(org-element-table-parser limit affiliated))
;; List.
((looking-at-p (org-item-re))
(org-element-plain-list-parser
limit affiliated
(or structure (org-element--list-struct limit))))
;; Default element: Paragraph.
(t (org-element-paragraph-parser limit affiliated)))))))
(when result
(org-element-put-property result :buffer (current-buffer))
(org-element-put-property result :mode mode)
(org-element-put-property result :granularity granularity))
result)))
;; Most elements can have affiliated keywords. When looking for an
@ -6888,7 +6888,7 @@ known element in cache (it may start after END)."
(org-element--cache-log-message
"Found non-robust headline that can be updated individually: %S"
(org-element--format-element current))
(org-element-set-element up current org-element--cache-element-properties)
(org-element-set up current org-element--cache-element-properties)
t)))
;; If UP is org-data, the situation is similar to
;; headline case. We just need to re-parse the
@ -6897,7 +6897,7 @@ known element in cache (it may start after END)."
;; potentially alter first-section).
(when (and (eq 'org-data (org-element-type up))
(>= beg (org-element-property :contents-begin up)))
(org-element-set-element up (org-with-point-at 1 (org-element-org-data-parser)) org-element--cache-element-properties)
(org-element-set up (org-with-point-at 1 (org-element-org-data-parser)) org-element--cache-element-properties)
(org-element--cache-log-message
"Found non-robust change invalidating org-data. Re-parsing: %S"
(org-element--format-element up))

View File

@ -118,7 +118,7 @@
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-property "org-element" (property element))
(declare-function org-element-put-property "org-element" (element property value))
(declare-function org-element-set-element "org-element" (old new))
(declare-function org-element-set "org-element" (old new))
(declare-function org-element-type "org-element" (element))
(declare-function org-element-update-syntax "org-element" ())
(declare-function org-end-of-meta-data "org" (&optional full))
@ -3459,7 +3459,7 @@ Valid parameters are:
(when (and backend (plist-get params :raw))
(org-element-map data org-element-all-objects
(lambda (object)
(org-element-set-element
(org-element-set
object (org-element-interpret-data object)))))
;; We use a low-level mechanism to export DATA so as to skip all
;; usual pre-processing and post-processing, i.e., hooks, filters,

View File

@ -53,7 +53,7 @@
(declare-function org-duration-to-minutes "org-duration" (duration &optional canonical))
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
(declare-function org-element-contents "org-element" (element))
(declare-function org-element-extract-element "org-element" (element))
(declare-function org-element-extract "org-element" (element))
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-lineage "org-element" (blob &optional types with-self))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
@ -5761,7 +5761,7 @@ This may be either a string or a function of two arguments:
(org-element-map data 'table-row
(lambda (row)
(if (>= n skip) t
(org-element-extract-element row)
(org-element-extract row)
(cl-incf n)
nil))
nil t))))
@ -5778,7 +5778,7 @@ This may be either a string or a function of two arguments:
(dolist (cell (nthcdr (if specialp 1 0)
(org-element-contents row)))
(when (memq c skipcols)
(org-element-extract-element cell))
(org-element-extract cell))
(cl-incf c))))))))))
;; Since we are going to export using a low-level mechanism,
;; ignore special column and special rows manually.

View File

@ -175,7 +175,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-element-context "org-element" (&optional element))
(declare-function org-element-copy "org-element" (datum))
(declare-function org-element-create "org-element" (type &optional props &rest children))
(declare-function org-element-extract-element "org-element" (element))
(declare-function org-element-extract "org-element" (element))
(declare-function org-element-insert-before "org-element" (element location))
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-keyword-parser "org-element" (limit affiliated))
@ -7607,7 +7607,7 @@ Assume S may contain only objects."
(org-element-insert-before c o))
(org-element-put-property
c :post-blank (org-element-property :post-blank o)))))
(org-element-extract-element o)))
(org-element-extract o)))
;; Return modified tree.
tree)))

View File

@ -3151,7 +3151,7 @@ it."
mode))
(org-element-put-property table :name nil)
(org-element-put-property table :caption nil)
(org-element-extract-element previous)
(org-element-extract previous)
(org-element-adopt-elements matrices previous)
(setq previous next))
;; Inherit `:post-blank' from the value of the last
@ -3162,7 +3162,7 @@ it."
(org-element-put-property previous :post-blank 0)
(org-element-put-property table :name nil)
(org-element-put-property table :caption nil)
(org-element-extract-element previous)
(org-element-extract previous)
(org-element-adopt-elements matrices previous))))))
info)
data)
@ -3215,14 +3215,14 @@ containing export options. Modify DATA by side-effect and return it."
(last object))
;; Wrap MATH-BLOCK around OBJECT in DATA.
(org-element-insert-before math-block object)
(org-element-extract-element object)
(org-element-extract object)
(org-element-adopt-elements math-block object)
(when (zerop (or (org-element-property :post-blank object) 0))
;; MATH-BLOCK swallows consecutive math objects.
(catch 'exit
(dolist (next next-elements)
(unless (funcall valid-object-p next) (throw 'exit nil))
(org-element-extract-element next)
(org-element-extract next)
(org-element-adopt-elements math-block next)
;; Eschew the case: \beta$x$ -> \(\betax\).
(org-element-put-property last :post-blank 1)

View File

@ -3817,7 +3817,7 @@ contextual information."
replacement :post-blank
(org-element-property :post-blank latex-*))
;; Replace now.
(org-element-set-element latex-* replacement)))))
(org-element-set latex-* replacement)))))
info nil nil t)))
tree)
@ -3861,7 +3861,7 @@ contextual information."
(org-element-map tree 'plain-list
(lambda (el)
(when (eq (org-element-property :type el) 'descriptive)
(org-element-set-element
(org-element-set
el
(apply 'org-element-adopt-elements
(list 'plain-list (list :type 'descriptive-1))
@ -3928,7 +3928,7 @@ contextual information."
(lambda (l1-list)
(when (org-export-read-attribute :attr_odt l1-list :list-table)
;; Replace list with table.
(org-element-set-element
(org-element-set
l1-list
;; Build replacement table.
(apply 'org-element-adopt-elements

View File

@ -657,7 +657,7 @@ Return new tree."
(org-texinfo--massage-key-item plain-list item args info))
(push item items)))))
(unless (org-element-contents plain-list)
(org-element-extract-element plain-list)))))
(org-element-extract plain-list)))))
info)
tree)
@ -687,9 +687,9 @@ specified by CMD and ARGS."
(list :type cmd
:attr_texinfo (list (format ":options %s" args))
:post-blank (if contents 1 0))
(mapc #'org-element-extract-element contents))
(mapc #'org-element-extract contents))
plain-list))
(org-element-extract-element item))
(org-element-extract item))
(defun org-texinfo--split-plain-list (plain-list items)
"Insert a new plain list before the plain list PLAIN-LIST.
@ -700,7 +700,7 @@ new plain list."
(list :type 'descriptive
:attr_texinfo (org-element-property :attr_texinfo plain-list)
:post-blank 1)
(mapc #'org-element-extract-element items))
(mapc #'org-element-extract items))
plain-list))
(defun org-texinfo--massage-key-item (plain-list item args info)

View File

@ -1576,7 +1576,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
(org-element-restriction 'keyword))))
(org-element-map value 'plain-text
(lambda (s)
(org-element-set-element
(org-element-set
s (replace-regexp-in-string "\n" " " s))))
(setq plist (plist-put plist p value)))))))
@ -2783,7 +2783,7 @@ from tree."
(let ((post-blank (org-element-property :post-blank data)))
(if (or (not post-blank) (zerop post-blank)
(eq 'element (org-element-class data)))
(org-element-extract-element data)
(org-element-extract data)
;; Keep spaces in place of removed
;; element, if necessary.
;; Example: "Foo.[10%] Bar" would become
@ -2796,8 +2796,8 @@ from tree."
(rx whitespace eos) previous))
(_ (org-element-property :post-blank previous))))
;; Previous object ends with whitespace already.
(org-element-extract-element data)
(org-element-set-element data (make-string post-blank ?\s)))))))
(org-element-extract data)
(org-element-set data (make-string post-blank ?\s)))))))
(if (and (eq type 'headline)
(eq (plist-get info :with-archived-trees)
'headline)
@ -2827,7 +2827,7 @@ from tree."
(when selected
(let ((first-element (car (org-element-contents data))))
(when (eq (org-element-type first-element) 'section)
(org-element-extract-element first-element))))
(org-element-extract first-element))))
;; Prune tree and communication channel.
(funcall walk-data data)
(dolist (entry (append
@ -3033,7 +3033,7 @@ returned by the function."
post-blank)))))))))
(when new
;; Splice NEW at DATUM location in parse tree.
(dolist (e new (org-element-extract-element datum))
(dolist (e new (org-element-extract datum))
(unless (equal e "") (org-element-insert-before e datum))))))
info nil nil t)
;; Return modified parse tree.

View File

@ -196,14 +196,14 @@ Some other text
(org-element-map tree 'bold 'identity nil t)))))))
(ert-deftest test-org-element/extract-element ()
"Test `org-element-extract-element' specifications."
"Test `org-element-extract' specifications."
;; Extract a greater element.
(should
(eq 'org-data
(org-test-with-temp-text "* Headline"
(let* ((tree (org-element-parse-buffer))
(element (org-element-map tree 'headline 'identity nil t)))
(org-element-extract-element element)
(org-element-extract element)
(org-element-type tree)))))
;; Extract an element.
(should-not
@ -211,7 +211,7 @@ Some other text
(org-test-with-temp-text "Paragraph"
(let* ((tree (org-element-parse-buffer))
(element (org-element-map tree 'paragraph 'identity nil t)))
(org-element-extract-element element)
(org-element-extract element)
tree))
'paragraph
'identity))
@ -221,7 +221,7 @@ Some other text
(org-test-with-temp-text "*bold*"
(let* ((tree (org-element-parse-buffer))
(element (org-element-map tree 'bold 'identity nil t)))
(org-element-extract-element element)
(org-element-extract element)
tree))
'bold
'identity))
@ -230,7 +230,7 @@ Some other text
(org-test-with-temp-text "* Headline *bold*"
(let* ((tree (org-element-parse-buffer))
(element (org-element-map tree 'bold 'identity nil t)))
(org-element-extract-element element)
(org-element-extract element)
tree))
'bold
'identity))
@ -241,7 +241,7 @@ Some other text
(org-test-with-temp-text "* Headline\n Paragraph with *bold* text."
(let* ((tree (org-element-parse-buffer))
(element (org-element-map tree 'bold 'identity nil t)))
(org-element-extract-element element))))))
(org-element-extract element))))))
(ert-deftest test-org-element/insert-before ()
"Test `org-element-insert-before' specifications."
@ -268,20 +268,20 @@ Some other text
#'org-element-type))))))
(ert-deftest test-org-element/set-element ()
"Test `org-element-set-element' specifications."
"Test `org-element-set' specifications."
;; Check if new element is inserted.
(should
(org-test-with-temp-text "* Headline\n*a*"
(let* ((tree (org-element-parse-buffer))
(bold (org-element-map tree 'bold 'identity nil t)))
(org-element-set-element bold '(italic nil "b"))
(org-element-set bold '(italic nil "b"))
(org-element-map tree 'italic 'identity))))
;; Check if old element is removed.
(should-not
(org-test-with-temp-text "* Headline\n*a*"
(let* ((tree (org-element-parse-buffer))
(bold (org-element-map tree 'bold 'identity nil t)))
(org-element-set-element bold '(italic nil "b"))
(org-element-set bold '(italic nil "b"))
(org-element-map tree 'bold 'identity))))
;; Check if :parent property is correctly set.
(should
@ -289,7 +289,7 @@ Some other text
(org-test-with-temp-text "* Headline\n*a*"
(let* ((tree (org-element-parse-buffer))
(bold (org-element-map tree 'bold 'identity nil t)))
(org-element-set-element bold '(italic nil "b"))
(org-element-set bold '(italic nil "b"))
(org-element-type
(org-element-property
:parent (org-element-map tree 'italic 'identity nil t)))))))
@ -299,7 +299,7 @@ Some other text
(org-test-with-temp-text "* Headline"
(let* ((tree (org-element-parse-buffer))
(text (org-element-map tree 'plain-text 'identity nil t)))
(org-element-set-element text (list 'bold nil "b"))
(org-element-set text (list 'bold nil "b"))
(org-element-map tree 'plain-text 'identity)))))
;; Allow to replace elements with strings.
(should
@ -307,7 +307,7 @@ Some other text
(org-test-with-temp-text "* =verbatim="
(let* ((tree (org-element-parse-buffer))
(verb (org-element-map tree 'verbatim 'identity nil t)))
(org-element-set-element verb "a")
(org-element-set verb "a")
(org-element-map tree 'plain-text 'identity nil t)))))
;; Allow to replace strings with strings.
(should
@ -315,7 +315,7 @@ Some other text
(org-test-with-temp-text "a"
(let* ((tree (org-element-parse-buffer))
(text (org-element-map tree 'plain-text 'identity nil t)))
(org-element-set-element text "b")
(org-element-set text "b")
(org-element-map tree 'plain-text 'identity nil t))))))
(ert-deftest test-org-element/copy ()