Function: org-attach-expand-links

org-attach-expand-links is a byte-compiled function defined in org-attach.el.gz.

Signature

(org-attach-expand-links _)

Documentation

Expand links in current buffer.

It is meant to be added to org-export-before-parsing-hook.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-attach.el.gz
(defun org-attach-expand-links (_)
  "Expand links in current buffer.
It is meant to be added to `org-export-before-parsing-hook'."
  (save-excursion
    (while (re-search-forward "attachment:" nil t)
      (let ((link (org-element-context)))
	(when (and (org-element-type-p link 'link)
		   (string-equal "attachment"
				 (org-element-property :type link)))
	  (let* ((description (and (org-element-contents-begin link)
				   (buffer-substring-no-properties
				    (org-element-contents-begin link)
				    (org-element-contents-end link))))
		 (file (org-element-property :path link))
		 (new-link (org-link-make-string
			    (concat "file:" (org-attach-expand file))
			    description)))
	    (goto-char (org-element-end link))
	    (skip-chars-backward " \t")
	    (delete-region (org-element-begin link) (point))
	    (insert new-link)))))))