1

Is there a way to call a certain function after a certain org-capture template has been run (successfully, ie. not aborted)?

  • Do you mean automatically (as in a hook function)? If so, say, so please. – Drew Mar 23 at 0:06
1

You can add a function to org-capture-after-finalize-hook to have it run after an org-capture entry has been either confirmed or aborted. Then, within the function, you can use the variable org-note-abort to test whether the template was run successfully (nil) or aborted (t), and plist-get with the variable org-capture-plist to test which template was being used. For example:

(defun tina/test-finalize ()
  (let ((key  (plist-get org-capture-plist :key))
        (desc (plist-get org-capture-plist :description)))
    (if org-note-abort
        (message "Template with key %s and description “%s” aborted" key desc)
      (message "Template with key %s and description “%s” run successfully" key desc))))

(add-hook 'org-capture-after-finalize-hook 'tina/test-finalize)

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.