From c7a44b9f1209d82f0e3ebd74ac4386c1098d00df Mon Sep 17 00:00:00 2001 From: N V <44036031+progfolio@users.noreply.github.com> Date: Tue, 7 Apr 2020 01:53:22 -0400 Subject: [PATCH] Move org-roam-capture command to org-roam-capture.el (#407) --- org-roam-capture.el | 26 +++++++++++++++++++++++--- org-roam.el | 17 ----------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/org-roam-capture.el b/org-roam-capture.el index 04e938f..58e13bd 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -37,9 +37,12 @@ ;; Declarations (defvar org-roam-encrypt-files) (defvar org-roam-directory) -(declare-function org-roam--file-path-from-id "org-roam") -(declare-function org-roam--get-ref-path-completions "org-roam") -(declare-function org-roam--format-link "org-roam") +(declare-function org-roam--get-title-path-completions "org-roam") +(declare-function org-roam--get-ref-path-completions "org-roam") +(declare-function org-roam--file-path-from-id "org-roam") +(declare-function org-roam--format-link "org-roam") +(declare-function org-roam--title-to-slug "org-roam") +(declare-function org-roam-completion--completing-read "org-roam-completion") (defvar org-roam-capture--file-name-default "%<%Y%m%d%H%M%S>" "The default file name format for Org-roam templates.") @@ -308,6 +311,23 @@ GOTO and KEYS argument have the same functionality as (add-hook 'org-capture-after-finalize-hook #'org-roam-capture--cleanup-h 10) (org-capture goto keys))) +;;;###autoload +(defun org-roam-capture () + "Launches an `org-capture' process for a new or existing note. +This uses the templates defined at `org-roam-capture-templates'." + (interactive) + (when org-roam-capture--in-process + (user-error "Nested Org-roam capture processes not supported")) + (let* ((completions (org-roam--get-title-path-completions)) + (title (org-roam-completion--completing-read "File: " completions)) + (file-path (cdr (assoc title completions)))) + (let ((org-roam-capture--info (list (cons 'title title) + (cons 'slug (org-roam--title-to-slug title)) + (cons 'file file-path))) + (org-roam-capture--context 'capture)) + (setq org-roam-capture-additional-template-props (list :capture-fn 'org-roam-capture)) + (org-roam--capture)))) + (provide 'org-roam-capture) ;;; org-roam-capture.el ends here diff --git a/org-roam.el b/org-roam.el index 17e1336..4c68a92 100644 --- a/org-roam.el +++ b/org-roam.el @@ -451,23 +451,6 @@ INFO is an alist containing additional information." :require-match t))) (switch-to-buffer (cdr (assoc name names-and-buffers)))))) -;;;; org-roam-capture -(defun org-roam-capture () - "Launches an org-capture process for a new or existing note. -This uses the templates defined at `org-roam-capture-templates'." - (interactive) - (when org-roam-capture--in-process - (user-error "Nested Org-roam capture processes not supported")) - (let* ((completions (org-roam--get-title-path-completions)) - (title (org-roam-completion--completing-read "File: " completions)) - (file-path (cdr (assoc title completions)))) - (let ((org-roam-capture--info (list (cons 'title title) - (cons 'slug (org-roam--title-to-slug title)) - (cons 'file file-path))) - (org-roam-capture--context 'capture)) - (setq org-roam-capture-additional-template-props (list :capture-fn 'org-roam-capture)) - (org-roam--capture)))) - ;;;; Daily notes (defcustom org-roam-date-title-format "%Y-%m-%d" "Format string passed to `format-time-string' for getting a date file's title."