From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uKnZD97foWIRSQEAbAwnHQ (envelope-from ) for ; Thu, 09 Jun 2022 13:56:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iB6zD97foWLa3wAAauVa8A (envelope-from ) for ; Thu, 09 Jun 2022 13:56:14 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EE9FF8483 for ; Thu, 9 Jun 2022 13:56:13 +0200 (CEST) Received: from localhost ([::1]:43532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGlo-0005o8-ND for larch@yhetil.org; Thu, 09 Jun 2022 07:56:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzEbR-0007Fj-KP for emacs-orgmode@gnu.org; Thu, 09 Jun 2022 05:37:21 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzEbN-0002Hn-Qr for emacs-orgmode@gnu.org; Thu, 09 Jun 2022 05:37:21 -0400 Received: by mail-pl1-x635.google.com with SMTP id o6so14741889plg.2 for ; Thu, 09 Jun 2022 02:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=KLjV5mZ3b+EyLflCSGaie4KQ+jAMo2kMNOfh8qlhsfM=; b=qfkZD3zdOIAdgb7wsxjsNBruysRx3nIoCmycfs4tvTS6BMuyNqXyoZeyz7iKQzmyLl MIuCqXkf8v/JlJRQorp06+M6/6Yxn3FhkxPVgOvh0VNOngYE0O7t1Wqa5aqgIxLnoqDe adQ4maZGnApQ/53Vr+DfhxgmvHtgbf7uCQ4JlC70RG4lUtqecukJuQTU36Cr0cL/Oemp bL20IuY1cw1JjhYsWaOoQxfNQaV/RvgkhZw1b0NC5SL9iMYereem6p5oRKBQL3tOwbPY cLA/zreNzys3Mv9eEgmEdav4haSEAK4p6lwIP2wOo6HLkt8lKSIDFZoQauKNhnWZ7ldv BUUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=KLjV5mZ3b+EyLflCSGaie4KQ+jAMo2kMNOfh8qlhsfM=; b=FNjTZzC8BQ+son35BnlPf/DaeqNa6u2MRND3wyaJAtTnuup14M1LZYsCcWKKHJ7kfH gysOmt1+r+FrpdG4kDyLrs9A7jEqWSGq5jtxrRaZJ0lbISP43eR4bFJoZtqdgd3V4KIM YQvMJC1wXhSNhB/rcUgV6ekL8xpylD3jwbahBrm5WiTi8WUoJNcQshD4grLSQZfNGR5d Gh7EKEJcaGnoVkEkHV+p5hSpW0vXdN7J7cJyRUz6AXp6F+OSFJ7fKx0UqvUmwA8IPoYw w4rTgPfs88YXXalzkcbfB0IxFgcjmRemo9wx2wU91BVNLhwmgB5OOjntyGJi6vOWIthF Q44A== X-Gm-Message-State: AOAM532rvkjYbltG5jt09yyfkPkxhL3LvL4H5KsxfEg8MgzwHgoIL61r 4mycZJbORMIQ429MOCyq/P0= X-Google-Smtp-Source: ABdhPJwL5Wu/4E6xRkTvk6LCQO8Aqm/fFWEQrKd/qdnHHEarDpunGhCTVJNn35D6ggXMRaP9DyMIhw== X-Received: by 2002:a17:902:aa8f:b0:168:b18c:5e16 with SMTP id d15-20020a170902aa8f00b00168b18c5e16mr30193plr.64.1654767435494; Thu, 09 Jun 2022 02:37:15 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id 187-20020a6204c4000000b0051bc721b838sm15018415pfe.188.2022.06.09.02.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:37:14 -0700 (PDT) From: Ihor Radchenko To: Cletip Cletip Cc: Org Mode List Subject: [PATCH] Re: Org-attach for a directory In-Reply-To: References: <87h74vcux5.fsf@ucl.ac.uk> Date: Thu, 09 Jun 2022 17:37:53 +0800 Message-ID: <87czfii3da.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=yantar92@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654775774; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=KLjV5mZ3b+EyLflCSGaie4KQ+jAMo2kMNOfh8qlhsfM=; b=ZmHHvTlTaiZXUlah/lBBq1gpb8/vezCHNbGmdGtMwbAf3QanFFAJiDyU346nq2aeOI78FR 2+Snul99iVSzs+71ZqUhJL1efn820omo4oFWu4WxWpAVLya54PRIewFkN/bvI9+WHEc6jH wkIYJ/dK1J3PIqyVAY/GzBxxxrh1j23pZBjLUBu7RHYdSo/POg11ASwmedGkb1GJOPCsph ZwDc6LkznAJ9q7kz8MJzxs7zpAKZZLfJSC6LMe5F3bh+7Bvilt4wGJANkEgYChnSNaiVsu SZ3W/9ZKuSELlVQXwIasqOFIty4hBRsWV+5LSpkmbHtPEZXiy3Q41QE1UAWGyA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654775774; a=rsa-sha256; cv=none; b=FvZoBMp/YRtLvxIfKmsfluLzimTiNrl+0l7bpb+KRAiKPvQEfidL70weFQQVY9juuDYzRp sAd8A+AoMuzgdCeOCAMb8SsCkkb37FF9VHH/j5eVm8X9hZct5dfel9O9JWm7Wt4KVC1lrF kCxaB2NSPP5e+cdR20dB/Gl7AKkofFafCmfqQl6bIBoUm4AlsFywIX8WybFgz0ZlJNuPhi z9MKTNd7XH5oibS143DBcVhd8GRn8HyLbq/M2VqS18YddoyHJNzCYeO81rFKIW+RQnQpJR vzEHayQR4Gwh+57EaapZ979gLkMndRWdsKZf5VGidL+WyBuhHdIGmUg2sud44w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qfkZD3zd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -8.81 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qfkZD3zd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: EE9FF8483 X-Spam-Score: -8.81 X-Migadu-Scanner: scn0.migadu.com X-TUID: GY2r4lcVWkHM --=-=-= Content-Type: text/plain Cletip Cletip 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-attach-attach-Allow-attaching-directories-using-.patch >From 6d879aeca5d1c52a824df998704298d9ee4a4a0a Mon Sep 17 00:00:00 2001 Message-Id: <6d879aeca5d1c52a824df998704298d9ee4a4a0a.1654767374.git.yantar92@gmail.com> From: Ihor Radchenko 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 --=-=-=--