Rename `org-export-get-parent' to `org-element-parent'

This commit is contained in:
Ihor Radchenko 2023-05-03 14:56:35 +02:00
parent 6a7aee2c35
commit ea4f4fdf58
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
18 changed files with 146 additions and 146 deletions

View File

@ -65,6 +65,7 @@
(declare-function org-element-context "org-element" (&optional element))
(declare-function org-element-normalize-string "org-element" (s))
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-parent "org-element-ast" (node))
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
(declare-function org-element-type-p "org-element-ast" (node &optional types))
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
@ -2153,11 +2154,11 @@ to HASH."
((or `inline-babel-call `inline-src-block)
;; Results for inline objects are located right after them.
;; There is no RESULTS line to insert either.
(let ((limit (pcase (org-element-type (org-element-property :parent context))
(let ((limit (pcase (org-element-type (org-element-parent context))
(`section (org-element-property
:end (org-element-property :parent context)))
:end (org-element-parent context)))
(_ (org-element-property
:contents-end (org-element-property :parent context))))))
:contents-end (org-element-parent context))))))
(goto-char (org-element-property :end context))
(skip-chars-forward " \t\n" limit)
(throw :found
@ -2190,11 +2191,11 @@ to HASH."
;; No possible anonymous results at the very end of
;; buffer or outside CONTEXT parent.
((eq (point)
(or (pcase (org-element-type (org-element-property :parent context))
(or (pcase (org-element-type (org-element-parent context))
((or `section `org-data) (org-element-property
:end (org-element-property :parent context)))
:end (org-element-parent context)))
(_ (org-element-property
:contents-end (org-element-property :parent context))))
:contents-end (org-element-parent context))))
(point-max))))
;; Check if next element is an anonymous result below
;; the current block.
@ -2689,7 +2690,7 @@ Leading white space is trimmed."
(skip-chars-forward
" \t\n"
(org-element-property
:contents-end (org-element-property :parent el)))
:contents-end (org-element-parent el)))
(org-element-context))))
(when (and (org-element-type-p result 'macro)
(string= (org-element-property :key result) "results"))

View File

@ -71,6 +71,7 @@
(require 'oc)
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-parent "org-element-ast" (node))
(declare-function org-export-data "org-export" (data info))
@ -231,7 +232,7 @@ When NO-OPT argument is non-nil, only provide mandatory arguments."
(let* ((origin (pcase references
(`(,reference) reference)
(`(,reference . ,_)
(org-element-property :parent reference))))
(org-element-parent reference))))
(suffix (org-element-property :suffix origin))
(prefix (org-element-property :prefix origin)))
(concat (and prefix

View File

@ -86,6 +86,7 @@
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
(declare-function org-element-context "org-element" (&optional element))
(declare-function org-element-property "org-element-ast" (property node))
(declare-function org-element-parent "org-element-ast" (node))
(declare-function org-element-put-property "org-element-ast" (node property value))
(declare-function org-element-restriction "org-element" (element))
(declare-function org-element-set "org-element-ast" (old new))
@ -765,7 +766,7 @@ When removing the last reference, also remove the whole citation."
(when (= pos-after-blank end)
(org-with-point-at pos-before-blank (insert " ")))))))
('citation-reference
(let* ((citation (org-element-property :parent datum))
(let* ((citation (org-element-parent datum))
(references (org-cite-get-references citation))
(begin (org-element-property :begin datum))
(end (org-element-property :end datum)))
@ -958,7 +959,7 @@ When non-nil, the return value if the footnote container."
'(footnote-definition footnote-reference))))
(and footnote
(or (not strict)
(equal (org-element-contents (org-element-property :parent citation))
(equal (org-element-contents (org-element-parent citation))
(list citation)))
;; Return value.
footnote)))
@ -1091,7 +1092,7 @@ the same object, call `org-cite-adjust-note' first."
(org-element-insert-before new-next next))
(t
(org-element-adopt
(org-element-property :parent citation)
(org-element-parent citation)
new-next)))
(setq previous new-prev)
(setq next new-next)

View File

@ -1134,6 +1134,8 @@ context. See the individual commands for more information."
(define-obsolete-function-alias 'ob-clojure-eval-with-babashka
#'ob-clojure-eval-with-cmd "9.7")
(define-obsolete-function-alias 'org-export-get-parent 'org-element-parent "9.7")
;;;; Obsolete link types
(eval-after-load 'ol

View File

@ -538,6 +538,13 @@ except `:deferred', may not be resolved."
"Like `org-element-property', but reverse the order of NODE and PROPERTY."
(inline-quote (org-element-property ,property ,node ,dflt ,force-undefer)))
(defsubst org-element-parent (node)
"Return `:parent' property of NODE."
(org-element-property :parent node))
(gv-define-setter org-element-parent (value node)
`(org-element-put-property ,node :parent ,value))
(gv-define-setter org-element-property (value property node &optional _)
`(org-element-put-property ,node ,property ,value))
@ -741,7 +748,7 @@ Return the modified PARENT."
"Extract NODE from parse tree.
Remove NODE from the parse tree by side-effect, and return it
with its `:parent' property stripped out."
(let ((parent (org-element-property :parent node))
(let ((parent (org-element-parent node))
(secondary (org-element-secondary-p node)))
(if secondary
(org-element-put-property
@ -757,7 +764,7 @@ with its `:parent' property stripped out."
"Insert NODE before LOCATION in parse tree.
LOCATION is an element, object or string within the parse tree.
Parse tree is modified by side effect."
(let* ((parent (org-element-property :parent location))
(let* ((parent (org-element-parent location))
(property (org-element-secondary-p location))
(siblings (if property (org-element-property property parent)
(org-element-contents parent)))
@ -794,7 +801,7 @@ Return the modified element.
The function takes care of setting `:parent' property for NEW."
;; Ensure OLD and NEW have the same parent.
(org-element-put-property new :parent (org-element-property :parent old))
(org-element-put-property new :parent (org-element-parent old))
;; Handle KEEP-PROPS.
(dolist (p keep-props)
(org-element-put-property new p (org-element-property p old)))
@ -933,7 +940,7 @@ strings.
When CHILDREN is a single anonymous node, use its contents as children
nodes. This way,
(org-element-create 'section nil (org-element-contents node))
(org-element-create \\='section nil (org-element-contents node))
will yield expected results with contents of another node adopted into
a newly created one.
@ -1047,11 +1054,11 @@ When DATUM is obtained through `org-element-context' or
`org-element-at-point', and org-element-cache is disabled, only
ancestors from its section can be found. There is no such limitation
when DATUM belongs to a full parse tree."
(let ((up (if with-self datum (org-element-property :parent datum)))
(let ((up (if with-self datum (org-element-parent datum)))
ancestors)
(while (and up (not (org-element-type-p up types)))
(unless types (push up ancestors))
(setq up (org-element-property :parent up)))
(setq up (org-element-parent up)))
(if types up (nreverse ancestors))))
(defun org-element-lineage-map (datum fun &optional types with-self first-match)
@ -1076,7 +1083,7 @@ When optional argument FIRST-MATCH is non-nil, stop at the first
match for which FUN doesn't return nil, and return that value."
(declare (indent 2))
(setq fun (if (functionp fun) fun `(lambda (node) ,fun)))
(let ((up (if with-self datum (org-element-property :parent datum)))
(let ((up (if with-self datum (org-element-parent datum)))
acc rtn)
(catch :--first-match
(while up
@ -1085,7 +1092,7 @@ match for which FUN doesn't return nil, and return that value."
(if (and first-match rtn)
(throw :--first-match rtn)
(when rtn (push rtn acc))))
(setq up (org-element-property :parent up)))
(setq up (org-element-parent up)))
(nreverse acc))))
(defun org-element-property-inherited (property node &optional with-self accumulate literal-nil include-nil)
@ -1110,7 +1117,7 @@ skipped."
(setq property (ensure-list property))
(let (acc local val)
(catch :found
(unless with-self (setq node (org-element-property :parent node)))
(unless with-self (setq node (org-element-parent node)))
(while node
(setq local nil)
(dolist (prop property)
@ -1125,7 +1132,7 @@ skipped."
(setq local (append local (ensure-list val))))))
;; Append parent to front.
(setq acc (append local acc))
(setq node (org-element-property :parent node)))
(setq node (org-element-parent node)))
acc)))
(provide 'org-element-ast)

View File

@ -523,7 +523,7 @@ Class is either `element' or `object'. Optional argument PARENT
is the element or object containing DATUM. It defaults to the
value of DATUM `:parent' property."
(let ((type (org-element-type datum t))
(parent (or parent (org-element-property :parent datum))))
(parent (or parent (org-element-parent datum))))
(cond
;; Trivial cases.
((memq type org-element-all-objects) 'object)
@ -5737,7 +5737,7 @@ the cache."
(cond
((and limit
(not (org-element--cache-key-less-p
(org-element--cache-key element) limit)))
(org-element--cache-key element) limit)))
(setq node (avl-tree--node-left node)))
((> begin pos)
(setq upper element
@ -5761,7 +5761,7 @@ the cache."
(setq lower element)
(setq node (avl-tree--node-right node)))
((and (org-element-type-p element '(item table-row))
(let ((parent (org-element-property :parent element)))
(let ((parent (org-element-parent element)))
(and (= (org-element-property :begin element)
(org-element-property :contents-begin parent))
(setq node nil
@ -5816,9 +5816,9 @@ Assume ELEMENT belongs to cache and that a cache is active."
(org-element-put-property element :cached nil)
(cl-decf org-element--cache-size)
;; Invalidate contents of parent.
(when (and (org-element-property :parent element)
(org-element-contents (org-element-property :parent element)))
(org-element-set-contents (org-element-property :parent element) nil))
(when (and (org-element-parent element)
(org-element-contents (org-element-parent element)))
(org-element-set-contents (org-element-parent element) nil))
(when (org-element-type-p element '(headline inlinetask))
(cl-decf org-element--headline-cache-size)
(avl-tree-delete org-element--headline-cache element))
@ -5885,7 +5885,7 @@ Properties are modified by side-effect."
;; shifting it more than once.
(when (and (or (not props) (memq :structure props))
(org-element-type-p element 'plain-list)
(not (org-element-type-p (org-element-property :parent element) 'item)))
(not (org-element-type-p (org-element-parent element) 'item)))
(let ((structure (org-element-property :structure element)))
(dolist (item structure)
(cl-incf (car item) offset)
@ -6221,7 +6221,7 @@ completing the request."
(org-element-property :robust-end up))
'(:contents-end :end :robust-end)
'(:contents-end :end))))
(setq up (org-element-property :parent up)))))
(setq up (org-element-parent up)))))
(org-element--cache-log-message
"New parent at %S: %S::%S"
limit
@ -6297,7 +6297,7 @@ completing the request."
;; necessary. Propagate new structures for lists.
(while (and parent
(<= (org-element-property :end parent) begin))
(setq parent (org-element-property :parent parent)))
(setq parent (org-element-parent parent)))
(cond ((and (not parent) (zerop offset)) (throw 'org-element--cache-quit nil))
;; Consider scenario when DATA lays within
;; sensitive lines of PARENT that was found
@ -6338,7 +6338,7 @@ completing the request."
continue-flag t))
((and parent
(not (eq parent data))
(let ((p (org-element-property :parent data)))
(let ((p (org-element-parent data)))
(or (not p)
(< (org-element-property :begin p)
(org-element-property :begin parent))
@ -6349,7 +6349,7 @@ completing the request."
(org-element--cache-log-message
"Updating parent in %S\n Old parent: %S\n New parent: %S"
(org-element--format-element data)
(org-element--format-element (org-element-property :parent data))
(org-element--format-element (org-element-parent data))
(org-element--format-element parent))
(when (and (org-element-type-p parent 'org-data)
(not (org-element-type-p data 'headline)))
@ -6481,12 +6481,12 @@ the expected result."
(setq next (org-element-property :end up)
element up
mode (org-element--next-mode (org-element-property :mode element) (org-element-type element) nil)
up (org-element-property :parent up)))
up (org-element-parent up)))
(when next (goto-char next))
(when up (setq element up)))))
;; Parse successively each element until we reach POS.
(let ((end (or (org-element-property :end element) (point-max)))
(parent (org-element-property :parent element)))
(parent (org-element-parent element)))
(while t
(when (org-element--cache-interrupt-p time-limit)
(throw 'org-element--cache-interrupt nil))
@ -6912,12 +6912,12 @@ known element in cache (it may start after END)."
(org-element--format-element up))
(setq before up)
(when robust-flag (setq robust-flag nil))))
(unless (or (org-element-property :parent up)
(unless (or (org-element-parent up)
(org-element-type-p up 'org-data))
(org-element--cache-warn "Got element without parent. Please report it to Org mode mailing list (M-x org-submit-bug-report).\n%S" up)
(org-element-cache-reset)
(error "org-element--cache: Emergency exit"))
(setq up (org-element-property :parent up)))
(setq up (org-element-parent up)))
;; We're at top level element containing ELEMENT: if it's
;; altered by buffer modifications, it is first element in
;; cache to be removed. Otherwise, that first element is the
@ -6988,7 +6988,7 @@ change, as an integer."
(max (org-element-property :end first)
(org-element--request-end next)))
(setf (org-element--request-parent next)
(org-element-property :parent first))))
(org-element-parent first))))
;; The current and NEXT modifications are intersecting
;; with current modification starting before NEXT and NEXT
;; ending after current. We need to update the common
@ -7010,7 +7010,7 @@ change, as an integer."
(setf (org-element--request-end next)
(max (org-element-property :end first)
(org-element--request-end next)))
(setf (org-element--request-parent next) (org-element-property :parent first))))))
(setf (org-element--request-parent next) (org-element-parent first))))))
;; Ensure cache is correct up to END. Also make sure that NEXT,
;; if any, is no longer a 0-phase request, thus ensuring that
;; phases are properly ordered. We need to provide OFFSET as
@ -7040,7 +7040,7 @@ change, as an integer."
((let ((first-end (org-element-property :end first)))
(when (> first-end end)
(org-element--cache-log-message "Extending to non-robust element %S" (org-element--format-element first))
(vector key first-beg first-end offset (org-element-property :parent first) 0))))
(vector key first-beg first-end offset (org-element-parent first) 0))))
(t
;; Now, FIRST is the first element after BEG or
;; non-robust element containing BEG. However,
@ -7054,7 +7054,7 @@ change, as an integer."
(element-end (org-element-property :end element))
(up element))
(while (and (not (eq up first))
(setq up (org-element-property :parent up))
(setq up (org-element-parent up))
(>= (org-element-property :begin up) first-beg))
;; Note that UP might have been already
;; shifted if it is a robust element. After
@ -7102,7 +7102,7 @@ Return non-nil when verification failed."
org-element--cache-self-verify-frequency)))
;; Verify correct parent for the element.
(unless (or (not org-element--cache-self-verify)
(org-element-property :parent element)
(org-element-parent element)
(org-element-type-p element 'org-data))
(org-element--cache-warn "Got element without parent (cache active?: %S). Please report it to Org mode mailing list (M-x org-submit-bug-report).\n%S" (org-element--cache-active-p) element)
(org-element-cache-reset))
@ -7113,7 +7113,7 @@ Return non-nil when verification failed."
(< (random 1000) (* 1000 org-element--cache-self-verify-frequency)))
(org-with-point-at (org-element-property :begin element)
(org-element-with-disabled-cache (org-up-heading-or-point-min))
(unless (or (= (point) (org-element-property :begin (org-element-property :parent element)))
(unless (or (= (point) (org-element-property :begin (org-element-parent element)))
(eq (point) (point-min)))
(org-element--cache-warn
"Cached element has wrong parent in %s. Resetting.
@ -7121,10 +7121,10 @@ If this warning appears regularly, please report the warning text to Org mode ma
The element is: %S\n The parent is: %S\n The real parent is: %S"
(buffer-name (current-buffer))
(org-element--format-element element)
(org-element--format-element (org-element-property :parent element))
(org-element--format-element (org-element--current-element (org-element-property :end (org-element-property :parent element)))))
(org-element--format-element (org-element-parent element))
(org-element--format-element (org-element--current-element (org-element-property :end (org-element-parent element)))))
(org-element-cache-reset))
(org-element--cache-verify-element (org-element-property :parent element))))
(org-element--cache-verify-element (org-element-parent element))))
;; Verify the element itself.
(when (and org-element--cache-self-verify
(org-element--cache-active-p)
@ -7150,7 +7150,7 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
this-command
(buffer-name (current-buffer))
(if (/= org-element--cache-change-tic
(buffer-chars-modified-tick))
(buffer-chars-modified-tick))
"no" "yes")
(org-element--format-element element)
(org-element--format-element real-element)
@ -7428,7 +7428,7 @@ the cache."
(progn
(setq tmpelement (org-element--parse-to (point)))
(while (and tmpelement (not (org-element-type-p tmpelement restrict-elements)))
(setq tmpelement (org-element-property :parent tmpelement)))
(setq tmpelement (org-element-parent tmpelement)))
tmpelement)
(org-element--parse-to (point)))))
;; Starting from (point), search RE and move START to
@ -7480,7 +7480,7 @@ the cache."
(catch :exit
(when (eq tmpnext-start (org-element-property :contents-end tmpparent))
(setq tmpnext-start (org-element-property :end tmpparent)))
(while (setq tmpparent (org-element-property :parent tmpparent))
(while (setq tmpparent (org-element-parent tmpparent))
(if (eq tmpnext-start (org-element-property :contents-end tmpparent))
(setq tmpnext-start (org-element-property :end tmpparent))
(throw :exit t))))
@ -7609,8 +7609,8 @@ the cache."
;; and need to fill it.
(unless (or (and start (< (org-element-property :begin data) start))
(and prev (not (org-element--cache-key-less-p
(org-element--cache-key prev)
(org-element--cache-key data)))))
(org-element--cache-key prev)
(org-element--cache-key data)))))
;; DATA is at of after START and PREV.
(if (or (not start) (= (org-element-property :begin data) start))
;; DATA is at START. Match it.

View File

@ -604,7 +604,7 @@ Use :header-args: instead"
(before
(mapcar #'org-element-type
(assq d (reverse (org-element-contents
(org-element-property :parent d)))))))
(org-element-parent d)))))))
(list (org-element-property :post-affiliated d)
(if (or (and headline? (member before '(nil (planning))))
(and (null headline?) (member before '(nil (comment)))))
@ -1318,7 +1318,7 @@ Use \"export %s\" instead"
;; of the paragraph containing the faulty object. It is
;; not very accurate but may be enough for now.
(list (org-element-property :contents-begin
(org-element-property :parent text))
(org-element-parent text))
"Possibly incomplete citation markup")))))
(defun org-lint-item-number (ast)

View File

@ -3548,7 +3548,7 @@ PARAMS is a plist used to tweak the behavior of the transcoder."
(ddend (plist-get params :ddend)))
(lambda (item contents info)
(let* ((type
(org-element-property :type (org-element-property :parent item)))
(org-element-property :type (org-element-parent item)))
(tag (org-element-property :tag item))
(depth (org-list--depth item))
(separator (and (org-export-get-next-element item info)

View File

@ -545,9 +545,9 @@ Leave point in edit buffer."
(cond
((save-excursion (skip-chars-backward " \t") (bolp))
(org-current-text-indentation))
((org-element-property :parent datum)
((org-element-parent datum)
(org--get-expected-indentation
(org-element-property :parent datum) nil))
(org-element-parent datum) nil))
(t (org-current-text-indentation)))))
(content-ind org-edit-src-content-indentation)
(blank-line (save-excursion (beginning-of-line)

View File

@ -12267,7 +12267,7 @@ Inherited tags have the `inherited' text property."
(not local))
org-scanner-tags
(org-with-point-at (unless (org-element-type pos-or-element)
(or pos-or-element (point)))
(or pos-or-element (point)))
(unless (or (org-element-type pos-or-element)
(org-before-first-heading-p))
(org-back-to-heading t))
@ -12281,7 +12281,7 @@ Inherited tags have the `inherited' text property."
(org-element-lineage pos-or-element '(headline org-data inlinetask) t)
(org-element-at-point nil 'cached)))))
(if cached
(while (setq cached (org-element-property :parent cached))
(while (setq cached (org-element-parent cached))
(setq itags (nconc (mapcar #'org-add-prop-inherited
;; If we do explicitly copy the result, reference would
;; be returned and cache element might be modified directly.
@ -13019,8 +13019,8 @@ However, if LITERAL-NIL is set, return the string value \"nil\" instead."
((car v)
(move-marker org-entry-property-inherited-from (org-element-property :begin element))
(throw 'exit nil))
((org-element-property :parent element)
(setq element (org-element-property :parent element)))
((org-element-parent element)
(setq element (org-element-parent element)))
(t
(let ((global (org--property-global-or-keyword-value property literal-nil)))
(cond ((not global))
@ -17641,7 +17641,7 @@ This command does many different things, depending on context:
;; For convenience: at the first line of a paragraph on the same
;; line as an item, apply function on that item instead.
(when (eq type 'paragraph)
(let ((parent (org-element-property :parent context)))
(let ((parent (org-element-parent context)))
(when (and (org-element-type-p parent 'item)
(= (line-beginning-position)
(org-element-property :begin parent)))
@ -18990,8 +18990,8 @@ Optional argument ELEMENT contains element at BEG."
(not (org-element-lineage element '(headline inlinetask))))
nil ; Not inside heading.
;; Skip to top-level parent in section.
(while (not (org-element-type-p (org-element-property :parent element) 'section))
(setq element (org-element-property :parent element)))
(while (not (org-element-type-p (org-element-parent element) 'section))
(setq element (org-element-parent element)))
(pcase (org-element-type element)
((or `planning `property-drawer)
t)
@ -19022,7 +19022,7 @@ ELEMENT."
((diary-sexp footnote-definition) 0)
(section
(org--get-expected-indentation
(org-element-property :parent element)
(org-element-parent element)
t))
((headline inlinetask nil)
(if (not org-adapt-indentation) 0
@ -19041,7 +19041,7 @@ ELEMENT."
;; Indent like parent.
((< (line-beginning-position) start)
(org--get-expected-indentation
(org-element-property :parent element) t))
(org-element-parent element) t))
;; At first line: indent according to previous sibling, if any,
;; ignoring footnote definitions and inline tasks, or parent's
;; contents. If `org-adapt-indentation' is `headline-data', ignore
@ -19055,7 +19055,7 @@ ELEMENT."
(parent previous))
(while (and parent (<= (org-element-property :end parent) start))
(setq previous parent
parent (org-element-property :parent parent)))
parent (org-element-parent parent)))
(cond
((not previous) (throw 'exit 0))
((> (org-element-property :end previous) start)
@ -19077,7 +19077,7 @@ ELEMENT."
;; At first paragraph in an item or
;; a footnote definition.
(org--get-expected-indentation
(org-element-property :parent previous) t))))))))))
(org-element-parent previous) t))))))))))
;; Otherwise, move to the first non-blank line above.
(t
(beginning-of-line)
@ -19098,7 +19098,7 @@ ELEMENT."
;; like parent.
((< (line-beginning-position) start)
(org--get-expected-indentation
(org-element-property :parent element) t))
(org-element-parent element) t))
;; Line above is the beginning of an element, i.e., point
;; was originally on the blank lines between element's start
;; and contents.
@ -19485,7 +19485,7 @@ matches in paragraphs or comments, use it."
(paragraph
;; Fill prefix is usually the same as the current line,
;; unless the paragraph is at the beginning of an item.
(let ((parent (org-element-property :parent element)))
(let ((parent (org-element-parent element)))
(save-excursion
(beginning-of-line)
(cond ((org-element-type-p parent 'item)
@ -20604,7 +20604,7 @@ Optional argument ELEMENT contains element at point."
(while el
(when (org-element-property :commentedp el)
(throw :found t))
(setq el (org-element-property :parent el))))))))
(setq el (org-element-parent el))))))))
(defun org-in-archived-heading-p (&optional no-inheritance element)
"Non-nil if point is under an archived heading.
@ -20627,7 +20627,7 @@ Optional argument ELEMENT contains element at point."
(while element
(when (org-element-property :archivedp element)
(throw :archived t))
(setq element (org-element-property :parent element))))
(setq element (org-element-parent element))))
(save-excursion (and (org-up-heading-safe) (org-in-archived-heading-p)))))))
(defun org-at-comment-p nil
@ -21064,12 +21064,12 @@ Function may return a real element, or a pseudo-element with type
((memq type '(table property-drawer))
(list (org-element-property :begin e)
(org-element-property :end e)
(org-element-property :parent e)))
(org-element-parent e)))
((memq type '(node-property table-row))
(let ((e (org-element-property :parent e)))
(let ((e (org-element-parent e)))
(list (org-element-property :begin e)
(org-element-property :end e)
(org-element-property :parent e))))
(org-element-parent e))))
((memq type '(clock diary-sexp keyword))
(let* ((regexp (pcase type
(`clock org-clock-line-re)
@ -21089,14 +21089,14 @@ Function may return a real element, or a pseudo-element with type
(if (looking-at regexp)
(point)
(line-beginning-position 2)))))
(list begin end (org-element-property :parent e))))
(list begin end (org-element-parent e))))
;; Find the full plain list containing point, the check it
;; contains exactly one line per item.
((let ((l (org-element-lineage e '(plain-list) t)))
(while (org-element-type-p
(org-element-property :parent l)
(org-element-parent l)
'(item plain-list))
(setq l (org-element-property :parent l)))
(setq l (org-element-parent l)))
(and l org--single-lines-list-is-paragraph
(org-with-point-at (org-element-property :post-affiliated l)
(forward-line (length (org-element-property :structure l)))
@ -21104,7 +21104,7 @@ Function may return a real element, or a pseudo-element with type
;; Return value.
(list (org-element-property :begin l)
(org-element-property :end l)
(org-element-property :parent l)))))
(org-element-parent l)))))
(t nil)))) ;no triplet: return element
(pcase triplet
(`(,b ,e ,p)
@ -21207,7 +21207,7 @@ See `org-backward-paragraph'."
(post-affiliated (org-element-property :post-affiliated element))
(contents-end (org-element-property :contents-end element))
(end (org-element-property :end element))
(parent (org-element-property :parent element))
(parent (org-element-parent element))
(reach
;; Move to the visible empty line above position P, or
;; to position P. Return t.
@ -21293,7 +21293,7 @@ Move to the next element at the same level, when possible."
(t
(let* ((elem (org-element-at-point))
(end (org-element-property :end elem))
(parent (org-element-property :parent elem)))
(parent (org-element-parent elem)))
(cond ((and parent (= (org-element-property :contents-end parent) end))
(goto-char (org-element-property :end parent)))
((integer-or-marker-p end) (goto-char end))
@ -21328,7 +21328,7 @@ Move to the previous element at the same level, when possible."
(unless (bobp)
(let ((prev (org-element-at-point)))
(goto-char (org-element-property :begin prev))
(while (and (setq prev (org-element-property :parent prev))
(while (and (setq prev (org-element-parent prev))
(<= (org-element-property :end prev) beg))
(goto-char (org-element-property :begin prev)))))))))))
@ -21338,10 +21338,10 @@ Move to the previous element at the same level, when possible."
(if (org-with-limited-levels (org-at-heading-p))
(unless (org-up-heading-safe) (user-error "No surrounding element"))
(let* ((elem (org-element-at-point))
(parent (org-element-property :parent elem)))
(parent (org-element-parent elem)))
;; Skip sections
(when (org-element-type-p parent 'section)
(setq parent (org-element-property :parent parent)))
(setq parent (org-element-parent parent)))
(if (and parent
(not (org-element-type-p parent 'org-data)))
(goto-char (org-element-property :begin parent))
@ -21383,7 +21383,7 @@ Move to the previous element at the same level, when possible."
(let* ((beg (org-element-property :begin elem))
(prev (org-element-at-point))
(up prev))
(while (and (setq up (org-element-property :parent up))
(while (and (setq up (org-element-parent up))
(<= (org-element-property :end up) beg))
(setq prev up))
prev)))))

View File

@ -607,7 +607,7 @@ INFO is a plist used as a communication channel."
(lambda (e)
(and (org-element-type-p e 'plain-list)
(not (org-element-type-p
(org-export-get-parent e) 'item))))
(org-element-parent e) 'item))))
genealogy)
(plist-get info :ascii-list-margin))
;; Compute indentation offset due to current list. It is
@ -617,7 +617,7 @@ INFO is a plist used as a communication channel."
(dolist (e genealogy)
(cond
((not (org-element-type-p e 'item)))
((eq (org-element-property :type (org-export-get-parent e))
((eq (org-element-property :type (org-element-parent e))
'descriptive)
(cl-incf indentation org-ascii-quote-margin))
(t
@ -1465,7 +1465,7 @@ CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
(checkbox (org-ascii--checkbox item info))
(list-type (org-element-property :type (org-export-get-parent item)))
(list-type (org-element-property :type (org-element-parent item)))
(bullet
;; First parent of ITEM is always the plain-list. Get
;; `:type' property from it.
@ -1659,7 +1659,7 @@ the plist used as a communication channel."
;; Do not indent first paragraph in a section.
(unless (and (not (org-export-get-previous-element paragraph info))
(org-element-type-p
(org-export-get-parent paragraph) 'section))
(org-element-parent paragraph) 'section))
(make-string indented-line-width ?\s))
(replace-regexp-in-string "\\`[ \t]+" "" contents))))
paragraph info))
@ -1673,7 +1673,7 @@ CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
(let ((margin (plist-get info :ascii-list-margin)))
(if (or (< margin 1)
(org-element-type-p (org-export-get-parent plain-list) 'item))
(org-element-type-p (org-element-parent plain-list) 'item))
contents
(org-ascii--indent-string contents margin))))
@ -1887,8 +1887,8 @@ column.
When `org-ascii-table-widen-columns' is non-nil, width cookies
are ignored."
(let* ((row (org-export-get-parent table-cell))
(table (org-export-get-parent row))
(let* ((row (org-element-parent table-cell))
(table (org-element-parent row))
(col (let ((cells (org-element-contents row)))
(- (length cells) (length (memq table-cell cells)))))
(cache

View File

@ -2942,7 +2942,7 @@ INFO is a plist holding contextual information. See
"Transcode an ITEM element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((plain-list (org-export-get-parent item))
(let* ((plain-list (org-element-parent item))
(type (org-element-property :type plain-list))
(counter (org-element-property :counter item))
(checkbox (org-element-property :checkbox item))
@ -3169,7 +3169,7 @@ images, set it to:
(lambda (paragraph) (org-element-property :caption paragraph))"
(let ((paragraph (pcase (org-element-type element)
(`paragraph element)
(`link (org-export-get-parent element)))))
(`link (org-element-parent element)))))
(and (org-element-type-p paragraph 'paragraph)
(or (not (and (boundp 'org-html-standalone-image-predicate)
(fboundp org-html-standalone-image-predicate)))
@ -3248,7 +3248,7 @@ INFO is a plist holding contextual information. See
;; for inline images). This is needed as long as
;; attributes cannot be set on a per link basis.
(let* ((parent (org-export-get-parent-element link))
(link (let ((container (org-export-get-parent link)))
(link (let ((container (org-element-parent link)))
(if (and (org-element-type-p container 'link)
(org-html-inline-image-p link info))
container
@ -3396,7 +3396,7 @@ information."
"Transcode a PARAGRAPH element from Org to HTML.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
(let* ((parent (org-export-get-parent paragraph))
(let* ((parent (org-element-parent paragraph))
(parent-type (org-element-type parent))
(style '((footnote-definition " class=\"footpara\"")
(org-data " class=\"footpara\"")))
@ -3691,7 +3691,7 @@ contextual information."
"Transcode a TABLE-CELL element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(let* ((table-row (org-export-get-parent table-cell))
(let* ((table-row (org-element-parent table-cell))
(table (org-export-get-parent-table table-cell))
(cell-attrs
(if (not (plist-get info :html-table-align-individual-fields)) ""

View File

@ -2521,14 +2521,14 @@ contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((orderedp (eq (org-element-property
:type (org-export-get-parent item))
:type (org-element-parent item))
'ordered))
(level
;; Determine level of current item to determine the
;; correct LaTeX counter to use (enumi, enumii...).
(let ((parent item) (level 0))
(while (org-element-type-p
(setq parent (org-export-get-parent parent))
(setq parent (org-element-parent parent))
'(plain-list item))
(when (and (org-element-type-p parent 'plain-list)
(eq (org-element-property :type parent)
@ -2739,7 +2739,7 @@ used as a communication channel."
(center
(cond
;; If link is an image link, do not center.
((org-element-type-p (org-export-get-parent link) 'link) nil)
((org-element-type-p (org-element-parent link) 'link) nil)
((plist-member attr :center) (plist-get attr :center))
(t (plist-get info :latex-images-centered))))
(comment-include (if (plist-get attr :comment-include) "%" ""))
@ -3119,7 +3119,7 @@ it."
(when (and (member mode '("inline-math" "math"))
;; Do not wrap twice the same table.
(not (org-element-type-p
(org-element-property :parent table) 'latex-matrices)))
(org-element-parent table) 'latex-matrices)))
(let* ((caption (and (not (string= mode "inline-math"))
(org-element-property :caption table)))
(name (and (not (string= mode "inline-math"))
@ -3206,8 +3206,7 @@ containing export options. Modify DATA by side-effect and return it."
(lambda (object)
;; Skip objects already wrapped.
(when (and (not (org-element-type-p
(org-element-property :parent object)
'latex-math-block))
(org-element-parent object) 'latex-math-block))
(funcall valid-object-p object))
(let ((math-block (list 'latex-math-block nil))
(next-elements (org-export-get-next-element object info t))
@ -4007,7 +4006,7 @@ a communication channel."
CONTENTS is the contents of the row. INFO is a plist used as
a communication channel."
(let* ((attr (org-export-read-attribute :attr_latex
(org-export-get-parent table-row)))
(org-element-parent table-row)))
(booktabsp (if (plist-member attr :booktabs) (plist-get attr :booktabs)
(plist-get info :latex-tables-booktabs)))
(longtablep

View File

@ -554,7 +554,7 @@ contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((bullet (org-element-property :bullet item))
(type (org-element-property :type (org-element-property :parent item)))
(type (org-element-property :type (org-element-parent item)))
(checkbox (pcase (org-element-property :checkbox item)
(`on "\\o'\\(sq\\(mu'")
(`off "\\(sq ")
@ -645,7 +645,7 @@ information."
"Transcode a PARAGRAPH element from Org to Man.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
(let ((parent (org-element-property :parent paragraph)))
(let ((parent (org-element-parent paragraph)))
(when parent
(let ((parent-type (org-element-type parent))
(fixed-paragraph ""))

View File

@ -167,7 +167,7 @@ Assume BACKEND is `md'."
(org-element-put-property
e :post-blank
(if (and (org-element-type-p e 'paragraph)
(org-element-type-p (org-element-property :parent e) 'item)
(org-element-type-p (org-element-parent e) 'item)
(org-export-first-sibling-p e info)
(let ((next (org-export-get-next-element e info)))
(and (org-element-type-p next 'plain-list)
@ -437,7 +437,7 @@ as a communication channel."
"Transcode ITEM element into Markdown format.
CONTENTS is the item contents. INFO is a plist used as
a communication channel."
(let* ((type (org-element-property :type (org-export-get-parent item)))
(let* ((type (org-element-property :type (org-element-parent item)))
(struct (org-element-property :structure item))
(bullet (if (not (eq type 'ordered)) "-"
(concat (number-to-string

View File

@ -1937,7 +1937,7 @@ contextual information."
"Transcode an ITEM element from Org to ODT.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((plain-list (org-export-get-parent item))
(let* ((plain-list (org-element-parent item))
(count (org-element-property :counter item))
(type (org-element-property :type plain-list)))
(unless (memq type '(ordered unordered descriptive-1 descriptive-2))
@ -2555,7 +2555,7 @@ Return nil, otherwise."
(paragraph element)
(link (and (or (not link-predicate)
(funcall link-predicate element))
(org-export-get-parent element)))
(org-element-parent element)))
(t nil))))
(when (and p (org-element-type-p p 'paragraph))
(when (or (not paragraph-predicate)
@ -2838,7 +2838,7 @@ no special environment, a center block, or a quote block."
;; If PARAGRAPH is a leading paragraph in an item that has
;; a checkbox, splice checkbox and paragraph contents
;; together.
(concat (let ((parent (org-element-property :parent paragraph)))
(concat (let ((parent (org-element-parent paragraph)))
(and (org-element-type-p parent 'item)
(not (org-export-get-previous-element paragraph info))
(org-odt--checkbox parent)))
@ -2871,7 +2871,7 @@ contextual information."
;; If top-level list, re-start numbering. Otherwise,
;; continue numbering.
(format "text:continue-numbering=\"%s\""
(let* ((parent (org-export-get-parent plain-list)))
(let* ((parent (org-element-parent plain-list)))
(if (and parent (org-element-type-p parent 'item))
"true" "false")))
contents))
@ -3303,7 +3303,7 @@ channel."
(r (car table-cell-address))
(c (cdr table-cell-address))
(horiz-span (or (org-export-table-cell-width table-cell info) 0))
(table-row (org-export-get-parent table-cell))
(table-row (org-element-parent table-cell))
(custom-style-prefix (org-odt-get-table-cell-styles
table-cell info))
(paragraph-style
@ -3487,7 +3487,7 @@ pertaining to indentation here."
(list el
(assq 'headline
(org-element-contents
(org-export-get-parent el)))))))
(org-element-parent el)))))))
parent-list)
(nconc
;; Handle list genealogy.

View File

@ -1177,11 +1177,11 @@ contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((tag (org-element-property :tag item))
(plain-list (org-element-property :parent item))
(plain-list (org-element-parent item))
(compact (and (eq (org-element-property :type plain-list) 'descriptive)
(or (plist-get info :texinfo-compact-itemx)
(org-not-nil (org-export-read-attribute
:attr_texinfo plain-list :compact)))))
:attr_texinfo plain-list :compact)))))
(previous-item nil))
(when (and compact
(org-export-get-next-element item info)
@ -1350,7 +1350,7 @@ INFO is a plist holding contextual information. See
(and `target
(guard
(org-element-type-p
(org-element-property :parent destination)
(org-element-parent destination)
'headline))))
(let ((headline (org-element-lineage destination '(headline) t)))
(org-texinfo--@ref headline desc info)))

View File

@ -1633,14 +1633,6 @@ an alist where associations are (VARIABLE-NAME VALUE)."
(mapcar (lambda (v) (read (format "(%s)" v)))
values)))))
;; defsubst org-export-get-parent must be defined before first use,
;; was originally defined in the topology section
(defsubst org-export-get-parent (blob)
"Return BLOB parent or nil.
BLOB is the element or object considered."
(org-element-property :parent blob))
;;;; Tree Properties
;;
;; Tree properties are information extracted from parse tree. They
@ -1925,7 +1917,7 @@ Return a string."
(format "[BROKEN LINK: %s]" (nth 1 err)) info))
(_ nil))))))
(let* ((type (org-element-type data))
(parent (org-export-get-parent data))
(parent (org-element-parent data))
(results
(cond
;; Ignored element/object.
@ -5181,7 +5173,7 @@ All special rows will be ignored during export."
;; ... the table contains a special column and the row start
;; with a marking character among, "^", "_", "$" or "!",
(and (org-export-table-has-special-column-p
(org-export-get-parent table-row))
(org-element-parent table-row))
(member first-cell '(("^") ("_") ("$") ("!"))))
;; ... it contains only alignment cookies and empty cells.
(let ((special-row-p 'empty))
@ -5217,7 +5209,7 @@ header."
;; First time a row is queried, populate cache with all the
;; rows from the table.
(let ((group 0) row-flag)
(org-element-map (org-export-get-parent table-row) 'table-row
(org-element-map (org-element-parent table-row) 'table-row
(lambda (row)
(if (eq (org-element-property :type row) 'rule)
(setq row-flag nil)
@ -5233,8 +5225,8 @@ INFO is a plist used as the communication channel.
Return value is the width given by the last width cookie in the
same column as TABLE-CELL, or nil."
(let* ((row (org-export-get-parent table-cell))
(table (org-export-get-parent row))
(let* ((row (org-element-parent table-cell))
(table (org-element-parent row))
(cells (org-element-contents row))
(columns (length cells))
(column (- columns (length (memq table-cell cells))))
@ -5282,8 +5274,8 @@ column (see `org-table-number-fraction' for more information).
Possible values are `left', `right' and `center'."
;; Load `org-table-number-fraction' and `org-table-number-regexp'.
(require 'org-table)
(let* ((row (org-export-get-parent table-cell))
(table (org-export-get-parent row))
(let* ((row (org-element-parent table-cell))
(table (org-element-parent row))
(cells (org-element-contents row))
(columns (length cells))
(column (- columns (length (memq table-cell cells))))
@ -5307,7 +5299,7 @@ Possible values are `left', `right' and `center'."
(total-cells 0)
cookie-align
previous-cell-number-p)
(dolist (row (org-element-contents (org-export-get-parent row)))
(dolist (row (org-element-contents (org-element-parent row)))
(cond
;; In a special row, try to find an alignment cookie at
;; COLUMN.
@ -5366,7 +5358,7 @@ Return value is a list of symbols, or nil. Possible values are:
row (resp. last row) of the table, ignoring table rules, if any.
Returned borders ignore special rows."
(let* ((row (org-export-get-parent table-cell))
(let* ((row (org-element-parent table-cell))
(table (org-export-get-parent-table table-cell))
borders)
;; Top/above border? TABLE-CELL has a border above when a rule
@ -5446,7 +5438,7 @@ INFO is a plist used as a communication channel."
;; A cell starts a column group either when it is at the beginning
;; of a row (or after the special column, if any) or when it has
;; a left border.
(or (eq (org-element-map (org-export-get-parent table-cell) 'table-cell
(or (eq (org-element-map (org-element-parent table-cell) 'table-cell
'identity info 'first-match)
table-cell)
(memq 'left (org-export-table-cell-borders table-cell info))))
@ -5457,7 +5449,7 @@ INFO is a plist used as a communication channel."
;; A cell ends a column group either when it is at the end of a row
;; or when it has a right border.
(or (eq (car (last (org-element-contents
(org-export-get-parent table-cell))))
(org-element-parent table-cell))))
table-cell)
(memq 'right (org-export-table-cell-borders table-cell info))))
@ -5551,7 +5543,7 @@ a communication channel.
Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
zero-based index. Only exportable cells are considered. The
function returns nil for other cells."
(let* ((table-row (org-export-get-parent table-cell))
(let* ((table-row (org-element-parent table-cell))
(row-number (org-export-table-row-number table-row info)))
(when row-number
(cons row-number
@ -5932,7 +5924,7 @@ If no translation is found, the quote character is left as-is.")
(defun org-export--smart-quote-status (s info)
"Return smart quote status at the beginning of string S.
INFO is the current export state, as a plist."
(let* ((parent (org-element-property :parent s))
(let* ((parent (org-element-parent s))
(cache (or (plist-get info :smart-quote-cache)
(let ((table (make-hash-table :test #'eq)))
(plist-put info :smart-quote-cache table)
@ -6038,14 +6030,11 @@ Return the new string."
;;
;; Here are various functions to retrieve information about the
;; neighborhood of a given element or object. Neighbors of interest
;; are direct parent (`org-export-get-parent'), parent headline
;; (`org-export-get-parent-headline'), first element containing an
;; object, (`org-export-get-parent-element'), parent table
;; (`org-export-get-parent-table'), previous element or object
;; (`org-export-get-previous-element') and next element or object
;; (`org-export-get-next-element').
;; defsubst org-export-get-parent must be defined before first use
;; are parent headline (`org-export-get-parent-headline'), first
;; element containing an object, (`org-export-get-parent-element'),
;; parent table (`org-export-get-parent-table'), previous element or
;; object (`org-export-get-previous-element') and next element or
;; object (`org-export-get-next-element').
(defun org-export-get-parent-headline (blob)
"Return BLOB parent headline or nil.
@ -6074,7 +6063,7 @@ containing up to N siblings before BLOB, from farthest to
closest. With any other non-nil value, return a list containing
all of them."
(let* ((secondary (org-element-secondary-p blob))
(parent (org-export-get-parent blob))
(parent (org-element-parent blob))
(siblings
(if secondary (org-element-property secondary parent)
(org-element-contents parent)))
@ -6099,7 +6088,7 @@ containing up to N siblings after BLOB, from closest to farthest.
With any other non-nil value, return a list containing all of
them."
(let* ((secondary (org-element-secondary-p blob))
(parent (org-export-get-parent blob))
(parent (org-element-parent blob))
(siblings
(cdr (memq blob
(if secondary (org-element-property secondary parent)