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#20206: 25.0.50; [PATCH] keep diff-mode's window visible when we visit sources from diff-mode Date: Mon, 30 Mar 2015 10:37:33 +0200 Message-ID: <55190B4D.9070904@gmx.at> References: <87a8yzy5t4.fsf@secretsauce.net> <551456ED.8060101@gmx.at> <87twx4wztk.fsf@secretsauce.net> <55183DDD.7070303@gmx.at> <87r3s7wpe2.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020105050308070105050308" X-Trace: ger.gmane.org 1427704784 9618 80.91.229.3 (30 Mar 2015 08:39:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Mar 2015 08:39:44 +0000 (UTC) Cc: 20206@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 30 10:39:33 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YcVEJ-0000mq-7p for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Mar 2015 10:39:31 +0200 Original-Received: from localhost ([::1]:60257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcVEI-0002rB-MK for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Mar 2015 04:39:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcVCv-0000s3-TF for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2015 04:38:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcVCs-0004P5-Lt for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2015 04:38:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcVCs-0004P0-JU for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2015 04:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YcVCr-0008T1-US for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2015 04:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Mar 2015 08:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20206 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 20206-submit@debbugs.gnu.org id=B20206.142770466732509 (code B ref 20206); Mon, 30 Mar 2015 08:38:01 +0000 Original-Received: (at 20206) by debbugs.gnu.org; 30 Mar 2015 08:37:47 +0000 Original-Received: from localhost ([127.0.0.1]:39996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YcVCb-0008SH-Vi for submit@debbugs.gnu.org; Mon, 30 Mar 2015 04:37:46 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:49851) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YcVCZ-0008S0-3n for 20206@debbugs.gnu.org; Mon, 30 Mar 2015 04:37:44 -0400 Original-Received: from [194.166.85.52] ([194.166.85.52]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0Lqi70-1Z80Gi2bXG-00eP67; Mon, 30 Mar 2015 10:37:34 +0200 In-Reply-To: <87r3s7wpe2.fsf@secretsauce.net> X-Provags-ID: V03:K0:I4pGNvwCRHQeZmdQX5M2Lwhv/9muRu+O2T355E2+0cFNwqEO2QL gL4TEGyp6tPO1FCxw/rNzlWuNxX95yhyEqOtNvq8M8TExK2DZmli6m8B/Z3fBeDqdBn6mXV l8+MSLCbI/YpSVIYSCQitJyGM0i2QxSsdzhNX/HAmy6MTY8BFEnY10o/gqZ0GG/CgE5kfIJ GGXtpUoXgogBtRIzP+s7w== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:101038 Archived-At: This is a multi-part message in MIME format. --------------020105050308070105050308 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > I'm not sure what you mean: '((inhibit-same-window . t)) is not a valid > as an action argument to display-buffer, Sorry, I meant '(nil (inhibit-same-window . t)). > and emacs barfs if I try to use > it as such. I'm not at all married to using display-buffer-pop-up-window > here. If you have a better idea for solving 19901 (or if you think > there's nothing to fix), then I'm fine with it. I'm afraid we are miscommunicating or I am misssing something. You propose the following change: - (pop-to-buffer (current-buffer)) + (pop-to-buffer (current-buffer) '(display-buffer-use-some-window (inhibit-same-window . t))) I think this precludes the following scenario: Consider a frame that contains two windows. The user has set `split-height-threshold' and/or `split-width-threshold' to very small values which easily allow further splitting. In this case, a `pop-to-buffer' call for a buffer that doesn't appear on the frame yet will usually try to split one of the two windows and show the buffer in a third one. Agreed? Now with your proposed change `pop-to-buffer' will always use the "other window" for displaying the current buffer, thus overriding the user's customizations of `split-height-threshold' and `split-width-threshold'. The reason is that `display-buffer-pop-up-window' will not be called because `display-buffer-use-some-window' is always called first. Do you agree? And can we agree that such behavior would be wrong? Also, a user who wants to show the buffer in a separate frame via say (setq pop-up-frames t) will be disappointed as well. With a two windows frame he'll never get a new frame. Agreed? Maybe (pop-to-buffer (current-buffer) t) is already what we want here because we know that the current buffer is not shown in the selected window. Otherwise we could try a patch like the one I attached. Then we could do ... (pop-to-buffer (current-buffer) '(nil (previous-window))) ... if I got it right this time. WDYT? > Another wrinkle is that the behavior reported in 19901 as a bug is only > observable with particular geometries of the emacs X11 window. On my > machine, 19901 is reproducible if emacs takes up my whole screen > (1440x1050), but not if it takes only half (720x1050). Presumably emacs > thinks that splitting into a 3rd window will create new windows that are > too narrow. That is all to say that maybe 19901 is not a bug. I have no problems with Bug#19901. Let's care only about Bug#20206 here. martin --------------020105050308070105050308 Content-Type: text/plain; charset=windows-1252; name="window.el.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="window.el.diff" --- a/lisp/window.el +++ b/lisp/window.el @@ -6371,6 +6371,10 @@ Recognized alist entries include: window that already displays the buffer. See `display-buffer-reuse-window'. + `previous-window' -- A window `display-buffer-in-previous-window' + should use or nil to not try finding such a + window. + `pop-up-frame-parameters' -- Value specifies an alist of frame parameters to give a new frame, if one is created. @@ -6678,43 +6682,47 @@ selected frame if `display-buffer-reuse-frames' and `pop-up-frames' are both nil; search all frames on the current terminal if either of those variables is non-nil. -If ALIST has a `previous-window' entry, the window specified by -that entry will override any other window found by the methods -above, even if that window never showed BUFFER before." - (let* ((alist-entry (assq 'reusable-frames alist)) - (inhibit-same-window - (cdr (assq 'inhibit-same-window alist))) - (frames (cond - (alist-entry (cdr alist-entry)) - ((if (eq pop-up-frames 'graphic-only) - (display-graphic-p) - pop-up-frames) - 0) - (display-buffer-reuse-frames 0) - (t (last-nonminibuffer-frame)))) - best-window second-best-window window) - ;; Scan windows whether they have shown the buffer recently. - (catch 'best - (dolist (window (window-list-1 (frame-first-window) 'nomini frames)) - (when (and (assq buffer (window-prev-buffers window)) - (not (window-dedicated-p window))) - (if (eq window (selected-window)) - (unless inhibit-same-window - (setq second-best-window window)) - (setq best-window window) - (throw 'best t))))) - ;; When ALIST has a `previous-window' entry, that entry may override - ;; anything we found so far. - (when (and (setq window (cdr (assq 'previous-window alist))) - (window-live-p window) - (not (window-dedicated-p window))) - (if (eq window (selected-window)) - (unless inhibit-same-window - (setq second-best-window window)) - (setq best-window window))) - ;; Return best or second best window found. - (when (setq window (or best-window second-best-window)) - (window--display-buffer buffer window 'reuse alist)))) +If ALIST has a `previous-window' entry, the window specified in +the cdr of that entry will override any other window found by the +methods above, even if that window never showed BUFFER before. +If the cdr of that entry is nil, do not try to find a window that +previously showed BUFFER." + (unless (let ((previous-window (assq 'previous-window alist))) + (and previous-window (not (cdr previous-window)))) + (let* ((alist-entry (assq 'reusable-frames alist)) + (inhibit-same-window + (cdr (assq 'inhibit-same-window alist))) + (frames (cond + (alist-entry (cdr alist-entry)) + ((if (eq pop-up-frames 'graphic-only) + (display-graphic-p) + pop-up-frames) + 0) + (display-buffer-reuse-frames 0) + (t (last-nonminibuffer-frame)))) + best-window second-best-window window) + ;; Scan windows whether they have shown the buffer recently. + (catch 'best + (dolist (window (window-list-1 (frame-first-window) 'nomini frames)) + (when (and (assq buffer (window-prev-buffers window)) + (not (window-dedicated-p window))) + (if (eq window (selected-window)) + (unless inhibit-same-window + (setq second-best-window window)) + (setq best-window window) + (throw 'best t))))) + ;; When ALIST has a `previous-window' entry, that entry may override + ;; anything we found so far. + (when (and (setq window (cdr (assq 'previous-window alist))) + (window-live-p window) + (not (window-dedicated-p window))) + (if (eq window (selected-window)) + (unless inhibit-same-window + (setq second-best-window window)) + (setq best-window window))) + ;; Return best or second best window found. + (when (setq window (or best-window second-best-window)) + (window--display-buffer buffer window 'reuse alist))))) (defun display-buffer-use-some-window (buffer alist) "Display BUFFER in an existing window. --------------020105050308070105050308--