From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#32607: 27.0.50; pop-to-buffer in next-error-no-select Date: Thu, 13 Sep 2018 21:34:24 -0400 Message-ID: References: <87a7p0alxv.fsf@mail.linkov.net> <5B8B8DCE.4070704@gmx.at> <87efebjzbd.fsf@mail.linkov.net> <5B8CE360.5030700@gmx.at> <877ek2tdqx.fsf@mail.linkov.net> <5B8E3998.3050907@gmx.at> <87o9ddc8yc.fsf@mail.linkov.net> <5B8F8A1B.3030807@gmx.at> <8736unzjit.fsf@mail.linkov.net> <5B90D17D.5080605@gmx.at> <87efe6iaws.fsf@mail.linkov.net> <5B9228A3.4020700@gmx.at> <87sh2j36jw.fsf@mail.linkov.net> <5B94DC6C.6090107@gmx.at> <5B9A15C4.5010905@gmx.at> <87y3c5ov87.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1536888789 21334 195.159.176.226 (14 Sep 2018 01:33:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Sep 2018 01:33:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32607@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 14 03:33:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0cym-0005Q5-Sv for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Sep 2018 03:33:05 +0200 Original-Received: from localhost ([::1]:47093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0d0t-0000w0-3k for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Sep 2018 21:35:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0d0k-0000vi-3A for bug-gnu-emacs@gnu.org; Thu, 13 Sep 2018 21:35:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0d0g-0008Sh-Tp for bug-gnu-emacs@gnu.org; Thu, 13 Sep 2018 21:35:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g0d0g-0008SD-NV for bug-gnu-emacs@gnu.org; Thu, 13 Sep 2018 21:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g0d0g-0005WV-Dr for bug-gnu-emacs@gnu.org; Thu, 13 Sep 2018 21:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Sep 2018 01:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32607 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32607-submit@debbugs.gnu.org id=B32607.153688886921186 (code B ref 32607); Fri, 14 Sep 2018 01:35:02 +0000 Original-Received: (at 32607) by debbugs.gnu.org; 14 Sep 2018 01:34:29 +0000 Original-Received: from localhost ([127.0.0.1]:39852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0d09-0005Vd-0A for submit@debbugs.gnu.org; Thu, 13 Sep 2018 21:34:29 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:32984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0d07-0005VU-2E for 32607@debbugs.gnu.org; Thu, 13 Sep 2018 21:34:27 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w8E1YPrU027316; Thu, 13 Sep 2018 21:34:25 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id F30096A66C; Thu, 13 Sep 2018 21:34:24 -0400 (EDT) In-Reply-To: <87y3c5ov87.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 14 Sep 2018 02:04:08 +0300") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6373=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6373> : inlines <6878> : streams <1798380> : uri <2709965> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:150306 Archived-At: >> Indeed. I guess for this reason next-error-no-select might want to >> let-bind display-buffer-overriding-action to something like >> (nil (inhibit-same-window . t)) during the call to next-error. > > Then the same overriding should be applied to both: > > diff --git a/lisp/simple.el b/lisp/simple.el > index ffd7fcc067..17ebcb2e16 100644 > --- a/lisp/simple.el > +++ b/lisp/simple.el > @@ -383,9 +383,10 @@ next-error-no-select > Finds and highlights the source line like \\[next-error], but does not > select the source buffer." > (interactive "p") > - (let ((next-error-highlight next-error-highlight-no-select)) > + (let ((next-error-highlight next-error-highlight-no-select) > + (display-buffer-overriding-action '(nil (inhibit-same-window . t)))) > (next-error n)) > - (let ((display-buffer-overriding-action '(display-buffer-reuse-window))) > + (let ((display-buffer-overriding-action '(nil (inhibit-same-window . t)))) > ;; Override user customization such as display-buffer-same-window > ;; and use display-buffer-reuse-window to ensure next-error-last-buffer > ;; is displayed somewhere, not necessarily in the same window (bug#32607). > (pop-to-buffer next-error-last-buffer) The first inhibit-same-window should hopefully make the second unnecessary. If the first fails to do its job or somehow indirectly causes the original buffer not to be displayed in the original window, I'm not really sure what we should do about it. IOW, for the second part I'm not sure either of display-buffer-reuse-window or inhibit-same-window is clearly superior to the other. Maybe to get closer to "the ideal", we should go for something like: (let* ((orig-window (selected-window)) (orig-buf (window-buffer orig-window))) (let ((next-error-highlight next-error-highlight-no-select) (display-buffer-overriding-action '(nil (inhibit-same-window . t)))) (next-error n)) (cond ((eql (window-buffer orig-window) next-error-last-buffer) ;; inhibit-same-window did its job, we can just return to the original ;; window. (select-window orig-window)) ((eql orig-buf next-error-last-buffer) ;; Somehow the original window was affected by `next-error`, so ;; we need to work harder to bring the buffer back. (select-window orig-window) (pop-to-buffer-same-window next-error-last-buffer)) (t ;; Something weird is going on. We don't really know where we were ;; (orig-window was not showing the buffer where we were supposed ;; to "stay"), so let's just try and keep both buffers displayed ;; while at the same time trying not to gratuitously creating new ;; windows either. (let ((display-buffer-overriding-action '(display-buffer-reuse-window (inhibit-same-window . t)))) (pop-to-buffer next-error-last-buffer))))) But maybe we should instead trust inhibit-same-window to do its job and go for a simple: (save-selected-window (let ((next-error-highlight next-error-highlight-no-select) (display-buffer-overriding-action '(nil (inhibit-same-window . t)))) (next-error n))) -- Stefan