From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#8789: 23.3; debug backtrace buffer changes window on step-through Date: Wed, 15 Feb 2012 18:00:59 +0100 Message-ID: <4F3BE4CB.3030909@gmx.at> References: <4DE8DF63.5050405@gmx.at> <87haz0po82.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1329337364 16798 80.91.229.3 (15 Feb 2012 20:22:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Feb 2012 20:22:44 +0000 (UTC) Cc: michael_heerdegen@web.de, 8789@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 15 21:22:42 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RxlNA-00071M-PM for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Feb 2012 21:22:41 +0100 Original-Received: from localhost ([::1]:40170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxlN9-00032y-Nk for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Feb 2012 15:22:39 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxiFR-00077Y-DF for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2012 12:02:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxiFI-00024b-56 for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2012 12:02:29 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxiFI-00024X-3S for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2012 12:02:20 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RxiGw-0002KG-8S for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2012 12:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Feb 2012 17:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8789 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8789-submit@debbugs.gnu.org id=B8789.13293253868869 (code B ref 8789); Wed, 15 Feb 2012 17:04:02 +0000 Original-Received: (at 8789) by debbugs.gnu.org; 15 Feb 2012 17:03:06 +0000 Original-Received: from localhost ([127.0.0.1]:41647 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RxiFy-0002Im-7Z for submit@debbugs.gnu.org; Wed, 15 Feb 2012 12:03:06 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:38797) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1RxiFp-0002IK-Td for 8789@debbugs.gnu.org; Wed, 15 Feb 2012 12:03:00 -0500 Original-Received: (qmail invoked by alias); 15 Feb 2012 17:01:02 -0000 Original-Received: from 62-47-42-178.adsl.highway.telekom.at (EHLO [62.47.42.178]) [62.47.42.178] by mail.gmx.net (mp032) with SMTP; 15 Feb 2012 18:01:02 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/6sLUYhTX6YMuVfTPbC8GMU5hmvsCyKpQBoRpTYt f4QHjW/QKYME9E In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:56926 Archived-At: > 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. We could also try `window-prev-buffers' and `window-next-buffers' as in the rather untested patch below. martin === modified file 'lisp/window.el' --- lisp/window.el 2012-02-12 05:10:30 +0000 +++ lisp/window.el 2012-02-15 16:54:41 +0000 @@ -4846,6 +4846,39 @@ (and pop-up-windows (display-buffer-pop-up-window buffer alist)))) +(defun window-previously-showing (buffer &optional all-frames dedicated) + "Return a window that previously showed BUFFER. +A minibuffer window is never a candidate. A dedicated window is +never a candidate unless DEDICATED is non-nil, so if all windows +are dedicated, the value is nil. Avoid returning the selected +window if possible. + +The following non-nil values of the optional argument ALL-FRAMES +have special meanings: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames on + the current terminal. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames on the current terminal. + +- A frame means consider all windows on that frame only. + +Any other value of ALL-FRAMES means consider all windows on the +selected frame and no others." + (let (best-window second-best-window) + (dolist (window (window-list-1 nil 'nomini all-frames)) + (when (and (or (assq buffer (window-prev-buffers window)) + (assq buffer (window-next-buffers window))) + (or dedicated (not (window-dedicated-p window)))) + (if (eq window (selected-window)) + (setq second-best-window window) + ;; We probably should throw WINDOW here. + (setq best-window window)))) + (or best-window second-best-window))) + (defun display-buffer-use-some-window (buffer alist) "Display BUFFER in an existing window. Search for a usable window, set that window to the buffer, and @@ -4864,7 +4897,8 @@ (unwind-protect (setq window ;; Reuse an existing window. - (or (get-lru-window frame) + (or (window-previously-showing buffer 'visible) + (get-lru-window frame) (let ((window (get-buffer-window buffer 'visible))) (unless (and not-this-window (eq window (selected-window)))