Browse Source

org-export: Rewrite topology functions

* contrib/lisp/org-export.el (org-export-get-genealogy,
  org-export-get-parent, org-export-get-parent-headline,
  org-export-get-parent-table): Rewrite function to use :parent
  property.  Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code.  Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
  org-e-ascii--unique-links, org-e-ascii-inlinetask,
  org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
  org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
  change.
* contrib/lisp/org-e-html.el (org-e-html-link,
  org-e-html-link--inline-image): Use new function and apply signature
  change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
  new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
  org-e-odt-format-label, org-e-odt-link--inline-image): Use new
  function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
Nicolas Goaziou 12 years ago
parent
commit
4728a4611e

+ 10 - 10
contrib/lisp/org-e-ascii.el

@@ -53,7 +53,7 @@
 (declare-function org-export-get-headline-number "org-export" (headline info))
 (declare-function org-export-get-ordinal "org-export"
 		  (element info &optional types predicate))
-(declare-function org-export-get-parent-headline "org-export" (blob info))
+(declare-function org-export-get-parent-headline "org-export" (blob))
 (declare-function org-export-get-relative-level "org-export" (headline info))
 (declare-function org-export-low-level-p "org-export" (headline info))
 (declare-function org-export-output-file-name "org-export"
@@ -564,7 +564,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 info)))
+     (let* ((genealogy (cons element (org-export-get-genealogy element)))
 	    ;; Total width is determined by the presence, or not, of an
 	    ;; inline task among ELEMENT parents.
 	    (total-width
@@ -574,7 +574,7 @@ INFO is a plist used as a communication channel."
 	       ;; No inlinetask: Remove global margin from text width.
 	       (- org-e-ascii-text-width
 		  org-e-ascii-global-margin
-		  (let ((parent (org-export-get-parent-headline element info)))
+		  (let ((parent (org-export-get-parent-headline element)))
 		    ;; Inner margin doesn't apply to text before first
 		    ;; headline.
 		    (if (not parent) 0
@@ -830,7 +830,7 @@ is a plist used as a communication channel."
 	 ;; count links that might be in the title.
 	 (headline
 	  (if (eq (org-element-type element) 'headline) element
-	    (or (org-export-get-parent-headline element info) element))))
+	    (or (org-export-get-parent-headline element) element))))
     ;; Get all links in HEADLINE.
     (org-element-map
      headline 'link (lambda (link) (funcall unique-link-p link)) info)))
@@ -1306,7 +1306,7 @@ holding contextual information."
 	  (make-string width (if utf8p ?━ ?_)))
 	 ;; Flush the inlinetask to the right.
 	 (- org-e-ascii-text-width org-e-ascii-global-margin
-	    (if (not (org-export-get-parent-headline inlinetask info)) 0
+	    (if (not (org-export-get-parent-headline inlinetask)) 0
 	      org-e-ascii-inner-margin)
 	    (org-e-ascii--current-text-width inlinetask info)))))))
 
