weechat.el
weechat.el copied to clipboard
Read-marker doesn't match window width when window/frame not selected
I can reproduce this by waiting for the read marker hooks to be triggered with the a different-sized non-weechat window selected. The new read-marker's width is the width of the selected window, no the weechat buffer's window.
The bug pertains to the use of window-width
inside only a with-current-buffer
and not with-selected-window
. My local monkeypatch is as follows:
(defun bqv/weechat-read-marker-advice (old-function &rest args)
(let ((window (get-buffer-window (current-buffer) t)))
(if window
(with-selected-window (get-buffer-window (current-buffer) t)
(apply old-function args))
(apply old-function args))))
(advice-add 'weechat-read-marker--set-overlay
:around 'bqv/weechat-read-marker-advice)
Feel free to retrofit this as you wish.
Oh, a better thought, you could actually just replace (window-width)
with
(let ((widths (mapcar (lambda (w) (with-selected-window w (window-width)))
(get-buffer-window-list (current-buffer) nil t))))
(if (null widths)
1
(apply #'min widths)))
which gets the minimum window width for the buffer across all windows, or 1 if it's not visible. This should be the correct behaviour (and therefore works better than my monkeypatch).