unofficial mirror of emacs-orgmode@gnu.org
 help / color / mirror / code / Atom feed
* Re: org-attach a directory?
@ 2021-06-10 16:50 Ypo
  0 siblings, 0 replies; 19+ messages in thread
From: Ypo @ 2021-06-10 16:50 UTC (permalink / raw)
  To: bch, Org-mode

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]

In case you don't know it, take a look at the inheritance option for attachments. Very very very useful: You can use the same DIRectory with many subtrees without being necessary to attach the directory to each of them.

[-- Attachment #2: Type: text/html, Size: 331 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-11 16:35   ` John Kitchin
  2021-06-11 17:10     ` Juan Manuel Macías
  2021-06-15 12:45     ` stardiviner
@ 2021-06-15 20:22     ` Henrik Frisk
  2 siblings, 0 replies; 19+ messages in thread
From: Henrik Frisk @ 2021-06-15 20:22 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

Den fre 11 juni 2021 18:37John Kitchin <jkitchin@andrew.cmu.edu> skrev:

> 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
>
>> Should have thought of this when you first asked if i had understood your
question. This is a very useful function.

/Henrik

>
>>
>>

[-- Attachment #2: Type: text/html, Size: 1890 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-11 16:35   ` John Kitchin
  2021-06-11 17:10     ` Juan Manuel Macías
@ 2021-06-15 12:45     ` stardiviner
  2021-06-15 20:22     ` Henrik Frisk
  2 siblings, 0 replies; 19+ messages in thread
From: stardiviner @ 2021-06-15 12:45 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]



> On Jun 12, 2021, at 12:35 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> 
> 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

Thanks John.

I tried your methods. But this need to mark multiple regular files. Instead of a directory. It needs to leave Org file buffer. What if I have multiple Org buffer presents. It might cause chaos. I don’t think it’s a good solution to attach directory. But learn a new command. Still good.

> 
> -----------------------------------
> 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 <http://kitchingroup.cheme.cmu.edu/>
> 
> 
> 
> On Thu, Jun 10, 2021 at 10:04 PM stardiviner <numbchild@gmail.com <mailto:numbchild@gmail.com>> 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 <jkitchin@andrew.cmu.edu <mailto:jkitchin@andrew.cmu.edu>> 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 <http://kitchingroup.cheme.cmu.edu/>
>> 
> 


[-- Attachment #2: Type: text/html, Size: 4031 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-11 16:35   ` John Kitchin
@ 2021-06-11 17:10     ` Juan Manuel Macías
  2021-06-15 12:45     ` stardiviner
  2021-06-15 20:22     ` Henrik Frisk
  2 siblings, 0 replies; 19+ messages in thread
From: Juan Manuel Macías @ 2021-06-11 17:10 UTC (permalink / raw)
  To: John Kitchin; +Cc: orgmode

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 <numbchild@gmail.com>
> 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
>         <jkitchin@andrew.cmu.edu> 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
>

--


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-11  1:43 ` stardiviner
@ 2021-06-11 16:35   ` John Kitchin
  2021-06-11 17:10     ` Juan Manuel Macías
                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: John Kitchin @ 2021-06-11 16:35 UTC (permalink / raw)
  To: stardiviner; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]

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 <numbchild@gmail.com> 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 <jkitchin@andrew.cmu.edu> 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
>
>
>

[-- Attachment #2: Type: text/html, Size: 2259 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-08 15:49 John Kitchin
  2021-06-08 16:21 ` Henrik Frisk
  2021-06-09  1:38 ` Ihor Radchenko
@ 2021-06-11  1:43 ` stardiviner
  2021-06-11 16:35   ` John Kitchin
  2 siblings, 1 reply; 19+ messages in thread
From: stardiviner @ 2021-06-11  1:43 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 712 bytes --]

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 <jkitchin@andrew.cmu.edu> 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 <http://kitchingroup.cheme.cmu.edu/>
> 


