summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstardiviner <numbchild@gmail.com>2018-03-06 14:41:20 +0800
committerstardiviner <numbchild@gmail.com>2018-03-06 14:43:22 +0800
commit49a8de4ffd2d0fc50c975ff3edac15d2bb37a809 (patch)
tree621c21738e51e9e260b0e0ba05cf278c3c332f0b
parent881da595dda494ce27b0c4679c2224693eedba7c (diff)
downloadorg-mode-49a8de4ffd2d0fc50c975ff3edac15d2bb37a809.tar.gz
* ob-core.el (org-babel-result-to-file): relative file link result.
Respect option `org-link-file-path-type`.
-rw-r--r--lisp/ob-core.el21
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f84b9f1..b7ffda0 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2500,15 +2500,18 @@ in the buffer."
If the `default-directory' is different from the containing
file's directory then expand relative links."
(when (stringp result)
- (format "[[file:%s]%s]"
- (if (and default-directory
- buffer-file-name
- (not (string= (expand-file-name default-directory)
- (expand-file-name
- (file-name-directory buffer-file-name)))))
- (expand-file-name result default-directory)
- result)
- (if description (concat "[" description "]") ""))))
+ (let ((same-directory? (not (string= (expand-file-name default-directory)
+ (expand-file-name
+ (file-name-directory buffer-file-name))))))
+ (format "[[file:%s]%s]"
+ (if (and default-directory buffer-file-name same-directory?)
+ (if (eq org-link-file-path-type 'adaptive)
+ (file-relative-name
+ (expand-file-name result default-directory)
+ (file-name-directory (buffer-file-name)))
+ (expand-file-name result default-directory))
+ result)
+ (if description (concat "[" description "]") "")))))
(defun org-babel-examplify-region (beg end &optional results-switches inline)
"Comment out region using the inline `==' or `: ' org example quote."