Hi, I'm relatively new to org-mode. I am tending to use org-attach quite a bit as part of my workflow. Instead of having to navigate from default-directory to the source of the attachment, it would be great if I could set a better default. I am probably missing something obvious, but is there a way to set the default source directory for attachments? Any advice is greatly appreciated. Thank you for your help. -gyro
gyro funch <gyromagnetic@gmail.com> writes:
> Hi,
>
> I'm relatively new to org-mode.
>
> I am tending to use org-attach quite a bit as part of my
> workflow.
>
> Instead of having to navigate from default-directory to the
> source of
> the attachment, it would be great if I could set a better
> default.
>
> I am probably missing something obvious, but is there a way to
> set the
> default source directory for attachments?
>
> Any advice is greatly appreciated.
>
> Thank you for your help.As far as I’m aware, the attachments
> need to be kept in a directory that is special and separate,
> because *every item* in the directory is treated as an
> attachment. If you set this to a different directory, and then
> from within your document tried to delete all attachments, then
> *everything* in the whole directory would be lost. Wouldn’t it?
I think your particular workflow might possibly be better served
by creating file: links to all those files instead of attaching
them - that way, you can keep your files wherever you wish. It
might be safer to treat the attachment function as being a way to
manage finished permanent files that no longer need editing, to be
included as-is.
Section 4 of the Org-mode manual, titled “Hyperlinks”, shows
everything about links including links to your own files. You may
use Org-mode functions to help you create links, or you can type
them out by hand - the result is exactly the same, as long as
there are no typos of course.
--
David Rogers
gyro funch <gyromagnetic@gmail.com> writes:
> I am probably missing something obvious, but is there a way to set the
> default source directory for attachments?
Not by default. I am using the following advice (requires helm and f.el):
(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
Thank you, Ihor.
That is very helpful.
Kind regards,
gyro
------ Original Message ------
From: "Ihor Radchenko" <yantar92@gmail.com>
To: "gyro funch" <gyromagnetic@gmail.com>; emacs-orgmode@gnu.org
Sent: 11/29/2020 6:21:27 PM
Subject: Re: set source directory for org-attach
>gyro funch <gyromagnetic@gmail.com> writes:
>> I am probably missing something obvious, but is there a way to set the
>> default source directory for attachments?
>
>Not by default. I am using the following advice (requires helm and f.el):
>
>(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