[-- Attachment #2: Type: text/html, Size: 1641 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-10 14:01       ` Juan Manuel Macías
@ 2021-06-10 16:13         ` Juan Manuel Macías
  0 siblings, 0 replies; 19+ messages in thread
From: Juan Manuel Macías @ 2021-06-10 16:13 UTC (permalink / raw)
  To: orgmode

You could also modify some line in org-attach-attach, for example:

...
((eq method 'cp) (if (file-directory-p file)
                            (copy-directory file attach-file)
                          (copy-file file attach-file)))
...

Best regards,

Juan Manuel 

Juan Manuel Macías writes:

> If I have to stay with a workaround that covers many scenarios, I would
> stay with Ihor's snippet, which seems to me simpler than the patch that
> I suggested before, and you don't need to define new attach
> commands/methods. I would vote for a patch in that direction (Ihor's
> code).



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-10 12:37     ` Christian Barthel
  2021-06-10 12:39       ` John Kitchin
@ 2021-06-10 14:01       ` Juan Manuel Macías
  2021-06-10 16:13         ` Juan Manuel Macías
  1 sibling, 1 reply; 19+ messages in thread
From: Juan Manuel Macías @ 2021-06-10 14:01 UTC (permalink / raw)
  To: Christian Barthel, John Kitchin, Ihor Radchenko; +Cc: orgmode

This only works when you create the attach folder manually, but not when
you want org-attach to generate the attach directory for the current
node.

If I have to stay with a workaround that covers many scenarios, I would
stay with Ihor's snippet, which seems to me simpler than the patch that
I suggested before, and you don't need to define new attach
commands/methods. I would vote for a patch in that direction (Ihor's
code).

Best regards,

Juan Manuel     

Christian Barthel writes:

> On Thu, Jun 10 2021, Ypo wrote:
>
>> C-c C-a
>>
>> s
>>
>> (not "S" like in the video, but "s")
>
> Thanks, that is an interesting workaround:
> Setting the directory twice and using the copy/delete action
> accordingly.
>
> Does anyone know if there is a workaround to attach a file and
> delete the old one (or move the file) or do I need to write a
> small elisp function for that?



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-10 12:39       ` John Kitchin
@ 2021-06-10 12:54         ` Christian Barthel
  0 siblings, 0 replies; 19+ messages in thread
From: Christian Barthel @ 2021-06-10 12:54 UTC (permalink / raw)
  To: John Kitchin; +Cc: Ypo, Org-mode

On Thu, Jun 10 2021, John Kitchin wrote:

> isn't that just org-attach-attach-mv? or what happens if you set
> org-attach-method to mv?

Ah right.  I always just looked only at the *Org Attach* buffer
and haven't seen a move method.  The echo area lists a few more
commands:  it seems that doing `org-attach' and `m' (move?) does
exactly what I need.  Thanks!

-- 
Christian Barthel


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-10 12:37     ` Christian Barthel
@ 2021-06-10 12:39       ` John Kitchin
  2021-06-10 12:54         ` Christian Barthel
  2021-06-10 14:01       ` Juan Manuel Macías
  1 sibling, 1 reply; 19+ messages in thread
From: John Kitchin @ 2021-06-10 12:39 UTC (permalink / raw)
  To: Christian Barthel; +Cc: Ypo, Org-mode

[-- Attachment #1: Type: text/plain, Size: 829 bytes --]

isn't that just org-attach-attach-mv? or what happens if you set
org-attach-method to mv?

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 8:37 AM Christian Barthel <bch@online.de> wrote:

> On Thu, Jun 10 2021, Ypo wrote:
>
> > C-c C-a
> >
> > s
> >
> > (not "S" like in the video, but "s")
>
> Thanks, that is an interesting workaround:
> Setting the directory twice and using the copy/delete action
> accordingly.
>
> Does anyone know if there is a workaround to attach a file and
> delete the old one (or move the file) or do I need to write a
> small elisp function for that?
>
> --
> Christian Barthel
>

[-- Attachment #2: Type: text/html, Size: 1486 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-10  3:56   ` Ypo
@ 2021-06-10 12:37     ` Christian Barthel
  2021-06-10 12:39       ` John Kitchin
  2021-06-10 14:01       ` Juan Manuel Macías
  0 siblings, 2 replies; 19+ messages in thread
From: Christian Barthel @ 2021-06-10 12:37 UTC (permalink / raw)
  To: Ypo; +Cc: Org-mode, John Kitchin

On Thu, Jun 10 2021, Ypo wrote:

> C-c C-a
>
> s
>
> (not "S" like in the video, but "s")

Thanks, that is an interesting workaround:
Setting the directory twice and using the copy/delete action
accordingly.

Does anyone know if there is a workaround to attach a file and
delete the old one (or move the file) or do I need to write a
small elisp function for that?

-- 
Christian Barthel


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-09 23:39 ` John Kitchin
  2021-06-10  3:54   ` Ypo
@ 2021-06-10  3:56   ` Ypo
  2021-06-10 12:37     ` Christian Barthel
  1 sibling, 1 reply; 19+ messages in thread
From: Ypo @ 2021-06-10  3:56 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]

C-c C-a

s

(not "S" like in the video, but "s")

El 10/06/2021 a las 1:39, John Kitchin escribió:
> can you give an example of those commands, I tried the key commands
>
> C-c C-a which opens the dispatcher
> s to set a directory
> then C-c C-a z to sync, but it did not do anything but add a :DIR: 
> property. it didn't move or copy files anywhere.
>
> Here is the code I am currently using that basically does what I want.
>
> (defun scimax-org-attach-attach-directory-cp (dir)
>   "Copy DIR as an attachment to the current heading."
>   (interactive "DDir: ")
>   (copy-directory dir (file-name-as-directory (org-attach-dir 
> 'get-create)))
>   (org-attach-sync)
>   (org-entry-put (point) "ATTACHMENTS"
> (concat
>  (org-entry-get (point) "ATTACHMENTS")
>  (format " [[attachment:%s]]" (car (last (f-split dir)))))))
>
>
> (defun scimax-org-attach-attach-directory-mv (dir)
>   "Move DIR as an attachment to the current heading."
>   (interactive "DDir: ")
>   (scimax-org-attach-attach-directory-cp dir)
>   (delete-directory dir t t))
>
>
> 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 <http://kitchingroup.cheme.cmu.edu>
>
>
>
> On Wed, Jun 9, 2021 at 3:35 PM Ypo <ypuntot@gmail.com 
> <mailto:ypuntot@gmail.com>> wrote:
>
>     Firstly you set the folder where your files are as attachment
>     DIRectory.
>
>     Then, you set your target attachment DIRectory (always using the
>     attachment commands).
>
>     After doing this, you will be offered the option to copy and
>     delete all the files from the former to the target folder.
>
>     Hugs
>

[-- Attachment #2: Type: text/html, Size: 4224 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-09 23:39 ` John Kitchin
@ 2021-06-10  3:54   ` Ypo
  2021-06-10  3:56   ` Ypo
  1 sibling, 0 replies; 19+ messages in thread
From: Ypo @ 2021-06-10  3:54 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]

Hi John :-)

Take a look:

https://mega.nz/file/hKgECBqY#8UVEURWQBvDpno9DPEk8gb8E-zxAJq3F3E8Y9I9xRFk


El 10/06/2021 a las 1:39, John Kitchin escribió:
> can you give an example of those commands, I tried the key commands
>
> C-c C-a which opens the dispatcher
> s to set a directory
> then C-c C-a z to sync, but it did not do anything but add a :DIR: 
> property. it didn't move or copy files anywhere.
>
> Here is the code I am currently using that basically does what I want.
>
> (defun scimax-org-attach-attach-directory-cp (dir)
>   "Copy DIR as an attachment to the current heading."
>   (interactive "DDir: ")
>   (copy-directory dir (file-name-as-directory (org-attach-dir 
> 'get-create)))
>   (org-attach-sync)
>   (org-entry-put (point) "ATTACHMENTS"
> (concat
>  (org-entry-get (point) "ATTACHMENTS")
>  (format " [[attachment:%s]]" (car (last (f-split dir)))))))
>
>
> (defun scimax-org-attach-attach-directory-mv (dir)
>   "Move DIR as an attachment to the current heading."
>   (interactive "DDir: ")
>   (scimax-org-attach-attach-directory-cp dir)
>   (delete-directory dir t t))
>
>
> 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 <http://kitchingroup.cheme.cmu.edu>
>
>
>
> On Wed, Jun 9, 2021 at 3:35 PM Ypo <ypuntot@gmail.com 
> <mailto:ypuntot@gmail.com>> wrote:
>
>     Firstly you set the folder where your files are as attachment
>     DIRectory.
>
>     Then, you set your target attachment DIRectory (always using the
>     attachment commands).
>
>     After doing this, you will be offered the option to copy and
>     delete all the files from the former to the target folder.
>
>     Hugs
>

[-- Attachment #2: Type: text/html, Size: 4361 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-09 19:35 Ypo
@ 2021-06-09 23:39 ` John Kitchin
  2021-06-10  3:54   ` Ypo
  2021-06-10  3:56   ` Ypo
  0 siblings, 2 replies; 19+ messages in thread
From: John Kitchin @ 2021-06-09 23:39 UTC (permalink / raw)
  To: Ypo; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]

can you give an example of those commands, I tried the key commands

C-c C-a which opens the dispatcher
s to set a directory
then C-c C-a z to sync, but it did not do anything but add a :DIR:
property. it didn't move or copy files anywhere.

Here is the code I am currently using that basically does what I want.

(defun scimax-org-attach-attach-directory-cp (dir)
  "Copy DIR as an attachment to the current heading."
  (interactive "DDir: ")
  (copy-directory dir (file-name-as-directory (org-attach-dir 'get-create)))
  (org-attach-sync)
  (org-entry-put (point) "ATTACHMENTS"
(concat
 (org-entry-get (point) "ATTACHMENTS")
 (format " [[attachment:%s]]" (car (last (f-split dir)))))))


(defun scimax-org-attach-attach-directory-mv (dir)
  "Move DIR as an attachment to the current heading."
  (interactive "DDir: ")
  (scimax-org-attach-attach-directory-cp dir)
  (delete-directory dir t t))


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 Wed, Jun 9, 2021 at 3:35 PM Ypo <ypuntot@gmail.com> wrote:

> Firstly you set the folder where your files are as attachment DIRectory.
>
> Then, you set your target attachment DIRectory (always using the
> attachment commands).
>
> After doing this, you will be offered the option to copy and delete all
> the files from the former to the target folder.
>
> Hugs
>

[-- Attachment #2: Type: text/html, Size: 2604 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
@ 2021-06-09 19:35 Ypo
  2021-06-09 23:39 ` John Kitchin
  0 siblings, 1 reply; 19+ messages in thread
From: Ypo @ 2021-06-09 19:35 UTC (permalink / raw)
  To: jkitchin, Org-mode

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

Firstly you set the folder where your files are as attachment DIRectory.

Then, you set your target attachment DIRectory (always using the attachment commands).

After doing this, you will be offered the option to copy and delete all the files from the former to the target folder.

Hugs

[-- Attachment #2: Type: text/html, Size: 603 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-08 15:49 John Kitchin
  2021-06-08 16:21 ` Henrik Frisk
@ 2021-06-09  1:38 ` Ihor Radchenko
  2021-06-11  1:43 ` stardiviner
  2 siblings, 0 replies; 19+ messages in thread
From: Ihor Radchenko @ 2021-06-09  1:38 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode-email

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> Is it possible to attach a directory to an org heading?
>
> I have only seen how to attach a file so far.

I use the code below to attach directories and allow multiple selection
while attaching files. Also, if more people are interested in this kind
of functionality, I can write a simple patch. It's just a matter of
applying #'directory-file-name to the selected file name in the
interactive spec of the org-attach-attach.

(defvar yant/org-attach-default-source "~/Downloads/"
  "Default directory to attach the files from.")

(define-advice org-attach-attach (:around (oldfun files &rest args) start-from-default-directory)
  "Look for new attachments from `yant/org-attach-default-source' directory instead of `default-directory'."
  (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))
									  (and yant/org-attach-default-source
									       (f-slash yant/org-attach-default-source))
									  default-directory)
						       :marked-candidates t))
    current-prefix-arg
    nil))
  (unless (listp files) (setq files (list files)))
  (mapc (lambda (file) (apply oldfun file args)) files))