@@ -1329,7 +1329,7 @@ contextual information."
 	 ;; First parent of ITEM is always the plain-list.  Get
 	 ;; `:type' property from it.
 	 (org-list-bullet-string
-	  (case (org-element-property :type (org-export-get-parent item info))
+	  (case (org-element-property :type (org-export-get-parent item))
 	    (descriptive
 	     (concat (org-export-data (org-element-property :tag item) info)
 		     ": "))
@@ -1473,7 +1473,7 @@ information."
 CONTENTS is the contents of the paragraph, as a string.  INFO is
 the plist used as a communication channel."
   (org-e-ascii--fill-string
-   (let ((parent (org-export-get-parent paragraph info)))
+   (let ((parent (org-export-get-parent paragraph)))
      ;; If PARAGRAPH is the first one in a list element, be sure to
      ;; add the check-box in front of it, before any filling.  Later,
      ;; it would interfere with line width.
@@ -1567,7 +1567,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
      value
      (+ org-e-ascii-quote-margin
 	;; Don't apply inner margin if parent headline is low level.
-	(let ((headline (org-export-get-parent-headline quote-section info)))
+	(let ((headline (org-export-get-parent-headline quote-section)))
 	  (if (org-export-low-level-p headline info) 0
 	    org-e-ascii-inner-margin))))))
 
@@ -1597,7 +1597,7 @@ contextual information."
 	;; Separate list of links and section contents.
 	(when (org-string-nw-p links) (concat "\n\n" links)))))
    ;; Do not apply inner margin if parent headline is low level.
-   (let ((headline (org-export-get-parent-headline section info)))
+   (let ((headline (org-export-get-parent-headline section)))
      (if (or (not headline) (org-export-low-level-p headline info)) 0
        org-e-ascii-inner-margin))))
 
@@ -1698,7 +1698,7 @@ are ignored."
   (or (and (not org-e-ascii-table-widen-columns)
 	   (org-export-table-cell-width table-cell info))
       (let* ((max-width 0)
-	     (table (org-export-get-parent-table table-cell info))
+	     (table (org-export-get-parent-table table-cell))
 	     (specialp (org-export-table-has-special-column-p table))
 	     (col (cdr (org-export-table-cell-address table-cell info))))
 	(org-element-map

+ 10 - 10
contrib/lisp/org-e-html.el

@@ -2022,7 +2022,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (concat
    ;; Insert separator between two footnotes in a row.
-   (let ((prev (org-export-get-previous-element footnote-reference info)))
+   (let ((prev (org-export-get-previous-element footnote-reference)))
      (when (eq (org-element-type prev) 'footnote-reference)
        org-e-html-footnote-separator))
    (cond
@@ -2261,7 +2261,7 @@ contextual information."
   "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 info))
+  (let* ((plain-list (org-export-get-parent item))
 	 (type (org-element-property :type plain-list))
 	 (counter (org-element-property :counter item))
 	 (checkbox (org-element-property :checkbox item))
@@ -2382,7 +2382,7 @@ used as a communication channel."
 		     ((file-name-absolute-p raw-path)
 		      (expand-file-name raw-path))
 		     (t raw-path)))
-	 (parent (org-export-get-parent-paragraph link info))
+	 (parent (org-export-get-parent-element link))
 	 (caption (org-e-html--caption/label-string
 		   (org-element-property :caption parent)
 		   (org-element-property :name parent)
@@ -2428,7 +2428,7 @@ standalone images, do the following.
 		     (paragraph element)
 		     (link (and (org-export-inline-image-p
 				 element org-e-html-inline-image-rules)
-				(org-export-get-parent element info)))
+				(org-export-get-parent element)))
 		     (t nil))))
     (when paragraph
       (assert (eq (org-element-type paragraph) 'paragraph))
@@ -2484,7 +2484,7 @@ INFO is a plist holding contextual information.  See
 	  (let ((attr (mapconcat
 		       'identity
 		       (org-element-property
-			:attr_html (org-export-get-parent-paragraph link info))
+			:attr_html (org-export-get-parent-element link))
 		       " ")))
 	    (if attr (concat " " attr) "")))
 	 protocol)
@@ -2615,7 +2615,7 @@ the plist used as a communication channel."
 	 (class (cdr (assoc style '((footnote . "footnote")
 				    (verse . nil)))))
 	 (extra (if class (format " class=\"%s\"" class) ""))
-	 (parent (org-export-get-parent paragraph info)))
+	 (parent (org-export-get-parent paragraph)))
     (cond
      ((and (equal (org-element-type parent) 'item)
 	   (= (org-element-property :begin paragraph)
@@ -2783,7 +2783,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   "Transcode a SECTION element from Org to HTML.
 CONTENTS holds the contents of the section.  INFO is a plist
 holding contextual information."
-  (let ((parent (org-export-get-parent-headline section info)))
+  (let ((parent (org-export-get-parent-headline section)))
     ;; Before first headline: no container, just return CONTENTS.
     (if (not parent) contents
       ;; Get div's class and id references.
@@ -2905,8 +2905,8 @@ 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 info))
-	 (table (org-export-get-parent-table table-cell info))
+  (let* ((table-row (org-export-get-parent table-cell))
+	 (table (org-export-get-parent-table table-cell))
 	 (cell-attrs
 	  (if (not org-e-html-table-align-individual-fields) ""
 	    (format (if (and (boundp 'org-e-html-format-table-no-css)
@@ -2945,7 +2945,7 @@ communication channel."
 	      '("\n<tbody>" . "\n</tbody>"))
 	     ;; Case 2: Row is from first rowgroup.  Table has >=1 rowgroups.
 	     ((org-export-table-has-header-p
-	       (org-export-get-parent-table table-row info) info)
+	       (org-export-get-parent-table table-row) info)
 	      '("\n<thead>" . "\n</thead>"))
 	     ;; Case 2: Row is from first and only row group.
 	     (t '("\n<tbody>" . "\n</tbody>")))))

+ 8 - 8
contrib/lisp/org-e-latex.el

@@ -56,7 +56,7 @@
 (declare-function org-export-get-footnote-definition "org-export"
 		  (footnote-reference info))
 (declare-function org-export-get-footnote-number "org-export" (footnote info))
-(declare-function org-export-get-previous-element "org-export" (blob info))
+(declare-function org-export-get-previous-element "org-export" (blob))
 (declare-function org-export-get-relative-level "org-export" (headline info))
 (declare-function org-export-unravel-code "org-export" (element))
 (declare-function org-export-inline-image-p "org-export"
@@ -1150,7 +1150,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (concat
    ;; Insert separator between two footnotes in a row.
-   (let ((prev (org-export-get-previous-element footnote-reference info)))
+   (let ((prev (org-export-get-previous-element footnote-reference)))
      (when (eq (org-element-type prev) 'footnote-reference)
        org-e-latex-footnote-separator))
    (cond
@@ -1160,7 +1160,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	     (org-export-get-footnote-number footnote-reference info)))
     ;; Use also \footnotemark if reference is within another footnote
     ;; reference or footnote definition.
-    ((loop for parent in (org-export-get-genealogy footnote-reference info)
+    ((loop for parent in (org-export-get-genealogy footnote-reference)
 	   thereis (memq (org-element-type parent)
 			 '(footnote-reference footnote-definition)))
      (let ((num (org-export-get-footnote-number footnote-reference info)))
@@ -1408,7 +1408,7 @@ contextual information."
   (let* ((counter
 	  (let ((count (org-element-property :counter item))
 		(level
-		 (loop for parent in (org-export-get-genealogy item info)
+		 (loop for parent in (org-export-get-genealogy item)
 		       count (eq (org-element-type parent) 'plain-list)
 		       until (eq (org-element-type parent) 'headline))))
 	    (and count
@@ -1501,7 +1501,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   "Return LaTeX code for an inline image.
 LINK is the link pointing to the inline image.  INFO is a plist
 used as a communication channel."
-  (let* ((parent (org-export-get-parent-paragraph link info))
+  (let* ((parent (org-export-get-parent-element link))
 	 (path (let ((raw-path (org-element-property :path link)))
 		 (if (not (file-name-absolute-p raw-path)) raw-path
 		   (expand-file-name raw-path))))
@@ -2179,7 +2179,7 @@ a communication channel."
 		      (match-string 1 contents)
 		      (match-string 2 contents))
 	    contents)
-	  (when (org-export-get-next-element table-cell info) " & ")))
+	  (when (org-export-get-next-element table-cell) " & ")))
 
 
 ;;;; Table Row
@@ -2193,7 +2193,7 @@ a communication channel."
   (when (eq (org-element-property :type table-row) 'standard)
     (let* ((attr (mapconcat 'identity
 			    (org-element-property
-			     :attr_latex (org-export-get-parent table-row info))
+			     :attr_latex (org-export-get-parent table-row))
 			    " "))
 	   (longtablep (and attr (string-match "\\<longtable\\>" attr)))
 	   (booktabsp
@@ -2221,7 +2221,7 @@ a communication channel."
 		 (if booktabsp "\\midrule" "\\hline")
 		 ;; Number of columns.
 		 (cdr (org-export-table-dimensions
-		       (org-export-get-parent-table table-row info) info))))
+		       (org-export-get-parent-table table-row) info))))
 	;; When BOOKTABS are activated enforce bottom rule even when
 	;; no hline was specifically marked.
 	((and booktabsp (memq 'bottom borders)) "\\bottomrule")

+ 17 - 17
contrib/lisp/org-e-odt.el

@@ -534,7 +534,7 @@ Update styles.xml with styles that were collected as part of
 	       (t (error "what is this?"))))
 	 (caption-from
 	  (case (org-element-type element)
-	    (link (org-export-get-parent-paragraph element info))
+	    (link (org-export-get-parent-element element))
 	    (t element)))
 	 (captions (org-e-odt-format-label caption-from info 'definition))
 	 (caption (car captions))
@@ -858,7 +858,7 @@ ATTR is a string of other attributes of the a element."
 (defun org-e-odt-format-label (element info op)
   (let* ((caption-from
 	  (case (org-element-type element)
-	    (link (org-export-get-parent-paragraph element info))
+	    (link (org-export-get-parent-element element))
 	    (t element)))
 	 ;; get label and caption.
 	 (label (org-element-property :name caption-from))
@@ -2802,7 +2802,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (concat
    ;; Insert separator between two footnotes in a row.
-   (let ((prev (org-export-get-previous-element footnote-reference info)))
+   (let ((prev (org-export-get-previous-element footnote-reference)))
      (when (eq (org-element-type prev) 'footnote-reference)
        org-e-odt-footnote-separator))
    (cond
@@ -2989,7 +2989,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 info))
+  (let* ((plain-list (org-export-get-parent item))
 	 (type (org-element-property :type plain-list))
 	 (counter (org-element-property :counter item))
 	 (tag (let ((tag (org-element-property :tag item)))
@@ -3158,7 +3158,7 @@ used as a communication channel."
 		(org-e-odt-copy-image-file src)))
 	 ;; extract attributes from #+ATTR_ODT line.
 	 (attr-from (case (org-element-type element)
-		      (link (org-export-get-parent-paragraph element info))
+		      (link (org-export-get-parent-element element))
 		      (t element)))
 	 ;; convert attributes to a plist.
 	 (attr-plist (org-e-odt-element-attributes attr-from info))
@@ -3257,7 +3257,7 @@ standalone images, do the following.
 		     (paragraph element)
 		     (link (and (org-export-inline-image-p
 				 element org-e-odt-inline-image-rules)
-				(org-export-get-parent element info)))
+				(org-export-get-parent element)))
 		     (t nil))))
     (when paragraph
       (assert (eq (org-element-type paragraph) 'paragraph))
@@ -3403,7 +3403,7 @@ the plist used as a communication channel."
 	 (class (cdr (assoc style '((footnote . "footnote")
 				    (verse . nil)))))
 	 (extra (if class (format " class=\"%s\"" class) ""))
-	 (parent (org-export-get-parent paragraph info))
+	 (parent (org-export-get-parent paragraph))
 	 (parent-type (org-element-type parent))
 	 (style (case parent-type
 		  (quote-block 'quote)
@@ -3443,7 +3443,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 info)))
+		     (let* ((parent (org-export-get-parent plain-list)))
 		       (if (and parent (equal (org-element-type parent) 'item))
 			   "true" "false")))
 	     contents))))
@@ -3624,7 +3624,7 @@ contextual information."
 ;;;; Table Cell
 
 (defun org-e-odt-table-style-spec (element info)
-  (let* ((table (org-export-get-parent-table element info))
+  (let* ((table (org-export-get-parent-table element))
 	 (table-attributes (org-e-odt-element-attributes table info))
 	 (table-style (plist-get table-attributes :style)))
     (assoc table-style org-e-odt-table-styles)))
@@ -3650,7 +3650,7 @@ styles congruent with the ODF-1.2 specification."
 	 (r (car table-cell-address)) (c (cdr table-cell-address))
 	 (style-spec (org-e-odt-table-style-spec table-cell info))
 	 (table-dimensions (org-export-table-dimensions
-			    (org-export-get-parent-table table-cell info)
+			    (org-export-get-parent-table table-cell)
 			    info)))
     (when style-spec
       ;; LibreOffice - particularly the Writer - honors neither table
@@ -3697,7 +3697,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 info))
+	 (table-row (org-export-get-parent table-cell))
 	 (custom-style-prefix (org-e-odt-get-table-cell-styles
 			       table-cell info))
 	 (paragraph-style
@@ -3708,9 +3708,9 @@ channel."
 	    (cond
 	     ((and (= 1 (org-export-table-row-group table-row info))
 		   (org-export-table-has-header-p
-		    (org-export-get-parent-table table-row info) info))
+		    (org-export-get-parent-table table-row) info))
 	      "OrgTableHeading")
-	     ((let* ((table (org-export-get-parent-table table-cell info))
+	     ((let* ((table (org-export-get-parent-table table-cell))
 		     (table-attrs (org-e-odt-element-attributes table info))
 		     (table-header-columns (plist-get table-attrs
 						      :header-columns)))
@@ -3763,7 +3763,7 @@ communication channel."
     (let* ((rowgroup-tags
 	    (if (and (= 1 (org-export-table-row-group table-row info))
 		     (org-export-table-has-header-p
-		      (org-export-get-parent-table table-row info) info))
+		      (org-export-get-parent-table table-row) info))
 		;; If the row belongs to the first rowgroup and the
 		;; table has more than one row groups, then this row
 		;; belongs to the header row group.
@@ -3854,7 +3854,7 @@ contextual information."
   (let* ((--get-previous-elements
 	  (function
 	   (lambda (blob info)
-	     (let ((parent (org-export-get-parent blob info)))
+	     (let ((parent (org-export-get-parent blob)))
 	       (cdr (member blob (reverse (org-element-contents parent))))))))
 	 (--element-preceded-by-table-p
 	  (function
@@ -3864,7 +3864,7 @@ contextual information."
 	 (--walk-list-genealogy-and-collect-tags
 	  (function
 	   (lambda (table info)
-	     (let* ((genealogy (org-export-get-genealogy table info))
+	     (let* ((genealogy (org-export-get-genealogy table))
 		    (list-genealogy
 		     (when (equal (org-element-type (car genealogy)) 'item)
 		       (loop for el in genealogy
@@ -4181,7 +4181,7 @@ using `org-open-file'."
   (let* ((numbered-parent-headline-at-<=-n
 	  (function
 	   (lambda (element n info)
-	     (loop for x in (org-export-get-genealogy element info)
+	     (loop for x in (org-export-get-genealogy element)
 		   thereis (and (eq (org-element-type x) 'headline)
 		   		(<= (org-export-get-relative-level x info) n)
 		   		(org-export-numbered-headline-p x info)

+ 2 - 2
contrib/lisp/org-e-publish.el

@@ -50,7 +50,7 @@
 (declare-function
  org-export-to-file "org-export"
  (backend file &optional subtreep visible-only body-only ext-plist))
-(declare-function org-export-get-parent-headline "org-export" (blob info))
+(declare-function org-export-get-parent-headline "org-export" (blob))
 (declare-function org-export-get-environment "org-export"
 		  (&optional backend subtreep ext-plist))
 (declare-function org-export-get-inbuffer-options "org-export"
@@ -979,7 +979,7 @@ keyword."
        (when (string= (downcase (org-element-property :key k))
 		      "index")
 	 (let ((index (org-element-property :value k))
-	       (parent (org-export-get-parent-headline k info)))
+	       (parent (org-export-get-parent-headline k)))
 	   (list index (plist-get info :input-file) parent))))
      info)))
   ;; Return parse-tree to avoid altering output.

+ 68 - 109
contrib/lisp/org-export.el

@@ -1601,8 +1601,8 @@ tag."
     ;; Check table-cell.
     (table-cell
      (and (org-export-table-has-special-column-p
-	   (nth 1 (org-export-get-genealogy blob options)))
-	  (not (org-export-get-previous-element blob options))))
+	   (org-export-get-parent-table blob))
+	  (not (org-export-get-previous-element blob))))
     ;; Check clock.
     (clock (not (plist-get options :with-clocks)))
     ;; Check planning.
@@ -1702,7 +1702,7 @@ Return transcoded string."
 			     ;; indentation: there is none and it
 			     ;; might be misleading.
 			     (when (eq type 'paragraph)
-			       (let ((parent (org-export-get-parent data info)))
+			       (let ((parent (org-export-get-parent data)))
 				 (and (equal (car (org-element-contents parent))
 					     data)
 				      (memq (org-element-type parent)
@@ -2837,13 +2837,13 @@ Any tag belonging to this list will also be removed."
 (defun org-export-first-sibling-p (headline info)
   "Non-nil when HEADLINE is the first sibling in its sub-tree.
 INFO is the plist used as a communication channel."
-  (not (eq (org-element-type (org-export-get-previous-element headline info))
+  (not (eq (org-element-type (org-export-get-previous-element headline))
 	   'headline)))
 
 (defun org-export-last-sibling-p (headline info)
   "Non-nil when HEADLINE is the last sibling in its sub-tree.
 INFO is the plist used as a communication channel."
-  (not (org-export-get-next-element headline info)))
+  (not (org-export-get-next-element headline)))
 
 
 ;;;; For Links
@@ -3004,7 +3004,7 @@ Assume LINK type is \"fuzzy\"."
 		 (when (eq (org-element-type parent) 'headline)
 		   (let ((foundp (funcall find-headline path parent)))
 		     (when foundp (throw 'exit foundp)))))
-	       (org-export-get-genealogy link info)) nil)
+	       (org-export-get-genealogy link)) nil)
 	    ;; No match with a common ancestor: try the full parse-tree.
 	    (funcall find-headline
 		     (if match-title-p (substring path 1) path)
@@ -3109,7 +3109,7 @@ 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 info)
+	    (loop for parent in (org-export-get-genealogy element)
 		  when
 		  (memq
 		   (org-element-type parent)
@@ -3402,7 +3402,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 info))
+	     (org-export-get-parent table-row))
 	    (member first-cell '(("^") ("_") ("$") ("!"))))
        ;; ... it contains only alignment cookies and empty cells.
        (let ((special-row-p 'empty))
@@ -3442,7 +3442,7 @@ rows and table rules.  Group 1 is also table's header."
 	    ((eq (org-element-property :type row) 'rule)
 	     (setq row-flag nil)))
 	   (when (equal table-row row) (throw 'found group)))
-	 (org-element-contents (org-export-get-parent table-row info)))))))
+	 (org-element-contents (org-export-get-parent table-row)))))))
 
 (defun org-export-table-cell-width (table-cell info)
   "Return TABLE-CELL contents width.
@@ -3451,11 +3451,10 @@ 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* ((genealogy (org-export-get-genealogy table-cell info))
-	 (row (car genealogy))
+  (let* ((row (org-export-get-parent table-cell))
 	 (column (let ((cells (org-element-contents row)))
 		   (- (length cells) (length (member table-cell cells)))))
-	 (table (nth 1 genealogy))
+	 (table (org-export-get-parent-table table-cell))
 	 cookie-width)
     (mapc
      (lambda (row)
@@ -3489,11 +3488,10 @@ same column as TABLE-CELL.  If no such cookie is found, a default
 alignment value will be deduced from fraction of numbers in the
 column (see `org-table-number-fraction' for more information).
 Possible values are `left', `right' and `center'."
-  (let* ((genealogy (org-export-get-genealogy table-cell info))
-	 (row (car genealogy))
+  (let* ((row (org-export-get-parent table-cell))
 	 (column (let ((cells (org-element-contents row)))
 		   (- (length cells) (length (member table-cell cells)))))
-	 (table (nth 1 genealogy))
+	 (table (org-export-get-parent-table table-cell))
 	 (number-cells 0)
 	 (total-cells 0)
 	 cookie-align)
@@ -3549,9 +3547,8 @@ 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* ((genealogy (org-export-get-genealogy table-cell info))
-	 (row (car genealogy))
-	 (table (nth 1 genealogy))
+  (let* ((row (org-export-get-parent table-cell))
+	 (table (org-export-get-parent-table table-cell))
 	 borders)
     ;; Top/above border?  TABLE-CELL has a border above when a rule
     ;; used to demarcate row groups can be found above.  Hence,
@@ -3635,7 +3632,7 @@ INFO is a plist used as a communication channel."
   ;; of a row (or after the special column, if any) or when it has
   ;; a left border.
   (or (equal (org-element-map
-	      (org-export-get-parent table-cell info)
+	      (org-export-get-parent table-cell)
 	      'table-cell 'identity info 'first-match)
 	     table-cell)
       (memq 'left (org-export-table-cell-borders table-cell info))))
@@ -3646,7 +3643,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 (equal (car (last (org-element-contents
-			 (org-export-get-parent table-cell info))))
+			 (org-export-get-parent table-cell))))
 	     table-cell)
       (memq 'right (org-export-table-cell-borders table-cell info))))
 
@@ -3672,7 +3669,7 @@ INFO is a plist used as a communication channel."
   "Non-nil when TABLE-ROW is the first table header's row.
 INFO is a plist used as a communication channel."
   (and (org-export-table-has-header-p
-	(org-export-get-parent-table table-row info) info)
+	(org-export-get-parent-table table-row) info)
        (org-export-table-row-starts-rowgroup-p table-row info)
        (= (org-export-table-row-group table-row info) 1)))
 
@@ -3680,7 +3677,7 @@ INFO is a plist used as a communication channel."
   "Non-nil when TABLE-ROW is the last table header's row.
 INFO is a plist used as a communication channel."
   (and (org-export-table-has-header-p
-	(org-export-get-parent-table table-row info) info)
+	(org-export-get-parent-table table-row) info)
        (org-export-table-row-ends-rowgroup-p table-row info)
        (= (org-export-table-row-group table-row info) 1)))
 
@@ -3714,8 +3711,8 @@ 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 info))
-	 (table (org-export-get-parent-table table-cell info)))
+  (let* ((table-row (org-export-get-parent table-cell))
+	 (table (org-export-get-parent-table table-cell)))
     ;; Ignore cells in special rows or in special column.
     (unless (or (org-export-table-row-is-special-p table-row info)
 		(and (org-export-table-has-special-column-p table)
@@ -3852,102 +3849,64 @@ Return a list of src-block elements with a caption."
 ;; Here are various functions to retrieve information about the
 ;; neighbourhood of a given element or object.  Neighbours of interest
 ;; are direct parent (`org-export-get-parent'), parent headline
-;; (`org-export-get-parent-headline'), parent paragraph
-;; (`org-export-get-parent-paragraph'), previous element or object
+;; (`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').
 ;;
-;; All of these functions are just a specific use of the more generic
-;; `org-export-get-genealogy', which returns the genealogy relative to
-;; the element or object.
-
-(defun org-export-get-genealogy (blob info)
-  "Return genealogy relative to a given element or object.
-BLOB is the element or object being considered.  INFO is a plist
-used as a communication channel."
-  (let* ((type (org-element-type blob))
-	 (end (org-element-property :end blob))
-	 walk-data			; for byte-compiler.
-         (walk-data
-          (lambda (data genealogy)
-	    ;; Walk DATA, looking for BLOB.  GENEALOGY is the list of
-	    ;; parents of all elements in DATA.
-            (mapc
-             (lambda (el)
-               (cond
-		((stringp el) nil)
-                ((equal el blob) (throw 'exit genealogy))
-                ((>= (org-element-property :end el) end)
-		 ;; If BLOB is an object and EL contains a secondary
-		 ;; string, be sure to check it.
-		 (when (memq type org-element-all-objects)
-		   (let ((sec-prop
-			  (cdr (assq (org-element-type el)
-				     org-element-secondary-value-alist))))
-		     (when sec-prop
-		       (funcall
-			walk-data
-			(cons 'org-data
-			      (cons nil (org-element-property sec-prop el)))
-			(cons el genealogy)))))
-                 (funcall walk-data el (cons el genealogy)))))
-	     (org-element-contents data)))))
-    (catch 'exit (funcall walk-data (plist-get info :parse-tree) nil) nil)))
-
-(defun org-export-get-parent (blob info)
-  "Return BLOB parent or nil.
-BLOB is the element or object considered.  INFO is a plist used
-as a communication channel."
-  (car (org-export-get-genealogy blob info)))
+;; `org-export-get-genealogy' returns the full genealogy of a given
+;; element or object, from closest parent to full parse tree.
 
-(defun org-export-get-parent-headline (blob info)
+(defun org-export-get-parent (blob)
+  "Return BLOB parent or nil.
+BLOB is the element or object considered."
+  (org-element-property :parent blob))
+
+(defun org-export-get-genealogy (blob)
+  "Return full genealogy relative to a given element or object.
+BLOB is the element or object being considered."
+  (let (genealogy (parent blob))
+    (while (setq parent (org-element-property :parent parent))
+      (push parent genealogy))
+    (nreverse genealogy)))
+
+(defun org-export-get-parent-headline (blob)
   "Return BLOB parent headline or nil.
-BLOB is the element or object being considered.  INFO is a plist
-used as a communication channel."
-  (catch 'exit
-    (mapc
-     (lambda (el) (when (eq (org-element-type el) 'headline) (throw 'exit el)))
-     (org-export-get-genealogy blob info))
-    nil))
-
-(defun org-export-get-parent-paragraph (object info)
-  "Return OBJECT parent paragraph or nil.
-OBJECT is the object to consider.  INFO is a plist used as
-a communication channel."
-  (catch 'exit
-    (mapc
-     (lambda (el) (when (eq (org-element-type el) 'paragraph) (throw 'exit el)))
-     (org-export-get-genealogy object info))
-    nil))
-
-(defun org-export-get-parent-table (object info)
+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))
+
+(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))
+
+(defun org-export-get-parent-table (object)
   "Return OBJECT parent table or nil.
-OBJECT is either a `table-cell' or `table-element' type object.
-INFO is a plist used as a communication channel."
-  (catch 'exit
-    (mapc
-     (lambda (el) (when (eq (org-element-type el) 'table) (throw 'exit el)))
-     (org-export-get-genealogy object info))
-    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))
 
-(defun org-export-get-previous-element (blob info)
+(defun org-export-get-previous-element (blob)
   "Return previous element or object.
-
-BLOB is an element or object.  INFO is a plist used as
-a communication channel.
-
-Return previous element or object, a string, or nil."
-  (let ((parent (org-export-get-parent blob info)))
+BLOB is an element or object.  Return previous element or object,
+a string, or nil."
+  (let ((parent (org-export-get-parent blob)))
     (cadr (member blob (reverse (org-element-contents parent))))))
 
-(defun org-export-get-next-element (blob info)
+(defun org-export-get-next-element (blob)
   "Return next element or object.
-
-BLOB is an element or object.  INFO is a plist used as
-a communication channel.
-
-Return next element or object, a string, or nil."
-  (let ((parent (org-export-get-parent blob info)))
+BLOB is an element or object.  Return next element or object,
+a string, or nil."
+  (let ((parent (org-export-get-parent blob)))
     (cadr (member blob (org-element-contents parent)))))