Run org-roam-preview-postprocess-functions over org-roam-review previews

This commit is contained in:
Chris Barrett
2022-08-29 16:24:48 +12:00
parent b07e1cb14d
commit 338eab7a1a

View File

@@ -330,16 +330,21 @@ When called with a `C-u' prefix arg, clear the current filter."
str)) str))
(cl-defun org-roam-review-insert-preview (node &optional (depth 0)) (cl-defun org-roam-review-insert-preview (node &optional (depth 0))
(magit-insert-section preview (org-roam-preview-section) (magit-insert-section section (org-roam-preview-section)
(let* ((start (org-roam-node-point node)) (let* ((start (org-roam-node-point node))
(file (org-roam-node-file node)) (file (org-roam-node-file node))
(content (org-roam-fontify-like-in-org-mode (org-roam-preview-get-contents file start)))) (preview (org-roam-fontify-like-in-org-mode (org-roam-preview-get-contents file start)))
(oset preview file file) (post-formatters
(oset preview point start) (append org-roam-preview-postprocess-functions
(insert (org-roam-review-indent-string (if (string-blank-p (string-trim-left content)) (list (lambda (content)
(org-roam-review-indent-string (if (string-blank-p (string-trim-left content))
(propertize "(Empty)" 'font-lock-face 'font-lock-comment-face) (propertize "(Empty)" 'font-lock-face 'font-lock-comment-face)
content) content)
depth)) depth)))))
(formatted-preview (seq-reduce (lambda (str fn) (funcall fn str)) post-formatters preview)))
(oset section file file)
(oset section point start)
(insert formatted-preview)
(insert "\n\n")))) (insert "\n\n"))))
(defun org-roam-review--insert-node (node) (defun org-roam-review--insert-node (node)