diff --git a/org-roam-capture.el b/org-roam-capture.el index 0983cfc..ed78a9c 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -149,14 +149,6 @@ Next, it expands the remaining template string using (completing-read (format "%s: " key ) nil))) nil) (org-capture-fill-template))) -(defun org-roam-capture--find-file-h () - "Opens the newly created template file. -This is added as a hook to `org-capture-after-finalize-hook'." - (when-let ((file-path (org-roam-capture--get :file-path))) - (unless org-note-abort - (find-file file-path))) - (remove-hook 'org-capture-after-finalize-hook #'org-roam-capture--find-file-h)) - (defun org-roam-capture--insert-link-h () "Insert the link into the original buffer, after the capture process is done. This is added as a hook to `org-capture-after-finalize-hook'." @@ -303,6 +295,22 @@ This function is used solely in Org-roam's capture templates: see (push val converted))) (append (nreverse converted) `(:org-roam ,org-roam-plist)))) +(defun org-roam-capture--find-file-h () + "Opens the newly created template file. +This is added as a hook to `org-capture-after-finalize-hook'. +Run the hooks defined in `org-roam-capture-after-find-file-hook'." + (unless org-note-abort + (when-let ((file-path (org-roam-capture--get :file-path))) + (find-file file-path)) + (run-hooks 'org-roam-capture-after-find-file-hook)) + (remove-hook 'org-capture-after-finalize-hook #'org-roam-capture--find-file-h)) + +(defcustom org-roam-capture-after-find-file-hook nil + "Hook that is run right after an Org-roam capture process is finalized. +Suitable for moving point." + :group 'org-roam + :type 'hook) + (defun org-roam--capture (&optional goto keys) "Create a new file, and return the path to the edited file. The templates are defined at `org-roam-capture-templates'. The