Skip to content

Commit d2a110f

Browse files
committed
org-attach-attach: Allow attaching directories using 'cp method
* lisp/org-attach.el (org-attach-attach): Use `copy-directory' when FILE is a directory. Remove trailing slash before processing.
1 parent db6c229 commit d2a110f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lisp/org-attach.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,17 @@ METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from
520520
current-prefix-arg
521521
nil))
522522
(setq method (or method org-attach-method))
523+
(when (file-directory-p file)
524+
(setq file (directory-file-name file)))
523525
(let ((basename (file-name-nondirectory file)))
524526
(let* ((attach-dir (org-attach-dir 'get-create))
525527
(attach-file (expand-file-name basename attach-dir)))
526528
(cond
527529
((eq method 'mv) (rename-file file attach-file))
528-
((eq method 'cp) (copy-file file attach-file))
530+
((eq method 'cp)
531+
(if (file-directory-p file)
532+
(copy-directory file attach-file nil nil t)
533+
(copy-file file attach-file)))
529534
((eq method 'ln) (add-name-to-file file attach-file))
530535
((eq method 'lns) (make-symbolic-link file attach-file 1))
531536
((eq method 'url)

0 commit comments

Comments
 (0)