capture buffer for journelly entries
This commit is contained in:
@@ -29,18 +29,35 @@
|
||||
|
||||
|
||||
(defun journelly-convert-entry ()
|
||||
"Interactive function to convert journelly entry to org-roam."
|
||||
"Interactive function to convert journelly entry to org-roam.
|
||||
Opens the capture buffer for review before finalizing."
|
||||
(interactive)
|
||||
(let* ((entry-text (if (use-region-p)
|
||||
(buffer-substring-no-properties (region-beginning) (region-end))
|
||||
(buffer-substring-no-properties (point-min) (point-max))))
|
||||
(parsed (journelly-parse-entry entry-text)))
|
||||
(org-roam-capture-
|
||||
:node (org-roam-node-create :title (journelly-entry-title parsed))
|
||||
:props `(:immediate-finish t
|
||||
:journelly-heading ,(journelly-entry-heading parsed)
|
||||
:journelly-url ,(journelly-entry-url parsed)
|
||||
:journelly-content ,(journelly-entry-content parsed)))))
|
||||
(parsed (journelly-parse-entry entry-text))
|
||||
(title (journelly-entry-title parsed))
|
||||
(content (journelly-entry-content parsed))
|
||||
(heading (journelly-entry-heading parsed))
|
||||
(url (journelly-entry-url parsed)))
|
||||
;; Build the initial content
|
||||
(let ((initial-content
|
||||
(concat
|
||||
":PROPERTIES:\n"
|
||||
":ID: " (org-id-new) "\n"
|
||||
(when url (concat ":ROAM_REFS: " url "\n"))
|
||||
(when heading (concat ":JOURNELLY_HEADING: " heading "\n"))
|
||||
":END:\n"
|
||||
"#+title: " title "\n\n"
|
||||
(or content "") "\n")))
|
||||
(org-roam-capture-
|
||||
:node (org-roam-node-create :title title)
|
||||
:props (list :immediate-finish nil
|
||||
:jump-to-captured t)
|
||||
:templates `(("d" "default" plain
|
||||
,initial-content
|
||||
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "")
|
||||
:unnarrowed t))))))
|
||||
|
||||
(ert-deftest test-journelly-parse-basic ()
|
||||
(let* ((entry " * [2025-10-08 Wed 22:39] @ -
|
||||
|
||||
Reference in New Issue
Block a user