mirror of
https://github.com/chrisbarrett/nursery
synced 2025-08-19 13:43:32 -05:00
Make node heading formatter a custom var
This commit is contained in:
@@ -110,12 +110,7 @@ When called interactively, prompt the user for MAX-DEPTH."
|
|||||||
(if (equal id start-node-id)
|
(if (equal id start-node-id)
|
||||||
(magit-cancel-section)
|
(magit-cancel-section)
|
||||||
(let* ((seen-p (gethash id seen-ids))
|
(let* ((seen-p (gethash id seen-ids))
|
||||||
(face
|
(heading (funcall org-roam-review-title-formatter node)))
|
||||||
(cond
|
|
||||||
((zerop depth) 'magit-section-heading)
|
|
||||||
(seen-p 'font-lock-comment-face)
|
|
||||||
(t 'org-roam-title)))
|
|
||||||
(heading (propertize (org-roam-node-title node) 'font-lock-face face)))
|
|
||||||
(magit-insert-heading (org-roam-review-indent-string heading depth))
|
(magit-insert-heading (org-roam-review-indent-string heading depth))
|
||||||
(unless seen-p
|
(unless seen-p
|
||||||
(puthash id t seen-ids)
|
(puthash id t seen-ids)
|
||||||
|
@@ -90,6 +90,13 @@
|
|||||||
:group 'org-roam-review
|
:group 'org-roam-review
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
|
(defcustom org-roam-review-title-formatter #'org-roam-review-default-title-formatter
|
||||||
|
"Function that renders node title in review buffers.
|
||||||
|
|
||||||
|
It must take a node and return a (possibly propertized) string."
|
||||||
|
:group 'org-roam-review
|
||||||
|
:type 'function)
|
||||||
|
|
||||||
(defface org-roam-review-instructions
|
(defface org-roam-review-instructions
|
||||||
'((t
|
'((t
|
||||||
(:inherit font-lock-comment-face)))
|
(:inherit font-lock-comment-face)))
|
||||||
@@ -364,11 +371,14 @@ When called with a `C-u' prefix arg, clear the current filter."
|
|||||||
(insert formatted-preview)
|
(insert formatted-preview)
|
||||||
(insert "\n\n"))))
|
(insert "\n\n"))))
|
||||||
|
|
||||||
|
(defun org-roam-review-default-title-formatter (node)
|
||||||
|
(propertize (org-roam-node-title node)
|
||||||
|
'font-lock-face 'magit-section-secondary-heading))
|
||||||
|
|
||||||
(defun org-roam-review--insert-node (node)
|
(defun org-roam-review--insert-node (node)
|
||||||
(atomic-change-group
|
(atomic-change-group
|
||||||
(magit-insert-section section (org-roam-node-section (org-roam-node-id node) t)
|
(magit-insert-section section (org-roam-node-section (org-roam-node-id node) t)
|
||||||
(magit-insert-heading (propertize (org-roam-node-title node)
|
(magit-insert-heading (funcall org-roam-review-title-formatter node))
|
||||||
'font-lock-face 'magit-section-secondary-heading))
|
|
||||||
(oset section node node)
|
(oset section node node)
|
||||||
;; KLUDGE: Mofified macro-expansion of `magit-insert-section-body' that
|
;; KLUDGE: Mofified macro-expansion of `magit-insert-section-body' that
|
||||||
;; avoids unsetting the parent section's keymap.
|
;; avoids unsetting the parent section's keymap.
|
||||||
|
@@ -225,11 +225,10 @@ QUERY is a PRCE regexp string that will be passed to ripgrep."
|
|||||||
(pcase-dolist (`(,_file . ,group) (seq-group-by #'org-roam-node-file nodes))
|
(pcase-dolist (`(,_file . ,group) (seq-group-by #'org-roam-node-file nodes))
|
||||||
(when-let* ((top-node (-max-by (-on #'< #'org-roam-node-level)
|
(when-let* ((top-node (-max-by (-on #'< #'org-roam-node-level)
|
||||||
group) )
|
group) )
|
||||||
(node-id (org-roam-node-id top-node))
|
(node-id (org-roam-node-id top-node)))
|
||||||
(heading (org-link-display-format (org-roam-node-title top-node))))
|
|
||||||
(magit-insert-section section (org-roam-node-section node-id t)
|
(magit-insert-section section (org-roam-node-section node-id t)
|
||||||
(magit-insert-heading
|
(magit-insert-heading
|
||||||
(concat (propertize heading 'font-lock-face 'magit-section-heading)
|
(concat (funcall org-roam-review-title-formatter top-node)
|
||||||
" "
|
" "
|
||||||
(when-let* ((mat (org-roam-review-node-maturity top-node)))
|
(when-let* ((mat (org-roam-review-node-maturity top-node)))
|
||||||
(alist-get mat org-roam-review-maturity-emoji-alist nil nil #'equal))))
|
(alist-get mat org-roam-review-maturity-emoji-alist nil nil #'equal))))
|
||||||
|
Reference in New Issue
Block a user