From cc3689f30f69260d89eb59959f6196bbe8f9e1ea Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Sat, 12 Mar 2022 21:24:11 -0800 Subject: [PATCH] (feat)buffer: pass args to org-mode-section-functions (#2123) * (feat)buffer: pass args to org-mode-section-functions * update docs --- doc/org-roam.org | 9 +++++---- doc/org-roam.texi | 12 ++++++------ org-roam-mode.el | 9 ++++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/org-roam.org b/doc/org-roam.org index ae8ddfe..260e384 100644 --- a/doc/org-roam.org +++ b/doc/org-roam.org @@ -648,13 +648,14 @@ To configure what sections are displayed in the buffer, set ~org-roam-mode-secti Note that computing unlinked references may be slow, and has not been added in by default. -Or, if you want to render unique sources for backlinks (and also keep rendering reference links), set ~org-roam-mode-section-functions~ as follows: +For each section function, you can pass args along to modify its behaviour. For +example, if you want to render unique sources for backlinks (and also keep +rendering reference links), set ~org-roam-mode-section-functions~ as follows: #+begin_src emacs-lisp (setq org-roam-mode-section-functions - (list - (lambda (node) (org-roam-backlinks-section node :unique t)) - #'org-roam-reflinks-section)) + '((org-roam-backlinks-section :unique t) + org-roam-reflinks-section)) #+end_src ** Configuring the Org-roam buffer display diff --git a/doc/org-roam.texi b/doc/org-roam.texi index c155663..38d0ed4 100644 --- a/doc/org-roam.texi +++ b/doc/org-roam.texi @@ -988,16 +988,16 @@ To configure what sections are displayed in the buffer, set @code{org-roam-mode- Note that computing unlinked references may be slow, and has not been added in by default. -Or, if you want to render unique sources for backlinks (and also keep rendering reference links), set @code{org-roam-mode-section-functions} as follows: +For each section function, you can pass args along to modify its behaviour. For +example, if you want to render unique sources for backlinks (and also keep +rendering reference links), set @code{org-roam-mode-section-functions} as follows: @lisp - (setq org-roam-mode-section-functions - (list - (lambda (node) (org-roam-backlinks-section node :unique t)) - #'org-roam-reflinks-section)) +(setq org-roam-mode-section-functions + '((org-roam-backlinks-section :unique t) + org-roam-reflinks-section)) @end lisp - @node Configuring the Org-roam buffer display @section Configuring the Org-roam buffer display diff --git a/org-roam-mode.el b/org-roam-mode.el index 234455c..b12b5b4 100644 --- a/org-roam-mode.el +++ b/org-roam-mode.el @@ -228,7 +228,14 @@ buffer." (org-roam-node-title org-roam-buffer-current-node)) (magit-insert-section (org-roam) (magit-insert-heading) - (run-hook-with-args 'org-roam-mode-section-functions org-roam-buffer-current-node)) + (dolist (section-fn org-roam-mode-section-functions) + (pcase section-fn + ((pred functionp) + (funcall section-fn org-roam-buffer-current-node)) + (`(,fn . ,args) + (apply fn (cons org-roam-buffer-current-node args))) + (_ + (user-error "Invalid `org-roam-mode-section-functions specification.'"))))) (run-hooks 'org-roam-buffer-postrender-functions) (goto-char 0)))