Function: org-export--install-footnote-definitions
org-export--install-footnote-definitions is a byte-compiled function
defined in ox.el.gz.
Signature
(org-export--install-footnote-definitions DEFINITIONS TREE)
Documentation
Install footnote definitions in tree.
DEFINITIONS is the list of footnote definitions to install. TREE is the parse tree.
If there is a footnote section in TREE, definitions found are
appended to it. If org-footnote-section is non-nil, a new
footnote section containing all definitions is inserted in TREE.
Otherwise, definitions are appended at the end of the section
containing their first reference.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export--install-footnote-definitions (definitions tree)
"Install footnote definitions in tree.
DEFINITIONS is the list of footnote definitions to install. TREE
is the parse tree.
If there is a footnote section in TREE, definitions found are
appended to it. If `org-footnote-section' is non-nil, a new
footnote section containing all definitions is inserted in TREE.
Otherwise, definitions are appended at the end of the section
containing their first reference."
(cond
((null definitions))
;; If there is a footnote section, insert definitions there.
((let ((footnote-section
(org-element-map tree 'headline
(lambda (h) (and (org-element-property :footnote-section-p h) h))
nil t)))
(and footnote-section
(apply #'org-element-adopt
footnote-section
(nreverse definitions)))))
;; If there should be a footnote section, create one containing all
;; the definitions at the end of the tree.
(org-footnote-section
(org-element-adopt
tree
(org-element-create 'headline
(list :footnote-section-p t
:level 1
:title org-footnote-section
:raw-value org-footnote-section)
(apply #'org-element-create
'section
nil
(nreverse definitions)))))
;; Otherwise add each definition at the end of the section where it
;; is first referenced.
(t
(letrec ((seen nil)
(insert-definitions
(lambda (data)
;; Insert footnote definitions in the same section as
;; their first reference in DATA.
(org-element-map data 'footnote-reference
(lambda (reference)
(when (eq (org-element-property :type reference) 'standard)
(let ((label (org-element-property :label reference)))
(unless (member label seen)
(push label seen)
(let ((definition
(cl-some
(lambda (d)
(and (equal (org-element-property :label d)
label)
d))
definitions)))
(org-element-adopt
(org-element-lineage reference 'section)
definition)
;; Also insert definitions for nested
;; references, if any.
(funcall insert-definitions definition))))))))))
(funcall insert-definitions tree)))))