From 6644cb27a902b2ceeca89e83fde31e6ad01be79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Egil=20Hoftun=20Kv=C3=A6stad?= <103839750+toregilhk@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:56:42 +0200 Subject: [PATCH] (feat): allow a custom heading for a backlinks section (#2333) Allow the user to set a custom heading for a backlinks section in the org-roam buffer --- CHANGELOG.md | 1 + org-roam-mode.el | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0383b5a..0cd2a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## TBD ### Breaking ### Added +- [#2333](https://github.com/org-roam/org-roam/pull/2333) buffer: allow a custom heading for a backlink section - [#2449](https://github.com/org-roam/org-roam/pull/2449) extract rg-command builder function from unlinked-references ### Removed ### Fixed diff --git a/org-roam-mode.el b/org-roam-mode.el index af9d910..c93a4d2 100644 --- a/org-roam-mode.el +++ b/org-roam-mode.el @@ -514,17 +514,20 @@ Sorts by title." (string< (org-roam-node-title (org-roam-backlink-source-node a)) (org-roam-node-title (org-roam-backlink-source-node b)))) -(cl-defun org-roam-backlinks-section (node &key (unique nil) (show-backlink-p nil)) +(cl-defun org-roam-backlinks-section (node &key (unique nil) (show-backlink-p nil) + (section-heading "Backlinks:")) "The backlinks section for NODE. When UNIQUE is nil, show all positions where references are found. When UNIQUE is t, limit to unique sources. When SHOW-BACKLINK-P is not null, only show backlinks for which -this predicate is not nil." +this predicate is not nil. + +SECTION-HEADING is the string used as a heading for the backlink section." (when-let ((backlinks (seq-sort #'org-roam-backlinks-sort (org-roam-backlinks-get node :unique unique)))) (magit-insert-section (org-roam-backlinks) - (magit-insert-heading "Backlinks:") + (magit-insert-heading section-heading) (dolist (backlink backlinks) (when (or (null show-backlink-p) (and (not (null show-backlink-p))