Thanks for your explanations... (although I will need some time to think about and understand them)
>> Also, I would expect that a hook just calls the hook function, and it would
>> not 'restore the window
>> selected before the hook'. I would say the restoring is undesired behavior.
>
> The idea is probably that a function on that hook should be allowed to
> inadvertently select some other window and have the hook runner fix
> that. Maybe Stefan can tell us more.
No, IIRC it is just a consequence of needing to select windows when
running the local part of the hook (since that part is supposed to be
run for every window (which was modified) displaying that buffer).
Stefan