(fix)buffer: update defcustom for org-roam-mode-section-functions (#2124)

This commit is contained in:
Jethro Kuan
2022-03-13 09:04:55 -07:00
committed by GitHub
parent cc3689f30f
commit cce6a05630
5 changed files with 40 additions and 20 deletions

View File

@ -16,6 +16,7 @@
- [#2050](https://github.com/org-roam/org-roam/pull/2050) core: add `FILTER-FN` to `org-roam-node-random` - [#2050](https://github.com/org-roam/org-roam/pull/2050) core: add `FILTER-FN` to `org-roam-node-random`
- [#2065](https://github.com/org-roam/org-roam/pull/2065) dailies: add `keys` argument to the remaining dailies functions `org-roam-dailies-goto-yesterday`/`-today`/`-tomorrow`/`-date` and `org-roam-dailies-capture-yesterday`/`-tomorrow`/`-date` to give the abilty to get into a capture buffer bypassing the selection screen in all dailies commands. Extension of #2055 - [#2065](https://github.com/org-roam/org-roam/pull/2065) dailies: add `keys` argument to the remaining dailies functions `org-roam-dailies-goto-yesterday`/`-today`/`-tomorrow`/`-date` and `org-roam-dailies-capture-yesterday`/`-tomorrow`/`-date` to give the abilty to get into a capture buffer bypassing the selection screen in all dailies commands. Extension of #2055
- [#2079](https://github.com/org-roam/org-roam/pull/2079) capture: ensure that `:ref` info captured in all cases. - [#2079](https://github.com/org-roam/org-roam/pull/2079) capture: ensure that `:ref` info captured in all cases.
- [#2121](https://github.com/org-roam/org-roam/pull/2121) buffer: add unique option to `org-roam-backlinks-section`
### Removed ### Removed
### Fixed ### Fixed
@ -30,6 +31,7 @@
- [#2040](https://github.com/org-roam/org-roam/pull/2040) completions: fix completions display-width for Helm users - [#2040](https://github.com/org-roam/org-roam/pull/2040) completions: fix completions display-width for Helm users
- [#2025](https://github.com/org-roam/org-roam/pull/2025) chore: removed the dependencies on f.el and s.el - [#2025](https://github.com/org-roam/org-roam/pull/2025) chore: removed the dependencies on f.el and s.el
- [#2109](https://github.com/org-roam/org-roam/pull/2109) capture: `org-roam-node-insert` places cursor after inserted link where appropriate - [#2109](https://github.com/org-roam/org-roam/pull/2109) capture: `org-roam-node-insert` places cursor after inserted link where appropriate
- [#2123](https://github.com/org-roam/org-roam/pull/2123), [#2124](https://github.com/org-roam/org-roam/pull/2124) buffer: `org-roam-mode-section-functions` renamed to `org-roam-mode-sections`, supports passing args into the section-rendering function
## 2.2.0 ## 2.2.0
### Added ### Added

View File

@ -636,10 +636,10 @@ There are currently 3 provided widget types:
- Unlinked references :: View nodes that contain text that match the nodes - Unlinked references :: View nodes that contain text that match the nodes
title/alias but are not linked title/alias but are not linked
To configure what sections are displayed in the buffer, set ~org-roam-mode-section-functions~. To configure what sections are displayed in the buffer, set ~org-roam-mode-sections.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-roam-mode-section-functions (setq org-roam-mode-sections
(list #'org-roam-backlinks-section (list #'org-roam-backlinks-section
#'org-roam-reflinks-section #'org-roam-reflinks-section
;; #'org-roam-unlinked-references-section ;; #'org-roam-unlinked-references-section
@ -650,10 +650,10 @@ Note that computing unlinked references may be slow, and has not been added in b
For each section function, you can pass args along to modify its behaviour. For 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 example, if you want to render unique sources for backlinks (and also keep
rendering reference links), set ~org-roam-mode-section-functions~ as follows: rendering reference links), set ~org-roam-mode-sections~ as follows:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-roam-mode-section-functions (setq org-roam-mode-sections
'((org-roam-backlinks-section :unique t) '((org-roam-backlinks-section :unique t)
org-roam-reflinks-section)) org-roam-reflinks-section))
#+end_src #+end_src

View File

@ -976,10 +976,10 @@ There are currently 3 provided widget types:
title/alias but are not linked title/alias but are not linked
@end itemize @end itemize
To configure what sections are displayed in the buffer, set @code{org-roam-mode-section-functions}. To configure what sections are displayed in the buffer, set ~org-roam-mode-sections.
@lisp @lisp
(setq org-roam-mode-section-functions (setq org-roam-mode-sections
(list #'org-roam-backlinks-section (list #'org-roam-backlinks-section
#'org-roam-reflinks-section #'org-roam-reflinks-section
;; #'org-roam-unlinked-references-section ;; #'org-roam-unlinked-references-section
@ -990,10 +990,10 @@ Note that computing unlinked references may be slow, and has not been added in b
For each section function, you can pass args along to modify its behaviour. For 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 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: rendering reference links), set @code{org-roam-mode-sections} as follows:
@lisp @lisp
(setq org-roam-mode-section-functions (setq org-roam-mode-sections
'((org-roam-backlinks-section :unique t) '((org-roam-backlinks-section :unique t)
org-roam-reflinks-section)) org-roam-reflinks-section))
@end lisp @end lisp

View File

@ -229,6 +229,10 @@ nodes." org-id-locations-file)
'org-roam-remove-property 'org-roam-remove-property
'org-roam-property-remove "org-roam 2.1") 'org-roam-property-remove "org-roam 2.1")
(define-obsolete-variable-alias
'org-roam-mode-section-functions
'org-roam-mode-sections "org-roam 2.2.0")
;;; Obsolete functions ;;; Obsolete functions
(make-obsolete 'org-roam-get-keyword 'org-collect-keywords "org-roam 2.0") (make-obsolete 'org-roam-get-keyword 'org-collect-keywords "org-roam 2.0")

View File

@ -39,14 +39,28 @@
(defvar org-ref-buffer-hacked) (defvar org-ref-buffer-hacked)
;;; Options ;;; Options
(defcustom org-roam-mode-section-functions (list #'org-roam-backlinks-section (defcustom org-roam-mode-sections (list #'org-roam-backlinks-section
#'org-roam-reflinks-section) #'org-roam-reflinks-section)
"Functions that insert sections in the `org-roam-mode' based buffers. "A list of sections for the `org-roam-mode' based buffers.
Each function is called with one argument, which is an Each section is a function that is passed the an `org-roam-node'
`org-roam-node' for which the buffer will be constructed for. for which the section will be constructed for as the first
Normally this node is `org-roam-buffer-current-node'." argument. Normally this node is `org-roam-buffer-current-node'.
The function may also accept other optional arguments. Each item
in the list is either:
1. A function, which is called only with the `org-roam-node' as the argument
2. A list, containing the function and the optional arguments.
For example, one can add
(org-roam-backlinks-section :unique t)
to the list to pass :unique t to the section-rendering function."
:group 'org-roam :group 'org-roam
:type 'hook) :type `(repeat (choice (symbol :tag "Function")
(list :tag "Function with arguments"
(symbol :tag "Function")
(repeat :tag "Arguments" :inline t (sexp :tag "Arg"))))))
(defcustom org-roam-buffer-postrender-functions (list) (defcustom org-roam-buffer-postrender-functions (list)
"Functions to run after the Org-roam buffer is rendered. "Functions to run after the Org-roam buffer is rendered.
@ -168,7 +182,7 @@ This mode is used by special Org-roam buffers, such as persistent
`org-roam-buffer' and dedicated Org-roam buffers `org-roam-buffer' and dedicated Org-roam buffers
\(`org-roam-buffer-display-dedicated'), which render the \(`org-roam-buffer-display-dedicated'), which render the
information in a section-like manner (see information in a section-like manner (see
`org-roam-mode-section-functions'), with which the user can `org-roam-mode-sections'), with which the user can
interact with." interact with."
:group 'org-roam :group 'org-roam
(face-remap-add-relative 'header-line 'org-roam-header-line)) (face-remap-add-relative 'header-line 'org-roam-header-line))
@ -228,14 +242,14 @@ buffer."
(org-roam-node-title org-roam-buffer-current-node)) (org-roam-node-title org-roam-buffer-current-node))
(magit-insert-section (org-roam) (magit-insert-section (org-roam)
(magit-insert-heading) (magit-insert-heading)
(dolist (section-fn org-roam-mode-section-functions) (dolist (section org-roam-mode-sections)
(pcase section-fn (pcase section
((pred functionp) ((pred functionp)
(funcall section-fn org-roam-buffer-current-node)) (funcall section org-roam-buffer-current-node))
(`(,fn . ,args) (`(,fn . ,args)
(apply fn (cons org-roam-buffer-current-node args))) (apply fn (cons org-roam-buffer-current-node args)))
(_ (_
(user-error "Invalid `org-roam-mode-section-functions specification.'"))))) (user-error "Invalid `org-roam-mode-sections' specification")))))
(run-hooks 'org-roam-buffer-postrender-functions) (run-hooks 'org-roam-buffer-postrender-functions)
(goto-char 0))) (goto-char 0)))