[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: org-attach a directory?
From: |
Ihor Radchenko |
Subject: |
Re: org-attach a directory? |
Date: |
Wed, 09 Jun 2021 09:38:49 +0800 |
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