Improve eldoc-box--window-side

* eldoc-box.el (eldoc-box--window-side): Now it consistently returns
'left' even if the left side is split vertically.
This commit is contained in:
Jeffrey Phillips 2023-05-26 14:00:01 -07:00 committed by Yuan Fu
parent ee7c978887
commit e58ecc4699
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -320,9 +320,13 @@ STR has to be a proper documentation, not empty string, not nil, etc."
"Return the side of the selected window.
Symbol left if the selected window is on the left, right if
on the right. Return left if there is only one window."
(let ((left-window (if tab-bar-mode
(window-at-x-y 5 (+ 5 (tab-bar-height nil t)))
(window-at 0 0))))
;; Get the window at point (x, y), where x = 0, y = the y coordinate
;; of point. If this window is the selected window, the selected
;; window is on the left, otherwise the selected window is on the
;; right.
(let* ((y (cdr (posn-x-y (posn-at-point))))
(top (nth 1 (window-absolute-pixel-edges (selected-window))))
(left-window (window-at-x-y 0 (+ y top))))
(if (eq left-window (selected-window))
'left
'right)))