From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#32607: 27.0.50; pop-to-buffer in next-error-no-select Date: Sun, 16 Sep 2018 02:31:44 +0300 Organization: LINKOV.NET Message-ID: <878t42z5tz.fsf@mail.linkov.net> 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 1537056154 4168 195.159.176.226 (16 Sep 2018 00:02:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Sep 2018 00:02:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 32607@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 16 02:02:30 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 1g1KWC-0000vo-OM for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Sep 2018 02:02:29 +0200 Original-Received: from localhost ([::1]:57157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1KYJ-0000iV-FR for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Sep 2018 20:04:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1KXg-0000Ov-3C for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2018 20:04:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1KKA-0006gD-T2 for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2018 19:50:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g1KKA-0006g5-Ox for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2018 19:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g1KKA-0003Aw-It for bug-gnu-emacs@gnu.org; Sat, 15 Sep 2018 19:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Sep 2018 23:50: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.153705537012141 (code B ref 32607); Sat, 15 Sep 2018 23:50:02 +0000 Original-Received: (at 32607) by debbugs.gnu.org; 15 Sep 2018 23:49:30 +0000 Original-Received: from localhost ([127.0.0.1]:41820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1KJe-00039l-6P for submit@debbugs.gnu.org; Sat, 15 Sep 2018 19:49:30 -0400 Original-Received: from pop.dreamhost.com ([64.90.62.162]:37888 helo=pdx1-sub0-mail-a20.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1KJc-00039d-M4 for 32607@debbugs.gnu.org; Sat, 15 Sep 2018 19:49:28 -0400 Original-Received: from pdx1-sub0-mail-a20.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a20.g.dreamhost.com (Postfix) with ESMTP id DB7518103A; Sat, 15 Sep 2018 16:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=nAhpcwYaF1qEm2GZS8+xafKWen0=; b= BLD8fh76Q1HeS6gSdV8M8HF3NAh1PoY30bkZThjcGUKckeV4xC/qiYnWOk8IEsLl 8sHBcqh529IS3m7fwLna+kXF7MBtKGFutI8Q5+/tC5+2IvH+bdHSexe1tzUfdQLN b8WI/6wooeTpbeolJF0QRgA1QVdOZcOmVkg4VYKikrY= Original-Received: from localhost.linkov.net (m91-129-107-237.cust.tele2.ee [91.129.107.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a20.g.dreamhost.com (Postfix) with ESMTPSA id CBAB580236; Sat, 15 Sep 2018 16:49:25 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a20 X-DH-BACKEND: pdx1-sub0-mail-a20 In-Reply-To: (Stefan Monnier's message of "Thu, 13 Sep 2018 21:34:24 -0400") 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:150344 Archived-At: > 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))))) I see that such explicit handling even supports the case when next-error-last-buffer gets changed on different frames (when using next-error-buffer-on-selected-frame). > 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))) This is much simpler. Actually, this is what I wanted to propose as a solution to Martin in one of previous messages, but I mistakenly wrote save-window-excursion whereas I actually intended save-selected-window.