emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Capture with (moving) attachment?
@ 2020-07-22 21:48 Tim Landscheidt
  2020-07-28  9:28 ` Mikhail Skorzhinskii
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Landscheidt @ 2020-07-22 21:48 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I have a capture template to file items to a list:

| ("i" "inventory" entry
|  (file "~/Desktop/Agenda/Inventar.org")
|  "* %^{Name}" :immediate-finish t)

Currently, when I want to file an item with an associated
image, I open the directory of the images with dired, visit
the image file, use the capture to add an item, kill the im-
age buffer, use M-0 w in dired to copy the file's name,
switch to the org file, use C-c C-a m to attach the image by
moving the file, and then switch back to the dired buffer.
Lather, rinse, repeat, until the directory with the images
is empty.

What I want to do instead is open the image file (via dir-
ed), have the capture do the attaching by itself (if it is
called in an image-mode buffer) and then kill the image
buffer.  (Emacs does not care if the file associated with
the buffer is deleted in the mean time.)

First idea was to use %(EXP) to set
org-capture-after-finalize-hook to attach the file, but that
hook is called in the original (image) buffer.
org-capture-before-finalize-hook on the other hand is called
in a CAPTURE-Inventar.org buffer (with no associated file),
same with org-capture-prepare-finalize-hook.  (I also would
like to perform the attaching only *after* the item has suc-
cessfully been filed to avoid misfiling/deleting image
files.)

There are other ways to achieve this in this particular case
(capture, visit the org file, go to (point-max),
(org-attach-attach file nil 'mv), maybe even replace capture
with an (insert (format "* %s\n" (read-string)))), but are
there general solutions for this issue that will work, well,
more generally?

TIA,
Tim



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

end of thread, other threads:[~2020-07-28  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 21:48 Capture with (moving) attachment? Tim Landscheidt
2020-07-28  9:28 ` Mikhail Skorzhinskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).