From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id hiNJL5obwGAKkAAAgWs5BA (envelope-from ) for ; Wed, 09 Jun 2021 03:38:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oGcZKpobwGA4KwAA1q6Kng (envelope-from ) for ; Wed, 09 Jun 2021 01:38:34 +0000 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 185CA23CB1 for ; Wed, 9 Jun 2021 03:38:34 +0200 (CEST) Received: from localhost ([::1]:55776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqnAu-00015s-Nh for larch@yhetil.org; Tue, 08 Jun 2021 21:38:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqnAX-000151-Up for emacs-orgmode@gnu.org; Tue, 08 Jun 2021 21:38:10 -0400 Received: from mout01.posteo.de ([185.67.36.65]:39505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqnAV-0003vp-Dw for emacs-orgmode@gnu.org; Tue, 08 Jun 2021 21:38:09 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 1C04C240026 for ; Wed, 9 Jun 2021 03:38:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1623202684; bh=MM3tIg57D2ov9JZO50/eDLAn/JKNUWZIw3Df4NOlVVg=; h=From:To:Cc:Subject:Date:From; b=fCtaEH3IV4YlJkPEt2U6ZwrhZ1IkuqDHOyZhblxQddK/MHLo6roKz4KWeexAy4zj6 mgWDalaWHt4NH9yL2tAS/IfWcsg+Qkgp75qhmvjs8O1Dlj6KpI9/Nu+fjFrMokF2no kAbqByK3tLXZZeRgOxAwH5sYWOFzhgsIJa9svfeDyUOvtKuPi1QA5t+y2lrrdobjQC TWZq4fPXanz9hhjeM1ZJCRhRYjHYY5oiPl02gFr83X8bRa63U7bhJFN7vAEC832C2I gKSxwqzPxvLJ/RFeQVT84tHp83kpvQJLwVZUesmSYO4DJpw67rCcs3e9W4lKST98tA QYmnHYAQde4fg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4G08rB5XW5z6tmJ; Wed, 9 Jun 2021 03:38:02 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: John Kitchin Subject: [patch] Re: org-attach a directory? References: Date: Wed, 09 Jun 2021 01:38:01 +0000 In-Reply-To: (John Kitchin's message of "Tue, 8 Jun 2021 16:41:17 -0400") Message-ID: <874ke7x1fq.fsf_-_@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1623202714; 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=iYXBURyMuTVuCNzcGeVS0cg4aINPXD/fng8K/8CIOsQ=; b=NE7NwYjtbQDZq65J8eugZY6FXW2QNBrCbbGvcpuOjqP8D44pKxID1ywcU2wygBS49PyXBl AUM1ThL6btz7igDBX/bn8XfHhDECQ8LcFJsMUYlKVFmGlVFAqALgkv5rd/eRPzQdjDeQ4W r0/crBaY9plTVgwIXNebS29wQXeYRKXEvV31p0D0cc21sGWlg3+0EdreIM7yWX8QRB1H8C 6cjFUkcWbhgxd6ep3UunnCnMqTyvcr64Wf2R3zXFqEgu9fdtsKzSWN6bYnH+VR4rBtQNfX YjOiWUfX0vja78mDUn0RkwUPdn2Jz7QBQnEH/oT2b6wMHgTcwL2pdpWmwrgw1g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623202714; a=rsa-sha256; cv=none; b=X+3DlY35X4gGlqPThtutkU5ZIdaumJ0KQriU5oEEXklhG+9aYrKrVnD/DA6tTAOMKfAk88 GPUEISu48wIy+UZaUhVB6MuUSnnf5N+o8TepdwJGa57WvSLkLNkj2o7xYsfjo9j6Qi55ic CYBfCPb+ymbbk9hJYJ+AEp4JNJdsR1Fpbu1Y8pSt26ALbj/tEtrfgbR1FZ4Ctm7is6VDVW BgObCwIs75Gp1OOzLYEBwNDqDamitswC+S4sUkNb/tqk6F/kuzpaNBf2I8Ten3JtKRszcM FkhorLv97OVp//5Q/pdol3b2hU21uTAHxogPacar7Oslu0ma6Ckloy8YydGnTw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fCtaEH3I; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fCtaEH3I; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 185CA23CB1 X-Spam-Score: -2.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: SQ6ngUNiPMPe --=-=-= Content-Type: text/plain Hi John, John Kitchin writes: > I want to attach all the files in a directory on my desktop to the > attachment directory, something that is more like > org-attach-attach-mv-directory (that is not an existing command, but > what I was thinking of doing). Did I misunderstand what > org-attach-set-directory does? As far as I know, that option is not possible. And it's something that I've always missed in org-attach. I've written this possible patch, with two new attach methods/commands to copy or move a directory ("C" and "M"). I guess it would be better to use `read-file-name' and `read-directory-name' according to each case, but I can't think of how to solve that. Anyway, `read-file-name' may also apply here for directories. (Little tested). Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Org-attach.el-Add-two-new-methods-for-cp-or-mv-directories.patch >From 5a2f59a74c9b3f8ff1cf25777067780400f9043f Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Wed, 9 Jun 2021 03:03:50 +0200 Subject: [PATCH] Org-attach.el: Add two new methods for copying or moving directories * lisp/org-attach.el (org-attach-commands): add two new attachments commands (org-attach-attach): add two new attachment methods, argument `file' is ranamed as `target' (org-attach-attach-cp-dir): copy a directory (org-attach-attach-mv-dir): move (rename) a directory --- lisp/org-attach.el | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 715fe3e93..50b1dca3b 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -199,6 +199,10 @@ git-functionality from this file.") "Attach a file using copy method.") ((?m ?\C-m) org-attach-attach-mv "Attach a file using move method.") + ((?C ?\C-C) org-attach-attach-cp-dir + "Attach a directory using copy dir method.") + ((?M ?\C-M) org-attach-attach-mv-dir + "Attach a directory using move dir method.") ((?l ?\C-l) org-attach-attach-ln "Attach a file using link method.") ((?y ?\C-y) org-attach-attach-lns @@ -489,8 +493,8 @@ if it would overwrite an existing filename." (with-temp-file output (insert-buffer-substring buffer-name)))) -(defun org-attach-attach (file &optional visit-dir method) - "Move/copy/link FILE into the attachment directory of the current outline node. +(defun org-attach-attach (target &optional visit-dir method) + "Move/copy/link TARGET into the attachment directory of the current outline node. If VISIT-DIR is non-nil, visit the directory with dired. METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from `org-attach-method'." @@ -504,15 +508,20 @@ METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from current-prefix-arg nil)) (setq method (or method org-attach-method)) - (let ((basename (file-name-nondirectory file))) + (let ((basename (if (or (eq method 'mv-dir) + (eq method 'cp-dir)) + target + (file-name-nondirectory target)))) (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 '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))) + ((eq method 'mv) (rename-file target attach-file)) + ((eq method 'cp) (copy-file target attach-file)) + ((eq method 'mv-dir) (rename-file target (concat attach-dir "/"))) + ((eq method 'cp-dir) (copy-directory target (concat attach-dir "/"))) + ((eq method 'ln) (add-name-to-file target attach-file)) + ((eq method 'lns) (make-symbolic-link target attach-file)) + ((eq method 'url) (url-copy-file target attach-file))) (run-hook-with-args 'org-attach-after-change-hook attach-dir) (org-attach-tag) (cond ((eq org-attach-store-link-p 'attached) @@ -520,8 +529,8 @@ METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from (file-name-nondirectory attach-file)) org-stored-links)) ((eq org-attach-store-link-p t) - (push (list (concat "file:" file) - (file-name-nondirectory file)) + (push (list (concat "file:" target) + (file-name-nondirectory target)) org-stored-links)) ((eq org-attach-store-link-p 'file) (push (list (concat "file:" attach-file) @@ -539,6 +548,14 @@ METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from "Attach a file by moving (renaming) it." (interactive) (let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach))) +(defun org-attach-attach-cp-dir () + "Attach a directory by copying it." + (interactive) + (let ((org-attach-method 'cp-dir)) (call-interactively 'org-attach-attach))) +(defun org-attach-attach-mv-dir () + "Attach a directory by moving (renaming) it." + (interactive) + (let ((org-attach-method 'mv-dir)) (call-interactively 'org-attach-attach))) (defun org-attach-attach-ln () "Attach a file by creating a hard link to it. Beware that this does not work on systems that do not support hard links. -- 2.31.1 --=-=-=--