forked from mirrors/org-mode
ox: Deprecate `org-export-get-genealogy' for `org-element-lineage'
* lisp/ox.el (org-export-collect-tree-properties, org-export-numbered-headline-p, org-export-get-tags, org-export-resolve-fuzzy-link, org-export-get-ordinal, org-export-get-parent-headline, org-export-get-parent-element, org-export-get-parent-table): * lisp/ox-ascii.el (org-ascii--current-text-width): * lisp/ox-beamer.el (org-beamer--frame-level): * lisp/ox-icalendar.el (org-icalendar-blocked-headline-p): * lisp/ox-latex.el (org-latex-footnote-reference): * lisp/ox-odt.el (org-odt--enumerate, org-odt-link--infer-description, org-odt-table): Use `org-element-lineage' instead of `org-export-get-genealogy'.
This commit is contained in:
parent
182d61fc8f
commit
61ba40c371
|
@ -562,7 +562,7 @@ INFO is a plist used as a communication channel."
|
||||||
;; Elements with a relative width: store maximum text width in
|
;; Elements with a relative width: store maximum text width in
|
||||||
;; TOTAL-WIDTH.
|
;; TOTAL-WIDTH.
|
||||||
(otherwise
|
(otherwise
|
||||||
(let* ((genealogy (cons element (org-export-get-genealogy element)))
|
(let* ((genealogy (org-element-lineage element nil t))
|
||||||
;; Total width is determined by the presence, or not, of an
|
;; Total width is determined by the presence, or not, of an
|
||||||
;; inline task among ELEMENT parents.
|
;; inline task among ELEMENT parents.
|
||||||
(total-width
|
(total-width
|
||||||
|
|
|
@ -337,12 +337,10 @@ INFO is a plist used as a communication channel."
|
||||||
;; 1. Look for "frame" environment in parents, starting from the
|
;; 1. Look for "frame" environment in parents, starting from the
|
||||||
;; farthest.
|
;; farthest.
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(mapc (lambda (parent)
|
(dolist (parent (nreverse (org-element-lineage headline)))
|
||||||
(let ((env (org-element-property :BEAMER_ENV parent)))
|
(let ((env (org-element-property :BEAMER_ENV parent)))
|
||||||
(when (and env (member-ignore-case env '("frame" "fullframe")))
|
(when (and env (member-ignore-case env '("frame" "fullframe")))
|
||||||
(throw 'exit (org-export-get-relative-level parent info)))))
|
(throw 'exit (org-export-get-relative-level parent info))))))
|
||||||
(nreverse (org-export-get-genealogy headline)))
|
|
||||||
nil)
|
|
||||||
;; 2. Look for "frame" environment in HEADLINE.
|
;; 2. Look for "frame" environment in HEADLINE.
|
||||||
(let ((env (org-element-property :BEAMER_ENV headline)))
|
(let ((env (org-element-property :BEAMER_ENV headline)))
|
||||||
(and env (member-ignore-case env '("frame" "fullframe"))
|
(and env (member-ignore-case env '("frame" "fullframe"))
|
||||||
|
|
|
@ -323,19 +323,17 @@ A headline is blocked when either
|
||||||
;; Check :ORDERED: node property.
|
;; Check :ORDERED: node property.
|
||||||
(catch 'blockedp
|
(catch 'blockedp
|
||||||
(let ((current headline))
|
(let ((current headline))
|
||||||
(mapc (lambda (parent)
|
(dolist (parent (org-element-lineage headline))
|
||||||
(cond
|
(cond
|
||||||
((not (org-element-property :todo-keyword parent))
|
((not (org-element-property :todo-keyword parent))
|
||||||
(throw 'blockedp nil))
|
(throw 'blockedp nil))
|
||||||
((org-not-nil (org-element-property :ORDERED parent))
|
((org-not-nil (org-element-property :ORDERED parent))
|
||||||
(let ((sibling current))
|
(let ((sibling current))
|
||||||
(while (setq sibling (org-export-get-previous-element
|
(while (setq sibling (org-export-get-previous-element
|
||||||
sibling info))
|
sibling info))
|
||||||
(when (eq (org-element-property :todo-type sibling) 'todo)
|
(when (eq (org-element-property :todo-type sibling) 'todo)
|
||||||
(throw 'blockedp t)))))
|
(throw 'blockedp t)))))
|
||||||
(t (setq current parent))))
|
(t (setq current parent))))))))
|
||||||
(org-export-get-genealogy headline))
|
|
||||||
nil))))
|
|
||||||
|
|
||||||
(defun org-icalendar-use-UTC-date-time-p ()
|
(defun org-icalendar-use-UTC-date-time-p ()
|
||||||
"Non-nil when `org-icalendar-date-time-format' requires UTC time."
|
"Non-nil when `org-icalendar-date-time-format' requires UTC time."
|
||||||
|
|
|
@ -1425,9 +1425,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(org-export-get-footnote-number footnote-reference info)))
|
(org-export-get-footnote-number footnote-reference info)))
|
||||||
;; Use \footnotemark if reference is within another footnote
|
;; Use \footnotemark if reference is within another footnote
|
||||||
;; reference, footnote definition or table cell.
|
;; reference, footnote definition or table cell.
|
||||||
((loop for parent in (org-export-get-genealogy footnote-reference)
|
((org-element-lineage footnote-reference
|
||||||
thereis (memq (org-element-type parent)
|
'(footnote-reference footnote-definition table-cell))
|
||||||
'(footnote-reference footnote-definition table-cell)))
|
|
||||||
"\\footnotemark")
|
"\\footnotemark")
|
||||||
;; Otherwise, define it with \footnote command.
|
;; Otherwise, define it with \footnote command.
|
||||||
(t
|
(t
|
||||||
|
|
|
@ -2087,7 +2087,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(let* ((--numbered-parent-headline-at-<=-n
|
(let* ((--numbered-parent-headline-at-<=-n
|
||||||
(function
|
(function
|
||||||
(lambda (element n info)
|
(lambda (element n info)
|
||||||
(loop for x in (org-export-get-genealogy element)
|
(loop for x in (org-element-lineage element)
|
||||||
thereis (and (eq (org-element-type x) 'headline)
|
thereis (and (eq (org-element-type x) 'headline)
|
||||||
(<= (org-export-get-relative-level x info) n)
|
(<= (org-export-get-relative-level x info) n)
|
||||||
(org-export-numbered-headline-p x info)
|
(org-export-numbered-headline-p x info)
|
||||||
|
@ -2639,7 +2639,7 @@ Return nil, otherwise."
|
||||||
|
|
||||||
;; NOTE: Counterpart of `org-export-get-ordinal'.
|
;; NOTE: Counterpart of `org-export-get-ordinal'.
|
||||||
;; FIXME: Handle footnote-definition footnote-reference?
|
;; FIXME: Handle footnote-definition footnote-reference?
|
||||||
(let* ((genealogy (org-export-get-genealogy destination))
|
(let* ((genealogy (org-element-lineage destination))
|
||||||
(data (reverse genealogy))
|
(data (reverse genealogy))
|
||||||
(label (case (org-element-type destination)
|
(label (case (org-element-type destination)
|
||||||
(headline (org-export-get-headline-id destination info))
|
(headline (org-export-get-headline-id destination info))
|
||||||
|
@ -2684,7 +2684,7 @@ Return nil, otherwise."
|
||||||
(format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>"
|
(format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>"
|
||||||
(org-export-solidify-link-text label)
|
(org-export-solidify-link-text label)
|
||||||
(mapconcat (lambda (n) (if (not n) " "
|
(mapconcat (lambda (n) (if (not n) " "
|
||||||
(concat (number-to-string n) ".")))
|
(concat (number-to-string n) ".")))
|
||||||
item-numbers "")))))
|
item-numbers "")))))
|
||||||
;; Case 2: Locate a regular and numbered headline in the
|
;; Case 2: Locate a regular and numbered headline in the
|
||||||
;; hierarchy. Display its section number.
|
;; hierarchy. Display its section number.
|
||||||
|
@ -3515,7 +3515,7 @@ pertaining to indentation here."
|
||||||
(--walk-list-genealogy-and-collect-tags
|
(--walk-list-genealogy-and-collect-tags
|
||||||
(function
|
(function
|
||||||
(lambda (table info)
|
(lambda (table info)
|
||||||
(let* ((genealogy (org-export-get-genealogy table))
|
(let* ((genealogy (org-element-lineage table))
|
||||||
(list-genealogy
|
(list-genealogy
|
||||||
(when (eq (org-element-type (car genealogy)) 'item)
|
(when (eq (org-element-type (car genealogy)) 'item)
|
||||||
(loop for el in genealogy
|
(loop for el in genealogy
|
||||||
|
|
73
lisp/ox.el
73
lisp/ox.el
|
@ -1669,8 +1669,7 @@ Following tree properties are set or updated:
|
||||||
export.
|
export.
|
||||||
|
|
||||||
Return updated plist."
|
Return updated plist."
|
||||||
;; Install the parse tree in the communication channel, in order to
|
;; Install the parse tree in the communication channel.
|
||||||
;; use `org-export-get-genealogy' and al.
|
|
||||||
(setq info (plist-put info :parse-tree data))
|
(setq info (plist-put info :parse-tree data))
|
||||||
;; Get the list of elements and objects to ignore, and put it into
|
;; Get the list of elements and objects to ignore, and put it into
|
||||||
;; `:ignore-list'. Do not overwrite any user ignore that might have
|
;; `:ignore-list'. Do not overwrite any user ignore that might have
|
||||||
|
@ -3664,7 +3663,7 @@ INFO is a plist holding contextual information."
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
(unless (org-some
|
(unless (org-some
|
||||||
(lambda (head) (org-not-nil (org-element-property :UNNUMBERED head)))
|
(lambda (head) (org-not-nil (org-element-property :UNNUMBERED head)))
|
||||||
(cons headline (org-export-get-genealogy headline)))
|
(org-element-lineage headline nil t))
|
||||||
(let ((sec-num (plist-get info :section-numbers))
|
(let ((sec-num (plist-get info :section-numbers))
|
||||||
(level (org-export-get-relative-level headline info)))
|
(level (org-export-get-relative-level headline info)))
|
||||||
(if (wholenump sec-num) (<= level sec-num) sec-num))))
|
(if (wholenump sec-num) (<= level sec-num) sec-num))))
|
||||||
|
@ -3706,15 +3705,11 @@ inherited from parent headlines and FILETAGS keywords."
|
||||||
(if (not inherited) (org-element-property :tags element)
|
(if (not inherited) (org-element-property :tags element)
|
||||||
;; Build complete list of inherited tags.
|
;; Build complete list of inherited tags.
|
||||||
(let ((current-tag-list (org-element-property :tags element)))
|
(let ((current-tag-list (org-element-property :tags element)))
|
||||||
(mapc
|
(dolist (parent (org-element-lineage element))
|
||||||
(lambda (parent)
|
(dolist (tag (org-element-property :tags parent))
|
||||||
(mapc
|
(when (and (memq (org-element-type parent) '(headline inlinetask))
|
||||||
(lambda (tag)
|
(not (member tag current-tag-list)))
|
||||||
(when (and (memq (org-element-type parent) '(headline inlinetask))
|
(push tag current-tag-list))))
|
||||||
(not (member tag current-tag-list)))
|
|
||||||
(push tag current-tag-list)))
|
|
||||||
(org-element-property :tags parent)))
|
|
||||||
(org-export-get-genealogy element))
|
|
||||||
;; Add FILETAGS keywords and return results.
|
;; Add FILETAGS keywords and return results.
|
||||||
(org-uniquify (append (plist-get info :filetags) current-tag-list))))))
|
(org-uniquify (append (plist-get info :filetags) current-tag-list))))))
|
||||||
|
|
||||||
|
@ -3980,13 +3975,12 @@ significant."
|
||||||
;; Search among headlines sharing an ancestor with link, from
|
;; Search among headlines sharing an ancestor with link, from
|
||||||
;; closest to farthest.
|
;; closest to farthest.
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(mapc
|
(dolist (parent
|
||||||
(lambda (parent)
|
(let ((parent-hl (org-export-get-parent-headline link)))
|
||||||
(let ((foundp (funcall find-headline path parent)))
|
(if (not parent-hl) (list (plist-get info :parse-tree))
|
||||||
(when foundp (throw 'exit foundp))))
|
(org-element-lineage parent-hl nil t))))
|
||||||
(let ((parent-hl (org-export-get-parent-headline link)))
|
(let ((foundp (funcall find-headline path parent)))
|
||||||
(if (not parent-hl) (list (plist-get info :parse-tree))
|
(when foundp (throw 'exit foundp))))
|
||||||
(cons parent-hl (org-export-get-genealogy parent-hl)))))
|
|
||||||
;; No destination found: return nil.
|
;; No destination found: return nil.
|
||||||
(and (not match-title-p) (puthash path nil link-cache))))))))
|
(and (not match-title-p) (puthash path nil link-cache))))))))
|
||||||
|
|
||||||
|
@ -4061,13 +4055,9 @@ objects of the same type."
|
||||||
;; table, item, or headline containing the object.
|
;; table, item, or headline containing the object.
|
||||||
(when (eq (org-element-type element) 'target)
|
(when (eq (org-element-type element) 'target)
|
||||||
(setq element
|
(setq element
|
||||||
(loop for parent in (org-export-get-genealogy element)
|
(org-element-lineage
|
||||||
when
|
element
|
||||||
(memq
|
'(footnote-definition footnote-reference headline item table))))
|
||||||
(org-element-type parent)
|
|
||||||
'(footnote-definition footnote-reference headline item
|
|
||||||
table))
|
|
||||||
return parent)))
|
|
||||||
(case (org-element-type element)
|
(case (org-element-type element)
|
||||||
;; Special case 1: A headline returns its number as a list.
|
;; Special case 1: A headline returns its number as a list.
|
||||||
(headline (org-export-get-headline-number element info))
|
(headline (org-export-get-headline-number element info))
|
||||||
|
@ -5100,47 +5090,26 @@ Return the new string."
|
||||||
;; (`org-export-get-parent-table'), previous element or object
|
;; (`org-export-get-parent-table'), previous element or object
|
||||||
;; (`org-export-get-previous-element') and next element or object
|
;; (`org-export-get-previous-element') and next element or object
|
||||||
;; (`org-export-get-next-element').
|
;; (`org-export-get-next-element').
|
||||||
;;
|
|
||||||
;; `org-export-get-genealogy' returns the full genealogy of a given
|
|
||||||
;; element or object, from closest parent to full parse tree.
|
|
||||||
|
|
||||||
;; defsubst org-export-get-parent must be defined before first use
|
;; defsubst org-export-get-parent must be defined before first use
|
||||||
|
|
||||||
(defun org-export-get-genealogy (blob)
|
(define-obsolete-function-alias
|
||||||
"Return full genealogy relative to a given element or object.
|
'org-export-get-genealogy 'org-element-lineage "25.1")
|
||||||
|
|
||||||
BLOB is the element or object being considered.
|
|
||||||
|
|
||||||
Ancestors are returned from closest to farthest, the last one
|
|
||||||
being the full parse tree."
|
|
||||||
(let (genealogy (parent blob))
|
|
||||||
(while (setq parent (org-element-property :parent parent))
|
|
||||||
(push parent genealogy))
|
|
||||||
(nreverse genealogy)))
|
|
||||||
|
|
||||||
(defun org-export-get-parent-headline (blob)
|
(defun org-export-get-parent-headline (blob)
|
||||||
"Return BLOB parent headline or nil.
|
"Return BLOB parent headline or nil.
|
||||||
BLOB is the element or object being considered."
|
BLOB is the element or object being considered."
|
||||||
(let ((parent blob))
|
(org-element-lineage blob '(headline)))
|
||||||
(while (and (setq parent (org-element-property :parent parent))
|
|
||||||
(not (eq (org-element-type parent) 'headline))))
|
|
||||||
parent))
|
|
||||||
|
|
||||||
(defun org-export-get-parent-element (object)
|
(defun org-export-get-parent-element (object)
|
||||||
"Return first element containing OBJECT or nil.
|
"Return first element containing OBJECT or nil.
|
||||||
OBJECT is the object to consider."
|
OBJECT is the object to consider."
|
||||||
(let ((parent object))
|
(org-element-lineage object org-element-all-elements))
|
||||||
(while (and (setq parent (org-element-property :parent parent))
|
|
||||||
(memq (org-element-type parent) org-element-all-objects)))
|
|
||||||
parent))
|
|
||||||
|
|
||||||
(defun org-export-get-parent-table (object)
|
(defun org-export-get-parent-table (object)
|
||||||
"Return OBJECT parent table or nil.
|
"Return OBJECT parent table or nil.
|
||||||
OBJECT is either a `table-cell' or `table-element' type object."
|
OBJECT is either a `table-cell' or `table-element' type object."
|
||||||
(let ((parent object))
|
(org-element-lineage object '(table)))
|
||||||
(while (and (setq parent (org-element-property :parent parent))
|
|
||||||
(not (eq (org-element-type parent) 'table))))
|
|
||||||
parent))
|
|
||||||
|
|
||||||
(defun org-export-get-previous-element (blob info &optional n)
|
(defun org-export-get-previous-element (blob info &optional n)
|
||||||
"Return previous element or object.
|
"Return previous element or object.
|
||||||
|
|
Loading…
Reference in New Issue