* run a function during capture
@ 2017-01-19 16:47 Alan Schmitt
2017-01-19 17:11 ` Nick Dokos
2017-01-20 13:25 ` Xebar Saram
0 siblings, 2 replies; 7+ messages in thread
From: Alan Schmitt @ 2017-01-19 16:47 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
Hello,
It is possible to run a function at the end of capture? I would like to
call org-board-archive (that downloads a web page according to some
properties) before finishing the capture?
Thanks,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-12: 404.48, 2015-12: 401.85
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: run a function during capture
2017-01-19 16:47 run a function during capture Alan Schmitt
@ 2017-01-19 17:11 ` Nick Dokos
2017-01-23 13:49 ` Alan Schmitt
2017-01-20 13:25 ` Xebar Saram
1 sibling, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2017-01-19 17:11 UTC (permalink / raw)
To: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> It is possible to run a function at the end of capture? I would like to
> call org-board-archive (that downloads a web page according to some
> properties) before finishing the capture?
>
There are three hooks that are run from org-capture-finalize:
- org-capture-prepare-finalize-hook
- org-capture-before-finalize-hook
- org-capture-after-finalize-hook
Check their documentation for when they are run and what the context is.
One of them should be good enough for what you want to do.
--
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: run a function during capture
2017-01-19 16:47 run a function during capture Alan Schmitt
2017-01-19 17:11 ` Nick Dokos
@ 2017-01-20 13:25 ` Xebar Saram
2017-01-23 14:16 ` Alan Schmitt
1 sibling, 1 reply; 7+ messages in thread
From: Xebar Saram @ 2017-01-20 13:25 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 639 bytes --]
Alan: once you have your org-board and capture setting finalized , i would
be very interested to get more details on your setup and work flow, this
looks really interesting!
thx
Z
On Thu, Jan 19, 2017 at 6:47 PM, Alan Schmitt <
alan.schmitt@polytechnique.org> wrote:
> Hello,
>
> It is possible to run a function at the end of capture? I would like to
> call org-board-archive (that downloads a web page according to some
> properties) before finishing the capture?
>
> Thanks,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-12: 404.48, 2015-12: 401.85
>
[-- Attachment #2: Type: text/html, Size: 1064 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: run a function during capture
2017-01-20 13:25 ` Xebar Saram
@ 2017-01-23 14:16 ` Alan Schmitt
2017-01-23 18:56 ` Nick Dokos
0 siblings, 1 reply; 7+ messages in thread
From: Alan Schmitt @ 2017-01-23 14:16 UTC (permalink / raw)
To: Xebar Saram; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]
On 2017-01-20 15:25, Xebar Saram <zeltakc@gmail.com> writes:
> Alan: once you have your org-board and capture setting finalized , i
> would be very interested to get more details on your setup and work
> flow, this looks really interesting!
Here is how I did it:
- on Firefox side, I installed Org-capture for Firefox
http://chadok.info/firefox-org-capture/. Alternatively, you can do it
manually by following http://weblog.zamazal.org/org-mode-firefox/ (in
the “The advanced way” section)
- I "(require 'org-protocol)" and have installed the "org-board"
package.
- I setup a capture template like this:
#+begin_src emacs-lisp
(setq as/org-board-capture-file "my-org-board.org")
(setq org-capture-templates
`(...
("c" "capture through org protocol" entry
(file+headline ,as/org-board-capture-file "Unsorted")
"* %?%:description\n:PROPERTIES:\n:URL: %:link\n:END:\n\n Added %U")
...))
#+end_src
- I added a hook to org-capture-after-finalize-hook
#+begin_src emacs-lisp
(defun as/do-org-board-dl-hook ()
(when (equal (buffer-name) (concat "CAPTURE-" as/org-board-capture-file))
(org-board-archive)))
(add-hook 'org-capture-before-finalize-hook 'as/do-org-board-dl-hook)
#+end_src
(Note: I mistakenly said that the "prepare" hook worked, but that would
download the file even when cancelling, which was wrong)
I think this is it.
Best,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-12: 404.48, 2015-12: 401.85
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: run a function during capture
2017-01-23 14:16 ` Alan Schmitt
@ 2017-01-23 18:56 ` Nick Dokos
2017-01-24 8:43 ` Alan Schmitt
0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2017-01-23 18:56 UTC (permalink / raw)
To: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> ...
> - I added a hook to org-capture-after-finalize-hook
^^^^^
> #+begin_src emacs-lisp
> (defun as/do-org-board-dl-hook ()
> (when (equal (buffer-name) (concat "CAPTURE-" as/org-board-capture-file))
> (org-board-archive)))
>
> (add-hook 'org-capture-before-finalize-hook 'as/do-org-board-dl-hook)
^^^^^^
> #+end_src
>
> (Note: I mistakenly said that the "prepare" hook worked, but that would
^^^^^^^
> download the file even when cancelling, which was wrong)
>
Make up your mind, will you? :-)
--
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: run a function during capture
2017-01-23 18:56 ` Nick Dokos
@ 2017-01-24 8:43 ` Alan Schmitt
0 siblings, 0 replies; 7+ messages in thread
From: Alan Schmitt @ 2017-01-24 8:43 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]
On 2017-01-23 13:56, Nick Dokos <ndokos@gmail.com> writes:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> ...
>> - I added a hook to org-capture-after-finalize-hook
> ^^^^^
>> #+begin_src emacs-lisp
>> (defun as/do-org-board-dl-hook ()
>> (when (equal (buffer-name) (concat "CAPTURE-" as/org-board-capture-file))
>> (org-board-archive)))
>>
>> (add-hook 'org-capture-before-finalize-hook 'as/do-org-board-dl-hook)
> ^^^^^^
>> #+end_src
>>
>> (Note: I mistakenly said that the "prepare" hook worked, but that would
> ^^^^^^^
>> download the file even when cancelling, which was wrong)
>
> Make up your mind, will you? :-)
As you can guess, I was testing as I was editing the message. As always,
the code is the truth™.
For the record, here is what I discovered:
- the prepare hook is run even when cancelling
- the before hook is run with the buffer widened, but the point is still
in the same position as when confirming pointer
- when the after hook is run, I did not get access to the captured data
(I may have done it wrong, but since the before hook worked, I did not
look further)
Best,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2016-12: 404.48, 2015-12: 401.85
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-24 8:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 16:47 run a function during capture Alan Schmitt
2017-01-19 17:11 ` Nick Dokos
2017-01-23 13:49 ` Alan Schmitt
2017-01-20 13:25 ` Xebar Saram
2017-01-23 14:16 ` Alan Schmitt
2017-01-23 18:56 ` Nick Dokos
2017-01-24 8:43 ` Alan Schmitt
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.