1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

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:
Nicolas Goaziou 2014-11-16 13:27:34 +01:00
parent 182d61fc8f
commit 61ba40c371
6 changed files with 43 additions and 79 deletions

View File

@ -562,7 +562,7 @@ INFO is a plist used as a communication channel."
;; Elements with a relative width: store maximum text width in
;; TOTAL-WIDTH.
(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
;; inline task among ELEMENT parents.
(total-width

View File

@ -337,12 +337,10 @@ INFO is a plist used as a communication channel."
;; 1. Look for "frame" environment in parents, starting from the
;; farthest.
(catch 'exit
(mapc (lambda (parent)
(let ((env (org-element-property :BEAMER_ENV parent)))
(when (and env (member-ignore-case env '("frame" "fullframe")))
(throw 'exit (org-export-get-relative-level parent info)))))
(nreverse (org-export-get-genealogy headline)))
nil)
(dolist (parent (nreverse (org-element-lineage headline)))
(let ((env (org-element-property :BEAMER_ENV parent)))
(when (and env (member-ignore-case env '("frame" "fullframe")))
(throw 'exit (org-export-get-relative-level parent info))))))
;; 2. Look for "frame" environment in HEADLINE.
(let ((env (org-element-property :BEAMER_ENV headline)))
(and env (member-ignore-case env '("frame" "fullframe"))

View File

@ -323,19 +323,17 @@ A headline is blocked when either
;; Check :ORDERED: node property.
(catch 'blockedp
(let ((current headline))
(mapc (lambda (parent)
(cond
((not (org-element-property :todo-keyword parent))
(throw 'blockedp nil))
((org-not-nil (org-element-property :ORDERED parent))
(let ((sibling current))
(while (setq sibling (org-export-get-previous-element
sibling info))
(when (eq (org-element-property :todo-type sibling) 'todo)
(throw 'blockedp t)))))
(t (setq current parent))))
(org-export-get-genealogy headline))
nil))))
(dolist (parent (org-element-lineage headline))
(cond
((not (org-element-property :todo-keyword parent))
(throw 'blockedp nil))
((org-not-nil (org-element-property :ORDERED parent))
(let ((sibling current))
(while (setq sibling (org-export-get-previous-element
sibling info))
(when (eq (org-element-property :todo-type sibling) 'todo)
(throw 'blockedp t)))))
(t (setq current parent))))))))
(defun org-icalendar-use-UTC-date-time-p ()
"Non-nil when `org-icalendar-date-time-format' requires UTC time."

View File

@ -1425,9 +1425,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(org-export-get-footnote-number footnote-reference info)))
;; Use \footnotemark if reference is within another footnote
;; reference, footnote definition or table cell.
((loop for parent in (org-export-get-genealogy footnote-reference)
thereis (memq (org-element-type parent)
'(footnote-reference footnote-definition table-cell)))
((org-element-lineage footnote-reference
'(footnote-reference footnote-definition table-cell))
"\\footnotemark")
;; Otherwise, define it with \footnote command.
(t

View File

@ -2087,7 +2087,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(let* ((--numbered-parent-headline-at-<=-n
(function
(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)
(<= (org-export-get-relative-level x info) n)
(org-export-numbered-headline-p x info)
@ -2639,7 +2639,7 @@ Return nil, otherwise."
;; NOTE: Counterpart of `org-export-get-ordinal'.
;; FIXME: Handle footnote-definition footnote-reference?
(let* ((genealogy (org-export-get-genealogy destination))
(let* ((genealogy (org-element-lineage destination))
(data (reverse genealogy))
(label (case (org-element-type destination)
(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>"
(org-export-solidify-link-text label)
(mapconcat (lambda (n) (if (not n) " "
(concat (number-to-string n) ".")))
(concat (number-to-string n) ".")))
item-numbers "")))))
;; Case 2: Locate a regular and numbered headline in the
;; hierarchy. Display its section number.
@ -3515,7 +3515,7 @@ pertaining to indentation here."
(--walk-list-genealogy-and-collect-tags
(function
(lambda (table info)
(let* ((genealogy (org-export-get-genealogy table))
(let* ((genealogy (org-element-lineage table))
(list-genealogy
(when (eq (org-element-type (car genealogy)) 'item)
(loop for el in genealogy

View File

@ -1669,8 +1669,7 @@ Following tree properties are set or updated:
export.
Return updated plist."
;; Install the parse tree in the communication channel, in order to
;; use `org-export-get-genealogy' and al.
;; Install the parse tree in the communication channel.
(setq info (plist-put info :parse-tree data))
;; Get the list of elements and objects to ignore, and put it into
;; `: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."
(unless (org-some
(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))
(level (org-export-get-relative-level headline info)))
(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)
;; Build complete list of inherited tags.
(let ((current-tag-list (org-element-property :tags element)))
(mapc
(lambda (parent)
(mapc
(lambda (tag)
(when (and (memq (org-element-type parent) '(headline inlinetask))
(not (member tag current-tag-list)))
(push tag current-tag-list)))
(org-element-property :tags parent)))
(org-export-get-genealogy element))
(dolist (parent (org-element-lineage element))
(dolist (tag (org-element-property :tags parent))
(when (and (memq (org-element-type parent) '(headline inlinetask))
(not (member tag current-tag-list)))
(push tag current-tag-list))))
;; Add FILETAGS keywords and return results.
(org-uniquify (append (plist-get info :filetags) current-tag-list))))))
@ -3980,13 +3975,12 @@ significant."
;; Search among headlines sharing an ancestor with link, from
;; closest to farthest.
(catch 'exit
(mapc
(lambda (parent)
(let ((foundp (funcall find-headline path parent)))
(when foundp (throw 'exit foundp))))
(let ((parent-hl (org-export-get-parent-headline link)))
(if (not parent-hl) (list (plist-get info :parse-tree))
(cons parent-hl (org-export-get-genealogy parent-hl)))))
(dolist (parent
(let ((parent-hl (org-export-get-parent-headline link)))
(if (not parent-hl) (list (plist-get info :parse-tree))
(org-element-lineage parent-hl nil t))))
(let ((foundp (funcall find-headline path parent)))
(when foundp (throw 'exit foundp))))
;; No destination found: return nil.
(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.
(when (eq (org-element-type element) 'target)
(setq element
(loop for parent in (org-export-get-genealogy element)
when
(memq
(org-element-type parent)
'(footnote-definition footnote-reference headline item
table))
return parent)))
(org-element-lineage
element
'(footnote-definition footnote-reference headline item table))))
(case (org-element-type element)
;; Special case 1: A headline returns its number as a list.
(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-previous-element') and next element or object
;; (`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
(defun org-export-get-genealogy (blob)
"Return full genealogy relative to a given element or object.
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)))
(define-obsolete-function-alias
'org-export-get-genealogy 'org-element-lineage "25.1")
(defun org-export-get-parent-headline (blob)
"Return BLOB parent headline or nil.
BLOB is the element or object being considered."
(let ((parent blob))
(while (and (setq parent (org-element-property :parent parent))
(not (eq (org-element-type parent) 'headline))))
parent))
(org-element-lineage blob '(headline)))
(defun org-export-get-parent-element (object)
"Return first element containing OBJECT or nil.
OBJECT is the object to consider."
(let ((parent object))
(while (and (setq parent (org-element-property :parent parent))
(memq (org-element-type parent) org-element-all-objects)))
parent))
(org-element-lineage object org-element-all-elements))
(defun org-export-get-parent-table (object)
"Return OBJECT parent table or nil.
OBJECT is either a `table-cell' or `table-element' type object."
(let ((parent object))
(while (and (setq parent (org-element-property :parent parent))
(not (eq (org-element-type parent) 'table))))
parent))
(org-element-lineage object '(table)))
(defun org-export-get-previous-element (blob info &optional n)
"Return previous element or object.