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
|
3. ~plain~ text is inserted. Other options include Org headings via
|
||||||
~entry~.
|
~entry~.
|
||||||
4. ~(function org-roam--capture-get-point)~ should not be changed.
|
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.
|
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
|
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
|
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.
|
@code{(function org-roam--capture-get-point)} should not be changed.
|
||||||
|
|
||||||
@item
|
@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.
|
This template means don't insert any content, but place the cursor here.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
|
@ -353,7 +353,8 @@ properties to be added to the template."
|
|||||||
(rest (org-plist-delete template :key))
|
(rest (org-plist-delete template :key))
|
||||||
(rest (org-plist-delete rest :desc))
|
(rest (org-plist-delete rest :desc))
|
||||||
(rest (org-plist-delete rest :body))
|
(rest (org-plist-delete rest :body))
|
||||||
(org-roam-plist props)
|
(rest (append rest props))
|
||||||
|
org-roam-plist
|
||||||
options)
|
options)
|
||||||
(while rest
|
(while rest
|
||||||
(let* ((key (pop rest))
|
(let* ((key (pop rest))
|
||||||
@ -362,13 +363,15 @@ properties to be added to the template."
|
|||||||
(when (and custom
|
(when (and custom
|
||||||
(not val))
|
(not val))
|
||||||
(user-error "Invalid capture template format: %s\nkey %s cannot be nil" template key))
|
(user-error "Invalid capture template format: %s\nkey %s cannot be nil" template key))
|
||||||
(push val (if custom org-roam-plist options))
|
(if custom
|
||||||
(push key (if custom org-roam-plist options))))
|
(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)
|
(append `(,key ,desc plain #'org-roam-capture--get-point ,body)
|
||||||
options
|
options
|
||||||
(list :org-roam org-roam-plist))))
|
(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.
|
"Main entry point.
|
||||||
GOTO and KEYS correspond to `org-capture' arguments.
|
GOTO and KEYS correspond to `org-capture' arguments.
|
||||||
INFO is an alist for filling up Org-roam's capture templates.
|
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'."
|
Arguments GOTO and KEYS see `org-capture'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((node (org-roam-node-read)))
|
(let ((node (org-roam-node-read)))
|
||||||
(org-roam-capture--capture :goto goto
|
(org-roam-capture- :goto goto
|
||||||
:keys keys
|
:keys keys
|
||||||
:info `((title . ,(org-roam-node-title node))
|
:info `((title . ,(org-roam-node-title node))
|
||||||
(slug . ,(funcall org-roam-title-to-slug-function
|
(slug . ,(funcall org-roam-title-to-slug-function
|
||||||
(org-roam-node-title node)))
|
(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)
|
(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)))
|
(if goto (list (car it)) it)))
|
||||||
(org-roam-capture--info (list (cons 'time time)))
|
(org-roam-capture--info (list (cons 'time time)))
|
||||||
(org-roam-capture--context 'dailies))
|
(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))
|
:info (list (cons 'time time))
|
||||||
:context 'dailies)))
|
:context 'dailies)))
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ It opens or creates a note with the given ref.
|
|||||||
:annotation orglink
|
:annotation orglink
|
||||||
:initial body)
|
:initial body)
|
||||||
(raise-frame)
|
(raise-frame)
|
||||||
(org-roam-capture--capture
|
(org-roam-capture-
|
||||||
:keys (cdr (assoc 'template decoded-alist))
|
:keys (cdr (assoc 'template decoded-alist))
|
||||||
:info decoded-alist
|
:info decoded-alist
|
||||||
:props (list :ref ref)
|
: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)))
|
(let ((node (org-roam-node-read initial-input filter-fn)))
|
||||||
(if (org-roam-node-file node)
|
(if (org-roam-node-file node)
|
||||||
(org-roam-node-visit node other-window)
|
(org-roam-node-visit node other-window)
|
||||||
(org-roam-capture--capture
|
(org-roam-capture-
|
||||||
:info `((title . ,(org-roam-node-title node))
|
:info `((title . ,(org-roam-node-title node))
|
||||||
(slug . ,(funcall org-roam-title-to-slug-function (org-roam-node-title node))))
|
(slug . ,(funcall org-roam-title-to-slug-function (org-roam-node-title node))))
|
||||||
:props (list :finalize 'find-file)))))
|
:props (list :finalize 'find-file)))))
|
||||||
@ -720,7 +720,7 @@ which takes as its argument an alist of path-completions."
|
|||||||
(insert (org-link-make-string
|
(insert (org-link-make-string
|
||||||
(concat "id:" (org-roam-node-id node))
|
(concat "id:" (org-roam-node-id node))
|
||||||
description)))
|
description)))
|
||||||
(org-roam-capture--capture
|
(org-roam-capture-
|
||||||
:info `((title . ,(org-roam-node-title node))
|
:info `((title . ,(org-roam-node-title node))
|
||||||
(slug . ,(funcall org-roam-title-to-slug-function (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)
|
:props (list :region (when (and beg end)
|
||||||
|
Reference in New Issue
Block a user