Subject: bug#32536: displayed width of man pages

From: martin rudalics <[email-masked]>
Date: Mon, 03 Sep 2018 09:31:18 +0200

> 1. In Man-mode we have to add hook window-size-change-functions only
 >     buffer-locally (using the arg LOCAL of add-hook) rather than globally,
 >     because otherwise we can't remove this hook when a Man buffer is
 >     not displayed anymore.

I can't follow you here.  Shouldn't we remove the hook _when_ a Man
buffer is not displayed anymore.  That is, when
'Man-window-size-change' detects that no Man buffer is displayed
anymore, remove it from 'window-size-change-functions' and re-add it
as soon as a Man buffer gets displayed again.

 >     But the problem is that buffer-local
 >     window-size-change-functions is called only when the current buffer
 >     is in Man-mode.  If it's not, it's not called even when resizing of
 >     the current non-Man buffer causes the resize of a Man-mode buffer
 >     in an adjacent window.
 >
 > 2. What if the same Man-mode buffer is displayed in two adjacent windows
 >     side-by-side?  I guess we need to find all windows with the same buffer,
 >     compare their widths, and call Man-update-manpage only in the window
 >     with minimal width.  Also it seems window-size-change-functions is
 >     not called twice for every window with Man-mode buffer, this is good.

I think 'Man-window-size-change' will have to take care of such cases.
Also we'll have to look into how 'follow-mode' works when displaying a
Man buffer in several side-by-side windows.

 > 3. When windows are resized using the mouse, is it possible to call
 >     window-size-change-functions only when the mouse button is released?
 >     This will increase responsiveness.  But the same problem will remain
 >     for keyboard resizing with e.g. C-x } } }
 >     A debounce-like function could help, but I can't find its Emacs Lisp
 >     implementation anywhere.   I mean something similar to
 >     https://stackoverflow.com/questions/15927371/what-does-debounce-do
 >     It's easy to implement using timers, but better to have idiomatic
 >     implementation.

I used a timer in 'mouse-autoselect-window'.  It might be interesting
to come up with a generic function.

martin