DnD: Create directory when `org-yank-image-save-method' is a directory

* lisp/org.el (org--dnd-attach-file): Make sure that target directory
is created before copying file when `org-yank-image-save-method' is
set to specific directory (not 'attach).

Reported-by: ISouthRain <isouthrain@qq.com>
Link: https://orgmode.org/list/tencent_AABB2DEBF7ABFBC795348C288E0EBFCFDD0A@qq.com
This commit is contained in:
Ihor Radchenko 2024-06-13 18:01:37 +02:00
parent 96113f3b59
commit d7b5c19daa
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 12 additions and 9 deletions

View File

@ -20941,15 +20941,18 @@ SEPARATOR is the string to insert after each link."
('private (or org-yank-dnd-default-attach-method
org-attach-method)))))
(if separatep
(funcall
(pcase method
('cp #'copy-file)
('mv #'rename-file)
('ln #'add-name-to-file)
('lns #'make-symbolic-link))
filename
(expand-file-name (file-name-nondirectory filename)
org-yank-image-save-method))
(progn
(unless (file-directory-p org-yank-image-save-method)
(make-directory org-yank-image-save-method t))
(funcall
(pcase method
('cp #'copy-file)
('mv #'rename-file)
('ln #'add-name-to-file)
('lns #'make-symbolic-link))
filename
(expand-file-name (file-name-nondirectory filename)
org-yank-image-save-method)))
(org-attach-attach filename nil method))
(insert
(org-link-make-string