Subject: Re: bug#38164: quit-restore-window doesn't restore point in man

From: martin rudalics <[email-masked]>
Date: Wed, 13 Nov 2019 09:04:12 +0100

> Removing these lines from 'quit-restore-window' fixes the problem:
 >
 >        ;; Select old window.
 >        (when (window-live-p (nth 2 quit-restore))
 >          (select-window (nth 2 quit-restore)))
 >
 > If there lines are the whole purpose of 'quit-restore-window',
 > then in man.el we need to reselect the original window explicitly:
 >
 > diff --git a/lisp/man.el b/lisp/man.el
 > index ce01fdc805..76890f74a9 100644
 > --- a/lisp/man.el
 > +++ b/lisp/man.el
 > @@ -1469,8 +1469,10 @@ Man-bgproc-sentinel
 >
 >         (when delete-buff
 >           (if (window-live-p (get-buffer-window Man-buffer t))
 > -            (quit-restore-window
 > -             (get-buffer-window Man-buffer t) 'kill)
 > +            (progn
 > +              (quit-restore-window
 > +               (get-buffer-window Man-buffer t) 'kill)
 > +              (select-window (old-selected-window)))
 >             (kill-buffer Man-buffer)))
 >
 >         (when message

I'm completely lost now.  Can you tell me in a detailed fashion what
goes wrong here?  Is the window stored in (nth 2 quit-restore) the
wrong window right from the outset?  Or is it in a sense falsified by
what happens later during minibuffer interaction?

martin