Merge branch 'bugfix'

This commit is contained in:
Ihor Radchenko 2022-12-07 14:15:31 +03:00
commit 06648d43e4
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 22 additions and 3 deletions

View File

@ -2691,8 +2691,8 @@ specified as an an \"attachment:\" style link."
(same-directory?
(and base-file-name
(not (string= (expand-file-name default-directory)
(expand-file-name
base-directory)))))
(expand-file-name
base-directory)))))
(request-attachment (eq type 'attachment))
(attach-dir (let* ((default-directory base-directory)
(dir (org-attach-dir nil t)))
@ -2708,7 +2708,9 @@ specified as an an \"attachment:\" style link."
((and 'attachment (guard in-attach-dir)) "attachment")
(_ "file"))
(if (and request-attachment in-attach-dir)
(file-relative-name result-file-name)
(file-relative-name
result-file-name
(file-name-as-directory attach-dir))
(if (and default-directory
base-file-name same-directory?)
(if (eq org-link-file-path-type 'adaptive)

View File

@ -1954,6 +1954,23 @@ nil
(file-exists-p (format "%s/test.txt" (org-attach-dir nil t)))
(string= (buffer-substring-no-properties (point) (line-end-position))
"[[attachment:test.txt]]"))))
;; Strip attach dir from the file path.
(should
(org-test-with-temp-text-in-file
"* heading
:PROPERTIES:
:DIR: custom-attach-dir
:END:
<point>#+begin_src elisp :results value file
\"custom-attach-dir/test.txt\"
#+end_src"
(message "DIR: %s" (org-attach-dir t))
(org-babel-execute-src-block)
(goto-char (org-babel-where-is-src-block-result))
(forward-line)
(string= (buffer-substring-no-properties (point) (line-end-position))
"[[attachment:test.txt]]")))
(should-error
(org-test-with-temp-text-in-file
"* 'attach with no ID or DIR