From e73807efe135c5797d7a94c0f205a7fbd4b2e781 Mon Sep 17 00:00:00 2001 From: Hugo-Heagren <62905215+Hugo-Heagren@users.noreply.github.com> Date: Thu, 23 Feb 2023 06:45:37 +0000 Subject: [PATCH] Add customisable function for prompting when adding refs (#2317) * (node): new custom `org-roam-ref-prompt-function' Function for prompting when adding a ref. * (node): use `org-roam-ref-prompt' in `org-roam-ref-add' Prompt properly for ref. --- org-roam-node.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/org-roam-node.el b/org-roam-node.el index 2faf9dc..61e396b 100644 --- a/org-roam-node.el +++ b/org-roam-node.el @@ -112,6 +112,12 @@ It takes a single argument REF, which is a propertized string." :group 'org-roam :type '(function)) +(defcustom org-roam-ref-prompt-function nil + "Function to prompt for ref strings in `org-roam-ref-add'. +Should take no arguments, prompt the user, and return a string." + :group 'org-roam + :type 'function) + ;;;; Completion-at-point (defcustom org-roam-completion-everywhere nil "When non-nil, provide link completion matching outside of Org links." @@ -1038,7 +1044,9 @@ and when nil is returned the node will be filtered out." ;;;; Editing (defun org-roam-ref-add (ref) "Add REF to the node at point." - (interactive "sRef: ") + (interactive `(,(if org-roam-ref-prompt-function + (funcall org-roam-ref-prompt-function) + (read-string "Ref: ")))) (let ((node (org-roam-node-at-point 'assert))) (save-excursion (goto-char (org-roam-node-point node))