From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wFDmHEeZw2ADPgEAgWs5BA (envelope-from ) for ; Fri, 11 Jun 2021 19:11:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SFatGEeZw2CgLwAAB5/wlQ (envelope-from ) for ; Fri, 11 Jun 2021 17:11:35 +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 3ACDD19B83 for ; Fri, 11 Jun 2021 19:11:34 +0200 (CEST) Received: from localhost ([::1]:54142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrkgu-0004TP-5B for larch@yhetil.org; Fri, 11 Jun 2021 13:11:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrkgO-0004TE-6A for emacs-orgmode@gnu.org; Fri, 11 Jun 2021 13:11:00 -0400 Received: from mout01.posteo.de ([185.67.36.65]:50967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrkgL-0006QI-8z for emacs-orgmode@gnu.org; Fri, 11 Jun 2021 13:10:59 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id EB1EC240027 for ; Fri, 11 Jun 2021 19:10:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1623431455; bh=GnRmMyqN6fCiL7tezJ3n7SWqeImTa5iMB7IcoCps1qA=; h=From:To:Cc:Subject:Date:From; b=idjEgr2KekPTyKZRnVAfJ186slpOLWLJxbLtrvDYl88EFsrEUR9i4vdcAUC9Vhyxn 64mWEC7Fqp9nPhY9qmGbBT5R+S+SUm6ePL5ousGOiEGxzYUxMFrLert+bAYpVZDtX9 Q87yaHSaLbNgQTI91XgIhZq5AH98irVwjn3nNlzUVa8dZtHeeg/Jk94fXyh6MIoV5x /UhlOgfEurVos84C70sey2KOXp5ak2sY/ifS1sVlQwnbJk9MfBDJ5Ve7I8MBKahIyw F4CYcrkdP4xQosfmh8YXEF0oUmqkuNF4NtRHXh674VGr2kw+6EoDVvEGfYOLnb1GX2 T5E60H+hWRGYQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4G1nRd5L3hz9rxR; Fri, 11 Jun 2021 19:10:53 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: John Kitchin Subject: Re: org-attach a directory? References: <2459FA17-C27C-48E1-B9B5-74B13147D2C3@gmail.com> Date: Fri, 11 Jun 2021 17:10:52 +0000 In-Reply-To: (John Kitchin's message of "Fri, 11 Jun 2021 12:35:39 -0400") Message-ID: <87zgvwnx7n.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, URIBL_SBL_A=0.1 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=1623431494; 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=t4ARNhQeb1otE5kc0CCwzs87lrYQArPYwxIJfMwAioU=; b=sy5FkEgJ3XmP1Pekv/IpKZuTJjBvF5hZw+Gnxl4CnRxgzDMZc7qXP5xF3IUbb2P7PCbIbk XH60fq2aW2gVHr008K7PJ/9m0WzpsPxLI8ZSat7fog2CjnvSoSoPCfEbbQrpdhMQ8WRpHe r1+DYwnhQ7sOKe/yI0bvK3gZvjbz4OgrzKZr5SLfIblgeYSnP3oGxwT0etAmUSmz0CIyhh qqyiJTVqJwQIjczKP+C+MvVJ4SJXKCZPFqPUEEZZt2BFdax6xK4R0Umdk6aawrJYbdR5cY vmgsHjmw0PoLR7/GhKhw9UNT/eYxxZuZxrTS9zxiFHyqW0YY59LyAdNCQg5wpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623431494; a=rsa-sha256; cv=none; b=I7T6DhIIwKsmUttz95Rz+LfDzWbAXpfiaAKZToF4tk3yABq5snbI4n9E0AV20legjXtnHT RNOSI5NOHeSLdHjJIeNSnOpZk8mUi0KwtB9skD+6htefx4gDI7O63hsjZWlgbymTnVoolR zjAZKxgj4kneLcnDoC/5giponMp5jxhMtyko0KNSVs9C5W16FnNyTnykga25osmbSxSEc2 A9i+t3YiAEPABRi/oeN33NkVL1QIiDBea47YpIqHfuTFBmJPbhjpGKa0ZcmuzOPkQg6dZD GMflYyS1T39Z5aw5kaOPQmfq/u5FsCx/Y+OSdfu2EKLwxLhyGjQk/M9CuQURdA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=idjEgr2K; 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-Spam-Score: -2.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=idjEgr2K; 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: 3ACDD19B83 X-Spam-Score: -2.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: DfoyTNIbg+sc I have put the Ihor's snippet in my init file. I find it very useful, and everything is done from a simple Helm session. The only case it doesn't work is when I just want to copy a directory --not a file-- (instead of moving or giving it a symbolic link). So I have done this little modification (just added a conditional to the old function when the method attach is 'cp: if attachment is a file, run `copy-file'. If it is a directory, run `copy-directory'. Then just call the org-attach dispatcher as always: C-c C-a and select an attach method: (define-advice org-attach-attach (:around (oldfun files &rest args) start-from-default-directory) "Code shared by Ihor Radchenko, slightly modified and adapted to my use." (interactive (list (mapcar #'directory-file-name (helm-read-file-name "File to keep as an attachment:" :initial-input (or (progn (require 'dired-aux) (dired-dwim-target-directory)) default-directory) :marked-candidates t)) current-prefix-arg nil)) ;; my addition starts here (setq oldfun (lambda (file &optional visit-dir method) (interactive) (setq method (or method org-attach-method)) (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) (if (file-directory-p file) (ref:lin-attach) (copy-directory file attach-file) (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))) (run-hook-with-args 'org-attach-after-change-hook attach-dir) (org-attach-tag) (cond ((eq org-attach-store-link-p 'attached) (push (list (concat "attachment:" (file-name-nondirectory attach-file)) (file-name-nondirectory attach-file)) org-stored-links)) ((eq org-attach-store-link-p t) (push (list (concat "file:" file) (file-name-nondirectory file)) org-stored-links)) ((eq org-attach-store-link-p 'file) (push (list (concat "file:" attach-file) (file-name-nondirectory attach-file)) org-stored-links))) (if visit-dir (dired attach-dir) (message "File or directory %S is now an attachment" basename)))))) ;; my addition ends here (unless (listp files) (setq files (list files))) (mapc (lambda (file) (apply oldfun file args)) files)) John Kitchin writes: > I discovered another way to do this that is already built in with > `org-attach-dired-to-subtree` that would help sometimes. > > You split your window, open dired in one of them, mark some files, and > then run that command in the dired window. > > John > > ----------------------------------- > Professor John Kitchin (he/him/his) > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > > On Thu, Jun 10, 2021 at 10:04 PM stardiviner > wrote: > > I want this feature patch too. Hope Org Mode can add this. I > remember old version org-mode can do this. But later delete this > feature? I forget what version is. > > I suggest to add this feature. > > On Jun 8, 2021, at 11:49 PM, John Kitchin > wrote: > > Is it possible to attach a directory to an org heading? > > I have only seen how to attach a file so far. > > John > > ----------------------------------- > Professor John Kitchin (he/him/his) > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > --