emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: emacs-orgmode@gnu.org
Subject: Capture with (moving) attachment?
Date: Wed, 22 Jul 2020 21:48:24 +0000	[thread overview]
Message-ID: <874kpz8f54.fsf@passepartout.tim-landscheidt.de> (raw)

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



             reply	other threads:[~2020-07-22 21:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 21:48 Tim Landscheidt [this message]
2020-07-28  9:28 ` Capture with (moving) attachment? Mikhail Skorzhinskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874kpz8f54.fsf@passepartout.tim-landscheidt.de \
    --to=tim@tim-landscheidt.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).