From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#33258: inhibit-select-window Date: Wed, 07 Nov 2018 10:22:38 +0100 Message-ID: <5BE2AEDE.1090109@gmx.at> References: <87muqpj8ib.fsf@mail.linkov.net> <5BE00E99.1020003@gmx.at> <87bm731abq.fsf@mail.linkov.net> <5BE154BC.4080707@gmx.at> <878t25vpd7.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1541582473 27055 195.159.176.226 (7 Nov 2018 09:21:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 7 Nov 2018 09:21:13 +0000 (UTC) Cc: 33258@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 07 10:21:09 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 1gKK1K-0006t2-DB for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Nov 2018 10:21:06 +0100 Original-Received: from localhost ([::1]:46743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKK3Q-0003LU-TY for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Nov 2018 04:23:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKK3L-0003J5-Aj for bug-gnu-emacs@gnu.org; Wed, 07 Nov 2018 04:23:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKK3F-00072M-2K for bug-gnu-emacs@gnu.org; Wed, 07 Nov 2018 04:23:09 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKK3C-00071L-Sm for bug-gnu-emacs@gnu.org; Wed, 07 Nov 2018 04:23:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gKK3C-0003li-KR for bug-gnu-emacs@gnu.org; Wed, 07 Nov 2018 04:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 09:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33258 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33258-submit@debbugs.gnu.org id=B33258.154158257414457 (code B ref 33258); Wed, 07 Nov 2018 09:23:02 +0000 Original-Received: (at 33258) by debbugs.gnu.org; 7 Nov 2018 09:22:54 +0000 Original-Received: from localhost ([127.0.0.1]:38130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKK34-0003l6-ES for submit@debbugs.gnu.org; Wed, 07 Nov 2018 04:22:54 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:37641) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKK32-0003kq-30 for 33258@debbugs.gnu.org; Wed, 07 Nov 2018 04:22:52 -0500 Original-Received: from [192.168.1.101] ([212.95.5.136]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MI5rO-1gN3bY3aRC-003t6k; Wed, 07 Nov 2018 10:22:42 +0100 Original-Received: from [192.168.1.101] ([212.95.5.136]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MI5rO-1gN3bY3aRC-003t6k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C3F4L3OZXJneKpp cbyt5EtkliYoP+nmliZwKc3p5lMBALnh3WepuVQEV6TcZFWI+7JXmxmAB5Vv8BPx2wEfWMMI 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:152122 Archived-At: > A prototype that demonstrates a problem-free implementation is: > > (advice-add 'vc-diff :around > (lambda (orig-fun &rest args) > (save-selected-window > (apply orig-fun args))) > '((name . inhibit-select-window))) > > A question is how to do something like this using 'display-buffer-alist' > with 'inhibit-select-window'. You cannot do that in a systematical way - 'display-buffer-alist' is agnostic of its clients. And don't forget clients of 'vc-diff' who might rely on the fact that the latter selects the window chosen. Ironically, they might do that for exactly the same reason as yours - they don't want the diffs window to get selected. Now suppose they do that by selecting the window preceding or following the diffs window in the cyclic order of windows right after the 'vc-diff' call ... So even your advice is not problem-free. > This is a huge task to inspect all existing pop-to-buffer calls > and to add 'allow-inhibit-select-window' where it's safe, or to change > the existing code to be safe (if this is possible at all). Nobody will ever acquire enough knowledge to do that. >> We could convert 'pop-to-buffer' calls to 'display-buffer' calls with >> a 'force-select-window' t alist entry. Users could override that with >> a 'force-select-window' nil entry. This would be the contrapositive >> of the 'inhibit-select-window' approach. > > Does this have the same problem of not making the displayed buffer > current? The task would remain the same: Inspect all 'pop-to-buffer' calls, possibly their callers and decide whether converting them is safe. In the 'vc-diff' case the following stretch already looks hairy: ;; Display the buffer, but at the end because it can change point. (pop-to-buffer (current-buffer)) ;; The diff process may finish early, so call `vc-diff-finish' ;; after `pop-to-buffer'; the former assumes the diff buffer is ;; shown in some window. (let ((buf (current-buffer))) (vc-run-delayed (vc-diff-finish buf (when verbose messages)))) I suppose the 'buf' binding is superfluous because 'pop-to-buffer' cannot "pop away" from the current buffer even if a user inhibits selecting the window chosen. But if that binding had a real purpose, then using 'inhibit-select-window' would probably affect it and 'vc-diff-finish' would work on the wrong buffer. Worse even. The brutal 'set-buffer' call in 'vc-diff' (right before entering 'diff-mode') already suggests that eventually selecting the diffs window becomes unavoidable. Otherwise, returning from 'vc-diff' would leave you with the diffs buffer current and a window not showing the diffs buffer selected - a very unpleasing configuration. Replacing the 'set-buffer' with 'with-current-buffer' is not devoid of its problems either: You cannot reliably nest a 'display-buffer' call in 'with-current-buffer' because 'display-buffer' might select a window on another frame at any time. martin