From: Ihor Radchenko <yantar92@gmail.com>
To: Cletip Cletip <clement020302@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: [PATCH] Re: Org-attach for a directory
Date: Thu, 09 Jun 2022 17:37:53 +0800 [thread overview]
Message-ID: <87czfii3da.fsf@localhost> (raw)
In-Reply-To: <CAPHku6NO+EgNx9s8Ojq1-Tu=pb9_M7gAwkjYRZFoC6ONEjpbGQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 581 bytes --]
Cletip Cletip <clement020302@gmail.com> writes:
> Thank you for your answer.
> Unfortunately, I would like to copy the entire directory.
> To clarify my second question, I would like to have a folder system with
> org-mode, and therefore only use org-attach to store my documents
Note that it makes much more sense to use 'mv method when you actually
use attachments as your filesystem. There is no need to keep trailing
garbage files. 'mv methods works for directories.
As for the 'cp method, it does not work for directories on current main.
The fix is attached.
Best,
Ihor
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-attach-attach-Allow-attaching-directories-using-.patch --]
[-- Type: text/x-patch, Size: 1573 bytes --]
From 6d879aeca5d1c52a824df998704298d9ee4a4a0a Mon Sep 17 00:00:00 2001
Message-Id: <6d879aeca5d1c52a824df998704298d9ee4a4a0a.1654767374.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Thu, 9 Jun 2022 17:33:49 +0800
Subject: [PATCH] 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.
---
lisp/org-attach.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5ee2b84b2..00919bef8 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -517,12 +517,17 @@ (defun org-attach-attach (file &optional visit-dir method)
current-prefix-arg
nil))
(setq method (or method org-attach-method))
+ (when (file-directory-p file)
+ (setq file (directory-file-name file)))
(let ((basename (file-name-nondirectory file)))
(let* ((attach-dir (org-attach-dir 'get-create))
(attach-file (expand-file-name basename attach-dir)))
(cond
((eq method 'mv) (rename-file file attach-file))
- ((eq method 'cp) (copy-file file attach-file))
+ ((eq method 'cp)
+ (if (file-directory-p file)
+ (copy-directory file attach-file nil nil t)
+ (copy-file file attach-file)))
((eq method 'ln) (add-name-to-file file attach-file))
((eq method 'lns) (make-symbolic-link file attach-file))
((eq method 'url) (url-copy-file file attach-file)))
--
2.35.1
next prev parent reply other threads:[~2022-06-09 11:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 9:59 Org-attach for a directory Cletip Cletip
2022-06-08 10:27 ` Fraga, Eric
2022-06-08 19:48 ` Cletip Cletip
2022-06-09 9:37 ` Ihor Radchenko [this message]
2022-07-21 11:24 ` [PATCH] " Ihor Radchenko
2022-07-21 13:51 ` Cletip Cletip
2022-06-08 10:32 ` Juan Manuel Macías
[not found] ` <CAPHku6O3RojzhaSu3d2pWfnE8x7N_9WAfjCupHyKcxNyD-i=ew@mail.gmail.com>
2022-06-09 10:11 ` Juan Manuel Macías
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87czfii3da.fsf@localhost \
--to=yantar92@gmail.com \
--cc=clement020302@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).