capture buffer for journelly entries

This commit is contained in:
Willem van den Ende
2025-10-11 14:59:08 +01:00
parent 1b87d0878a
commit 41ac6ca98c
+25 -8
View File
@@ -29,18 +29,35 @@
(defun journelly-convert-entry () (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) (interactive)
(let* ((entry-text (if (use-region-p) (let* ((entry-text (if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end)) (buffer-substring-no-properties (region-beginning) (region-end))
(buffer-substring-no-properties (point-min) (point-max)))) (buffer-substring-no-properties (point-min) (point-max))))
(parsed (journelly-parse-entry entry-text))) (parsed (journelly-parse-entry entry-text))
(org-roam-capture- (title (journelly-entry-title parsed))
:node (org-roam-node-create :title (journelly-entry-title parsed)) (content (journelly-entry-content parsed))
:props `(:immediate-finish t (heading (journelly-entry-heading parsed))
:journelly-heading ,(journelly-entry-heading parsed) (url (journelly-entry-url parsed)))
:journelly-url ,(journelly-entry-url parsed) ;; Build the initial content
:journelly-content ,(journelly-entry-content parsed))))) (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 () (ert-deftest test-journelly-parse-basic ()
(let* ((entry " * [2025-10-08 Wed 22:39] @ - (let* ((entry " * [2025-10-08 Wed 22:39] @ -