mirror of
https://github.com/org-roam/org-roam
synced 2025-09-22 16:20:54 -05:00
Add customizable width for org-roam buffer
This commit is contained in:
21
org-roam.el
21
org-roam.el
@@ -4,6 +4,7 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
(require 'dash)
|
||||||
(require 'org-element)
|
(require 'org-element)
|
||||||
(require 'async)
|
(require 'async)
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
@@ -395,11 +396,27 @@ Valid states are 'visible, 'exists and 'none."
|
|||||||
((get-buffer org-roam-buffer) 'exists)
|
((get-buffer org-roam-buffer) 'exists)
|
||||||
(t 'none))))
|
(t 'none))))
|
||||||
|
|
||||||
|
(defun org-roam--set-width (width)
|
||||||
|
"Set the width of the org-roam buffer to `WIDTH'."
|
||||||
|
(unless (one-window-p)
|
||||||
|
(let ((window-size-fixed)
|
||||||
|
(w (max width window-min-width)))
|
||||||
|
(cond
|
||||||
|
((> (window-width) w)
|
||||||
|
(shrink-window-horizontally (- (window-width) w)))
|
||||||
|
((< (window-width) w)
|
||||||
|
(enlarge-window-horizontally (- w (window-width))))))))
|
||||||
|
|
||||||
(defun org-roam--setup-buffer ()
|
(defun org-roam--setup-buffer ()
|
||||||
"Setup the `org-roam' buffer at the `org-roam-position'."
|
"Setup the `org-roam' buffer at the `org-roam-position'."
|
||||||
|
(save-excursion
|
||||||
|
(-> (get-buffer-create org-roam-buffer)
|
||||||
(display-buffer-in-side-window
|
(display-buffer-in-side-window
|
||||||
(get-buffer-create org-roam-buffer)
|
`((side . ,org-roam-position)))
|
||||||
`((side . ,org-roam-position))))
|
(select-window))
|
||||||
|
(org-roam--set-width
|
||||||
|
(round (* (frame-width)
|
||||||
|
org-roam-buffer-width)))))
|
||||||
|
|
||||||
(defun org-roam ()
|
(defun org-roam ()
|
||||||
"Pops up the window `org-roam-buffer' accordingly."
|
"Pops up the window `org-roam-buffer' accordingly."
|
||||||
|
Reference in New Issue
Block a user