diff options
author | Brian Lester <[email protected]> | 2021-08-04 11:26:52 -0400 |
---|---|---|
committer | Brian Lester <[email protected]> | 2021-08-04 16:12:54 -0400 |
commit | 13a3a1bafb82fd35014ad71e3c0a4a97a216b623 (patch) | |
tree | 6d1e09b35939a020069ab3f8ad378957aea31562 | |
parent | 94f85a652ce7e1787d7e17264a5ec8cffcfe57e3 (diff) |
Allow user styling of citation nodes via templates.
This change updates the way that the title field is created for a
citation node without an underlying node.
Instead of manually calling `orb-bib-entry-get-value-function` and
building the title via concatenation, it uses `orb--pre-xpand-template`
to create a title.
The template used can be customized with the
`org-roam-ui-ref-title-template` variable.
-rw-r--r-- | org-roam-ui.el | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index 4cff4fa..b3a50eb 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -107,6 +107,14 @@ This can lead to some jank." :group 'org-roam-ui :type 'boolean) +(defcustom org-roam-ui-ref-title-template "%^{author-abbrev} (%^{year}) %^{title}" + "A template for title creation, used for references without an associated nodes. + +This uses `orb--pre-expand-template' under the hood and therefore only org-style +capture `%^{...}' are supported." + :group 'org-roam-ui + :type 'string) + (defvar org-roam-ui--ws-current-node nil "Var to keep track of which node you are looking at.") (defvar oru-ws nil @@ -169,14 +177,12 @@ Requires `org-roam-bibtex' and `bibtex-completion' (a dependency of `orb') to be loaded. Returns `ref' if an entry could not be found." (if (and org-roam-ui-find-ref-title (fboundp 'bibtex-completion-get-entry) - (boundp 'orb-bibtex-entry-get-value-function)) + (fboundp 'orb--pre-expand-template)) (if-let ((entry (bibtex-completion-get-entry ref))) - (concat - (funcall orb-bibtex-entry-get-value-function "author-abbrev" entry ref) - " (" - (funcall orb-bibtex-entry-get-value-function "year" entry ref) - ") " - (funcall orb-bibtex-entry-get-value-function "title" entry ref)) + ;; Create a fake capture template list, only the actual capture at 3 + ;; matters. Interpolate the bibtex entries, and extract the filled + ;; template from the return value. + (nth 3 (orb--pre-expand-template `("" "" plain ,org-roam-ui-ref-title-template) entry)) ref) ref)) |