summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustav Wikström <gustav@whil.se>2020-01-15 20:40:24 +0100
committerGustav Wikström <gustav@whil.se>2020-01-15 20:40:24 +0100
commitf93020d5e6d7594c335cc129ad02c21ac26ed58a (patch)
treee92ca79c68875da3602d48c6ffdc20259d57a2fa
parent0ac6a9e1fcb71415df5ce287d4658f6a601b3df3 (diff)
downloadorg-mode-f93020d5e6d7594c335cc129ad02c21ac26ed58a.tar.gz
Expand attachment links with point in correct place
* lisp/ox-texinfo.el (org-texinfo-link) * lisp/ox-odt.el (org-odt-link) * lisp/ox-md.el (org-md-link) * lisp/ox-man.el (org-man-link) * lisp/ox-latex.el (org-latex--inline-image, org-latex-link) * lisp/ox-html.el (org-html-link) * lisp/ox-ascii.el (org-ascii-link): Move point to the link for org-attach-expand to know from which headline to expand the link.
-rw-r--r--lisp/ox-ascii.el4
-rw-r--r--lisp/ox-html.el4
-rw-r--r--lisp/ox-latex.el8
-rw-r--r--lisp/ox-man.el4
-rw-r--r--lisp/ox-md.el4
-rw-r--r--lisp/ox-odt.el4
-rw-r--r--lisp/ox-texinfo.el4
7 files changed, 24 insertions, 8 deletions
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index bcd62e9..9d71688 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1580,7 +1580,9 @@ INFO is a plist holding contextual information."
(raw-path (org-element-property :path link))
(path (cond
((string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path)))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path))))
(concat type ":" raw-path))
(t (concat type ":" raw-path)))))
(cond
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index aafeb69..be33aea 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3081,7 +3081,9 @@ INFO is a plist holding contextual information. See
(url-encode-url (concat type ":" raw-path)))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
;; During publishing, turn absolute file names belonging
;; to base directory into relative file names. Otherwise,
;; append "file" protocol to absolute file name.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 7758abd..c297cbf 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2363,7 +2363,9 @@ used as a communication channel."
(let* ((parent (org-export-get-parent-element link))
(path (let ((raw-path (org-element-property :path link)))
(when (string= (org-element-property :type link) "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(if (not (file-name-absolute-p raw-path)) raw-path
(expand-file-name raw-path))))
(filetype (file-name-extension path))
@@ -2536,7 +2538,9 @@ INFO is a plist holding contextual information. See
(concat type ":" raw-path))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(org-export-file-uri raw-path))
(t
raw-path)))))
diff --git a/lisp/ox-man.el b/lisp/ox-man.el
index c98f0cd..37e5d76 100644
--- a/lisp/ox-man.el
+++ b/lisp/ox-man.el
@@ -624,7 +624,9 @@ INFO is a plist holding contextual information. See
(concat type ":" raw-path))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(org-export-file-uri raw-path))
(t raw-path))))
(cond
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index d050430..d18d075 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -413,7 +413,9 @@ INFO is a plist holding contextual information. See
(concat type ":" raw-path))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(org-export-file-uri (funcall link-org-files-as-md raw-path)))
(t raw-path))))
(cond
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index e0def39..b7dc56f 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2714,7 +2714,9 @@ INFO is a plist holding contextual information. See
(concat type ":" raw-path))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(org-export-file-uri raw-path))
(t raw-path)))
;; Convert & to &amp; for correct XML representation
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 177007b..85c9798 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -1066,7 +1066,9 @@ INFO is a plist holding contextual information. See
(concat type ":" raw-path))
((string= type "file")
(when (string= raw-type "attachment")
- (setq raw-path (file-relative-name (org-attach-expand raw-path))))
+ (setq raw-path (file-relative-name
+ (org-with-point-at (org-element-property :begin link)
+ (org-attach-expand raw-path)))))
(org-export-file-uri raw-path))
(t raw-path))))
(cond