mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
update conversion to accept template overrides
rename org-roam-capture--capture to org-roam-capture-
This commit is contained in:
@ -569,7 +569,7 @@ the default template, reproduced below.
|
||||
3. ~plain~ text is inserted. Other options include Org headings via
|
||||
~entry~.
|
||||
4. ~(function org-roam--capture-get-point)~ should not be changed.
|
||||
5. ~"%?"~ is the template inserted on each call to ~org-roam-capture--capture~.
|
||||
5. ~"%?"~ is the template inserted on each call to ~org-roam-capture-~.
|
||||
This template means don't insert any content, but place the cursor here.
|
||||
6. ~:file-name~ is the file-name template for a new note, if it doesn't yet
|
||||
exist. This creates a file at path that looks like
|
||||
|
@ -938,7 +938,7 @@ The template is given a description of @code{"default"}.
|
||||
@code{(function org-roam--capture-get-point)} should not be changed.
|
||||
|
||||
@item
|
||||
@code{"%?"} is the template inserted on each call to @code{org-roam-capture--capture}.
|
||||
@code{"%?"} is the template inserted on each call to @code{org-roam-capture-}.
|
||||
This template means don't insert any content, but place the cursor here.
|
||||
|
||||
@item
|
||||
|
@ -353,7 +353,8 @@ properties to be added to the template."
|
||||
(rest (org-plist-delete template :key))
|
||||
(rest (org-plist-delete rest :desc))
|
||||
(rest (org-plist-delete rest :body))
|
||||
(org-roam-plist props)
|
||||
(rest (append rest props))
|
||||
org-roam-plist
|
||||
options)
|
||||
(while rest
|
||||
(let* ((key (pop rest))
|
||||
@ -362,13 +363,15 @@ properties to be added to the template."
|
||||
(when (and custom
|
||||
(not val))
|
||||
(user-error "Invalid capture template format: %s\nkey %s cannot be nil" template key))
|
||||
(push val (if custom org-roam-plist options))
|
||||
(push key (if custom org-roam-plist options))))
|
||||
(if custom
|
||||
(setq org-roam-plist (plist-put org-roam-plist key val))
|
||||
(setq options (plist-put options key val)))))
|
||||
(append `(,key ,desc plain #'org-roam-capture--get-point ,body)
|
||||
options
|
||||
(list :org-roam org-roam-plist))))
|
||||
|
||||
(cl-defun org-roam-capture--capture (&key goto keys info props templates)
|
||||
;;;###autoload
|
||||
(cl-defun org-roam-capture- (&key goto keys info props templates)
|
||||
"Main entry point.
|
||||
GOTO and KEYS correspond to `org-capture' arguments.
|
||||
INFO is an alist for filling up Org-roam's capture templates.
|
||||
@ -391,12 +394,13 @@ This uses the templates defined at `org-roam-capture-templates'.
|
||||
Arguments GOTO and KEYS see `org-capture'."
|
||||
(interactive "P")
|
||||
(let ((node (org-roam-node-read)))
|
||||
(org-roam-capture--capture :goto goto
|
||||
(org-roam-capture- :goto goto
|
||||
:keys keys
|
||||
:info `((title . ,(org-roam-node-title node))
|
||||
(slug . ,(funcall org-roam-title-to-slug-function
|
||||
(org-roam-node-title node)))
|
||||
(file . ,(org-roam-node-file node))))))
|
||||
(file . ,(org-roam-node-file node)))
|
||||
:props '(:immediate-finish nil))))
|
||||
|
||||
(provide 'org-roam-capture)
|
||||
|
||||
|
@ -102,7 +102,7 @@ When GOTO is non-nil, go the note without creating an entry."
|
||||
(if goto (list (car it)) it)))
|
||||
(org-roam-capture--info (list (cons 'time time)))
|
||||
(org-roam-capture--context 'dailies))
|
||||
(org-roam-capture--capture :goto (when goto '(4))
|
||||
(org-roam-capture- :goto (when goto '(4))
|
||||
:info (list (cons 'time time))
|
||||
:context 'dailies)))
|
||||
|
||||
|
@ -79,7 +79,7 @@ It opens or creates a note with the given ref.
|
||||
:annotation orglink
|
||||
:initial body)
|
||||
(raise-frame)
|
||||
(org-roam-capture--capture
|
||||
(org-roam-capture-
|
||||
:keys (cdr (assoc 'template decoded-alist))
|
||||
:info decoded-alist
|
||||
:props (list :ref ref)
|
||||
|
@ -687,7 +687,7 @@ If OTHER-WINDOW, visit the NODE in another window."
|
||||
(let ((node (org-roam-node-read initial-input filter-fn)))
|
||||
(if (org-roam-node-file node)
|
||||
(org-roam-node-visit node other-window)
|
||||
(org-roam-capture--capture
|
||||
(org-roam-capture-
|
||||
:info `((title . ,(org-roam-node-title node))
|
||||
(slug . ,(funcall org-roam-title-to-slug-function (org-roam-node-title node))))
|
||||
:props (list :finalize 'find-file)))))
|
||||
@ -720,7 +720,7 @@ which takes as its argument an alist of path-completions."
|
||||
(insert (org-link-make-string
|
||||
(concat "id:" (org-roam-node-id node))
|
||||
description)))
|
||||
(org-roam-capture--capture
|
||||
(org-roam-capture-
|
||||
:info `((title . ,(org-roam-node-title node))
|
||||
(slug . ,(funcall org-roam-title-to-slug-function (org-roam-node-title node))))
|
||||
:props (list :region (when (and beg end)
|
||||
|
Reference in New Issue
Block a user