Subject: Re: bug#8789: 23.3; debug backtrace buffer changes window on step-through

From: Stefan Monnier <[email-masked]>
Date: Thu, 09 Feb 2012 13:21:39 -0500

> I don't know why this problem doesn't get fixed.  It is an annoying
> problem, and a fix need not to be complicated - on the contrary.
> It should IMHO be sufficient to add to the

>   (pop-to-buffer debugger-buffer)

> call in `debug' an action argument that ensures that always the same
> window is chosen, by an deterministic algorithm.  For example:

>   (pop-to-buffer debugger-buffer
>      '((lambda (buffer _)
>          (let ((first-win (frame-first-window)))
>            (select-window first-win)
>            (switch-to-buffer buffer)
>            first-win))))

> would always choose the first window for *Backtrace*.

The general approach sounds good, but we should probably try to refine
it so as to minimize changes in behavior, and so it works right in the
multi-frame and even multi-terminal case.

We could try to store the last-used-window in a variable
`debugger-last-used-window' and use that window after checking that it's
still live and is visible in the selected terminal.

        Stefan