From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Thomas Holst <thomas.holst@de.bosch.com>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Problems with capture and lisp code
Date: Thu, 21 Jan 2016 14:19:13 +0100 [thread overview]
Message-ID: <87k2n3t6i6.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <ywod37truuim@de.bosch.com> (Thomas Holst's message of "Thu, 21 Jan 2016 10:55:13 +0100")
Hello,
Thomas Holst <thomas.holst@de.bosch.com> writes:
> for my work flow I would like to set up a capture template based on the
> ideas described in:
>
> http://www.jboecker.de/2010/04/14/general-reference-filing-with-org-mode.html#sec-5
>
> The original is based on remember but I want to use capture. The
> principle is as follows:
>
> In the capture template run some lisp code which appends a function to
> `org-capture-before-finalize-hook' which calls `org-attach-mv' to attach
> a file.
>
> The function run from capture template looks like this:
>
> #+begin_src emacs-lisp
> (defun th:filing-install-attach-mv-hook ()
> "call this from a capture template to install th:filing-attach-mv-hook"
> (add-hook 'org-capture-before-finalize-hook 'th:filing-attach-mv-hook)
> (make-local-variable 'kill-buffer-hook)
> (add-hook 'kill-buffer-hook 'th:filing-uninstall-attach-mv-hook)
> (add-hook 'org-capture-mode-hook 'th:filing-uninstall-attach-mv-hook)
> (message "finalize-hook: %s" org-capture-before-finalize-hook))
> #+end_src
>
> In the messages buffer I can see that at run time of the function
> `th:filing-attach-mv-hook' is in `org-capture-before-finalize-hook'.
>
> Now when I look at `org-capture-before-finalize-hook' in the final
> capture buffer `th:filing-attach-mv-hook' is not there.
>
> The same happens with `kill-buffer-hook'. I also tried
> `org-capture-prepare-finalize-hook'. Same result.
>
> So I am puzzled here :-(. Is there some caching mechanism involved? For
> the author of the article stated above this worked with remember - but
> why does it not work with capture.
Wild guess: capture template is expanded in a temporary buffer, which is
killed once the process is complete. Therefore, the uninstall hook
installed in `kill-hook-buffer' removes your function before it is
actually used.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2016-01-21 13:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-21 9:55 Problems with capture and lisp code Thomas Holst
2016-01-21 13:19 ` Nicolas Goaziou [this message]
2016-01-21 14:33 ` Thomas Holst
2016-01-25 23:28 ` Nicolas Goaziou
2016-01-26 6:38 ` Holst Thomas (DGS-EC/ESE4)
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k2n3t6i6.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=thomas.holst@de.bosch.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.