Best,
Ihor


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-08 16:21 ` Henrik Frisk
@ 2021-06-08 20:41   ` John Kitchin
  0 siblings, 0 replies; 19+ messages in thread
From: John Kitchin @ 2021-06-08 20:41 UTC (permalink / raw)
  To: Henrik Frisk; +Cc: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

I am not sure that is what I meant, it looks like that specifies/changes
the attachment directory for a heading.

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?

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 Tue, Jun 8, 2021 at 12:21 PM Henrik Frisk <frisk.h@gmail.com> wrote:

>
>
> Den tis 8 juni 2021 kl 17:56 skrev John Kitchin <jkitchin@andrew.cmu.edu>:
>
>> Is it possible to attach a directory to an org heading?
>>
>>
>> Yes, you do arg-attach-set-directory. After that you need to sync it to
> make the files in the directory visible: org-attach-sync
>
> It's quite neat, I use it all the time.
>
> /Henrik
>

[-- Attachment #2: Type: text/html, Size: 2037 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: org-attach a directory?
  2021-06-08 15:49 John Kitchin
@ 2021-06-08 16:21 ` Henrik Frisk
  2021-06-08 20:41   ` John Kitchin
  2021-06-09  1:38 ` Ihor Radchenko
  2021-06-11  1:43 ` stardiviner
  2 siblings, 1 reply; 19+ messages in thread
From: Henrik Frisk @ 2021-06-08 16:21 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Den tis 8 juni 2021 kl 17:56 skrev John Kitchin <jkitchin@andrew.cmu.edu>:

> Is it possible to attach a directory to an org heading?
>
>
> Yes, you do arg-attach-set-directory. After that you need to sync it to
make the files in the directory visible: org-attach-sync

It's quite neat, I use it all the time.

/Henrik

[-- Attachment #2: Type: text/html, Size: 726 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* org-attach a directory?
@ 2021-06-08 15:49 John Kitchin
  2021-06-08 16:21 ` Henrik Frisk
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: John Kitchin @ 2021-06-08 15:49 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 676 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-06-15 20:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 16:50 org-attach a directory? Ypo
  -- strict thread matches above, loose matches on Subject: below --
2021-06-09 19:35 Ypo
2021-06-09 23:39 ` John Kitchin
2021-06-10  3:54   ` Ypo
2021-06-10  3:56   ` Ypo
2021-06-10 12:37     ` Christian Barthel
2021-06-10 12:39       ` John Kitchin
2021-06-10 12:54         ` Christian Barthel
2021-06-10 14:01       ` Juan Manuel Macías
2021-06-10 16:13         ` Juan Manuel Macías
2021-06-08 15:49 John Kitchin
2021-06-08 16:21 ` Henrik Frisk
2021-06-08 20:41   ` John Kitchin
2021-06-09  1:38 ` Ihor Radchenko
2021-06-11  1:43 ` stardiviner
2021-06-11 16:35   ` John Kitchin
2021-06-11 17:10     ` Juan Manuel Macías
2021-06-15 12:45     ` stardiviner
2021-06-15 20:22     ` Henrik Frisk

unofficial mirror of emacs-orgmode@gnu.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git