(feat): allow org-roam-buffer-position to be a function (#1385)

Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
Samuel W. Flint
2021-01-15 23:43:00 -06:00
committed by GitHub
parent 05a9bc44f2
commit f10fbad386

View File

@ -64,11 +64,13 @@ Valid values are
* left,
* right,
* top,
* bottom."
* bottom,
* a function returning one of the above."
:type '(choice (const left)
(const right)
(const top)
(const bottom))
(const bottom)
function)
:group 'org-roam)
(defcustom org-roam-buffer-width 0.33
@ -293,14 +295,9 @@ Valid states are 'visible, 'exists and 'none."
(defun org-roam-buffer--get-create ()
"Set up the `org-roam' buffer at `org-roam-buffer-position'."
(let ((position
(if (member org-roam-buffer-position '(right left top bottom))
org-roam-buffer-position
(let ((text-quoting-style 'grave))
(lwarn '(org-roam) :error
"Invalid org-roam-buffer-position: %s. Defaulting to \\='right"
org-roam-buffer-position))
'right)))
(let ((position (if (functionp org-roam-buffer-position)
(funcall org-roam-buffer-position)
org-roam-buffer-position)))
(save-selected-window
(-> (get-buffer-create org-roam-buffer)
(display-buffer-in-side-window