From 2d22d7f515ef9e5e69b5265b11ac940a1793bc12 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 18 May 2023 13:33:15 +0200 Subject: [PATCH] ox.el: Rename `org-element-get-parent-element' and move to org-element * lisp/org-element.el: Rename `org-element-get-parent-element' to `org-element-parent-element'. * lisp/org-compat.el (org-export-get-parent-element): * lisp/ox.el (org-export-get-parent-element): Remove, adding obsolete alias. (org-export--skip-p): * lisp/org-table.el: * lisp/ox-beamer.el (org-beamer-link): * lisp/ox-html.el (org-html-link): * lisp/ox-latex.el (org-latex-footnote-reference): * lisp/ox-md.el (org-md-link): * lisp/ox-odt.el (org-odt-format-label): (org-odt-link--inline-image): (org-odt-link--inline-formula): * lisp/ox-texinfo.el (org-texinfo--inline-image): Update all the callers. --- lisp/org-compat.el | 5 ++++- lisp/org-element.el | 5 +++++ lisp/org-table.el | 2 +- lisp/ox-beamer.el | 2 +- lisp/ox-html.el | 2 +- lisp/ox-latex.el | 4 ++-- lisp/ox-md.el | 2 +- lisp/ox-odt.el | 8 ++++---- lisp/ox-texinfo.el | 2 +- lisp/ox.el | 9 ++------- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 226f97f58..edbbcdebb 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1134,7 +1134,10 @@ 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") +(define-obsolete-function-alias 'org-export-get-parent + 'org-element-parent "9.7") +(define-obsolete-function-alias 'org-export-get-parent-element + 'org-element-parent-element "9.7") ;;;; Obsolete link types diff --git a/lisp/org-element.el b/lisp/org-element.el index e4597b955..8b91bf2c3 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -544,6 +544,11 @@ value of DATUM `:parent' property." ((org-element-secondary-p datum) 'object) (t 'element))))))) +(defsubst org-element-parent-element (object) + "Return first element containing OBJECT or nil. +OBJECT is the object to consider." + (org-element-lineage object org-element-all-elements)) + (defconst org-element--cache-element-properties '(:cached :org-element--cache-sync-key diff --git a/lisp/org-table.el b/lisp/org-table.el index 554c3b138..0e615f835 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5954,7 +5954,7 @@ information." (let ((headerp ,(and (or hfmt hsep) '(org-export-table-row-in-header-p - (org-export-get-parent-element cell) info))) + (org-element-parent-element cell) info))) (column ;; Call costly `org-export-table-cell-address' only if ;; absolutely necessary, i.e., if one diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index 2f83a6766..c2aa70aeb 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -740,7 +740,7 @@ used as a communication channel." ;; Fall-back to LaTeX export. However, prefer "\hyperlink" over ;; "\hyperref" since the former handles overlay specifications. (let* ((latex-link (org-export-with-backend 'latex link contents info)) - (parent (org-export-get-parent-element link)) + (parent (org-element-parent-element link)) (attr (org-export-read-attribute :attr_beamer parent)) (overlay (plist-get attr :overlay))) (cond ((string-match "\\`\\\\hyperref\\[\\(.*?\\)\\]" latex-link) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 2ae76be27..ff0dac844 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3247,7 +3247,7 @@ INFO is a plist holding contextual information. See ;; do this for the first link in parent (inner image link ;; 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)) + (let* ((parent (org-element-parent-element link)) (link (let ((container (org-element-parent link))) (if (and (org-element-type-p container 'link) (org-html-inline-image-p link info)) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index d93659739..8f8feb4ce 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2217,7 +2217,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." '(footnote-reference footnote-definition table-cell verse-block)) (org-element-type-p - (org-export-get-parent-element footnote-reference) 'item)) + (org-element-parent-element footnote-reference) 'item)) "\\footnotemark") ;; Otherwise, define it with \footnote command. (t @@ -2708,7 +2708,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-element link)) + (let* ((parent (org-element-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)))) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 5af9bbca8..ba8bf4a79 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -590,7 +590,7 @@ INFO is a plist holding contextual information. See (t (expand-file-name raw-path)))) (caption (org-export-data (org-export-get-caption - (org-export-get-parent-element link)) + (org-element-parent-element link)) info))) (format "![img](%s)" (if (not (org-string-nw-p caption)) path diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 9dd73f9e0..9c6e79a9b 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2081,7 +2081,7 @@ SHORT-CAPTION are strings." (cl-assert (org-element-type-p element '(link table src-block paragraph))) (let* ((element-or-parent (cl-case (org-element-type element) - (link (org-export-get-parent-element element)) + (link (org-element-parent-element element)) (t element))) ;; Get label and caption. (label (and (or (org-element-property :name element) @@ -2259,7 +2259,7 @@ used as a communication channel." (org-odt--copy-image-file src-expanded))) ;; Extract attributes from #+ATTR_ODT line. (attr-from (cl-case (org-element-type element) - (link (org-export-get-parent-element element)) + (link (org-element-parent-element element)) (t element))) ;; Convert attributes to a plist. (attr-plist (org-export-read-attribute :attr_odt attr-from)) @@ -2297,7 +2297,7 @@ used as a communication channel." ;; Check if this link was created by LaTeX-to-PNG converter. (replaces (org-element-property :replaces (if (not standalone-link-p) element - (org-export-get-parent-element element)))) + (org-element-parent-element element)))) ;; If yes, note down the type of the element - LaTeX Fragment ;; or LaTeX environment. It will go in to frame title. (title (and replaces (capitalize @@ -2333,7 +2333,7 @@ used as a communication channel." ;; converter. (replaces (org-element-property :replaces (if (not standalone-link-p) element - (org-export-get-parent-element element)))) + (org-element-parent-element element)))) ;; If yes, note down the type of the element - LaTeX Fragment ;; or LaTeX environment. It will go in to frame title. (title (and replaces (capitalize diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 6fdc0feeb..ad10387a2 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1370,7 +1370,7 @@ INFO is a plist holding contextual information. See "Return Texinfo code for an inline image. LINK is the link pointing to the inline image. INFO is the current state of the export, as a plist." - (let* ((parent (org-export-get-parent-element link)) + (let* ((parent (org-element-parent-element link)) (label (and (org-element-property :name parent) (org-texinfo--get-node parent info))) (caption (org-export-get-caption parent)) diff --git a/lisp/ox.el b/lisp/ox.el index efd36bd2f..d33520aee 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1850,7 +1850,7 @@ not exported." ;; `:with-timestamps' only applies to isolated timestamps ;; objects, i.e. timestamp objects in a paragraph containing only ;; timestamps and whitespaces. - (when (let ((parent (org-export-get-parent-element datum))) + (when (let ((parent (org-element-parent-element datum))) (and (org-element-type-p parent '(paragraph verse-block)) (not (org-element-map parent (cons 'plain-text @@ -6031,7 +6031,7 @@ Return the new string." ;; Here are various functions to retrieve information about the ;; neighborhood of a given element or object. Neighbors of interest ;; are parent headline (`org-export-get-parent-headline'), first -;; element containing an object, (`org-export-get-parent-element'), +;; element containing an object, (`org-element-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'). @@ -6041,11 +6041,6 @@ Return the new string." BLOB is the element or object being considered." (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." - (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."