created display-buffer-in-side-window wrapper function

The old display-buffer-alist thing did not work like I expected it to,
so we removed it.

Instead of trying to update display-buffer-alist
when the screen resizes via a hook, we just create our own display function that
can be used in display-buffer-alist directly. The function takes a
"which-side" property in the alist, the property holds a function that returns
which side the new buffer will snap to when invoked. The display
function then creates a new alist with the side property and any other
properties were passed in, and calls display-buffer-in-side-window
with the new alist.

This allows us to use this function as if it were
display-buffer-in-side-window, but with an extra property to decide
which side the window snaps to each time the function is invoked. This
is useful if you want side windows to snap to different parts of the
screen based on the current size of the frame, or anything else.
master
John Turner 2 years ago
parent a9b93ae544
commit d314fe16f7
No known key found for this signature in database
GPG Key ID: 422FE10CC41A94A2

@ -1,6 +0,0 @@
(defvar config-display-buffer-gaps-width 20)
(defun config-display-buffer-which-side ()
(if (> (+ (frame-pixel-width) config-display-buffer-gaps-width) (/ (x-display-pixel-width) 2))
'right
'bottom))

@ -0,0 +1,7 @@
(defun config-display-buffer-frame-wide-p ()
(> (frame-pixel-width) (/ (x-display-pixel-width) 2)))
(defun config-display-buffer-best-side (buffer alist)
(let* ((side (funcall (alist-get 'which-side alist)))
(alist (append (cdr alist) (list (cons 'side side)))))
(display-buffer-in-side-window buffer alist)))

@ -1,5 +1,5 @@
(setq display-buffer-base-action '(display-buffer-same-window display-buffer-reuse-window))
(load "config-display-buffer-alist")
(load "config-display-buffer-best-side")
(provide 'config-display-buffer)

@ -5,9 +5,11 @@
(add-hook 'flycheck-error-list-mode-hook (lambda () (visual-line-mode 1)))
(add-to-list 'display-buffer-alist '("\\*Flycheck errors.*"
(display-buffer-in-side-window)
(side . (config-display-buffer-which-side))
(window-height . 15)
(window-width . 75)))
(config-display-buffer-best-side)
(which-side . (lambda ()
(if (config-display-buffer-frame-wide-p)
'right
'bottom)))))
(provide 'config-flycheck)

@ -3,9 +3,10 @@
(load "config-flymake-hooks")
(add-to-list 'display-buffer-alist '("\\*Flymake diagnostics.*"
(display-buffer-in-side-window)
(side . (config-display-buffer-which-side))
(window-height . 15)
(window-width . 75)))
(config-display-buffer-best-side)
(which-side . (lambda ()
(if (config-display-buffer-frame-wide-p)
'right
'bottom)))))
(provide 'config-flymake)

Loading…
Cancel
Save