Hello again, On 2026-04-23 15:07, Alan Schmitt <[email protected]> writes:
> I use org-capture through org-protocol to store web pages to read
> later. It works well, but I would like to improve it by first checking
> if I have already stored the page (and in this case not capture it, but
> have a message telling me so).
I made some progress, but I have trouble aborting the capture. Here is
what I tried.
I wrote a small function to be called as a hook:
(defun my-org-capture-hook-check-link ()
(let ((link (plist-get org-store-link-plist :link)))
(message (format "Capturing %s" link)))
(org-capture-kill))
If I add it as a :hook argument, then org-capture-kill fires too early
(as it assumes org-capture-mode is set) and the error is discarded (the
capture happens).
If I add it as a :prepare-finalize hook, I get stuck in an intermediate
step (the capture buffer is there, and "C-c C-k" does nothing).
If I add it as a :before-finalize hook, I have a capture buffer with the
whole file in it, and I can abort with "C-c C-k".
A “solution” seems to be to call org-capture-kill twice:
(defun my-org-capture-hook-check-link ()
(let ((link (plist-get org-store-link-plist :link)))
(message (format "Capturing %s" link)))
(org-capture-kill)
(org-capture-kill))
which does what I want (nothing is captured), but I see an error in
*Messages*:
This does not seem to be a capture buffer for Org mode
What is the correct way to abort capture in one of the hooks?
Best,
Alan
signature.asc
Description: PGP signature
