Function: org-export--update-included-link
org-export--update-included-link is a byte-compiled function defined
in ox.el.gz.
Signature
(org-export--update-included-link FILE-DIR INCLUDER-DIR)
Documentation
Update relative file name of link at point, if possible.
FILE-DIR is the directory of the file being included. INCLUDER-DIR is the directory of the file where the inclusion is going to happen.
Move point after the link.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export--update-included-link (file-dir includer-dir)
"Update relative file name of link at point, if possible.
FILE-DIR is the directory of the file being included.
INCLUDER-DIR is the directory of the file where the inclusion is
going to happen.
Move point after the link."
(let* ((link (org-element-link-parser))
(path (org-element-property :path link)))
(if (or (not (string= "file" (org-element-property :type link)))
(file-remote-p path)
(file-name-absolute-p path))
(goto-char (org-element-property :end link))
(let ((new-path (file-relative-name (expand-file-name path file-dir)
includer-dir))
(new-link (org-element-copy link)))
(org-element-put-property new-link :path new-path)
(when (org-element-property :contents-begin link)
(org-element-adopt-elements new-link
(buffer-substring
(org-element-property :contents-begin link)
(org-element-property :contents-end link))))
(delete-region (org-element-property :begin link)
(org-element-property :end link))
(insert (org-element-interpret-data new-link))))))