From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#70949: display-buffer-choose-some-window Date: Fri, 24 May 2024 20:38:34 +0300 Organization: LINKOV.NET Message-ID: <86zfsfqgtl.fsf@mail.linkov.net> References: <86jzjwqqmd.fsf@mail.linkov.net> <8d1947c7-a4d1-4920-8638-f8ae17acfe65@gmx.at> <86r0e32fnj.fsf@mail.linkov.net> <867cft0xt2.fsf@mail.linkov.net> <86ed9xvz3o.fsf@mail.linkov.net> <73251208-1e4c-4231-ae58-faf82363f241@gmx.at> <86jzjoo23l.fsf@mail.linkov.net> <9e29cbbc-65ee-4dd8-8a41-539946e19a7c@gmx.at> <86cypfm6s7.fsf@mail.linkov.net> <86o78xm9y5.fsf@mail.linkov.net> <78dfee56-80b4-4ba7-a012-df31abd21743@gmx.at> <86sey8jv66.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15118"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 70949@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 24 19:59:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sAZCG-0003ms-MK for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 May 2024 19:59:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAZBw-0006e3-7O; Fri, 24 May 2024 13:58:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sAZBv-0006dk-7T for bug-gnu-emacs@gnu.org; Fri, 24 May 2024 13:58:55 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sAZBu-00086p-Ve for bug-gnu-emacs@gnu.org; Fri, 24 May 2024 13:58:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sAZC2-0002Ca-03 for bug-gnu-emacs@gnu.org; Fri, 24 May 2024 13:59: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: Fri, 24 May 2024 17:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70949 X-GNU-PR-Package: emacs Original-Received: via spool by 70949-submit@debbugs.gnu.org id=B70949.17165735408455 (code B ref 70949); Fri, 24 May 2024 17:59:01 +0000 Original-Received: (at 70949) by debbugs.gnu.org; 24 May 2024 17:59:00 +0000 Original-Received: from localhost ([127.0.0.1]:38356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAZBz-0002CE-C8 for submit@debbugs.gnu.org; Fri, 24 May 2024 13:58:59 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:47841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAZBw-0002C5-MN for 70949@debbugs.gnu.org; Fri, 24 May 2024 13:58:57 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id B5E00E0002; Fri, 24 May 2024 17:58:42 +0000 (UTC) In-Reply-To: (martin rudalics's message of "Fri, 24 May 2024 11:32:16 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285786 Archived-At: >> This makes the behavior more predictable: the user will know that all >> buffers will be displayed in the most recently used window, so the user >> can switch to that window before continuing to navigate buffers. > > Not really. The window switched to becomes the selected window and the > 'mru' window used will be the window where the user was working before > the switch due to NOT-SELECTED being t. I meant switching to the window to instruct display-buffer what window to use as mru, then switch back to the rgrep window. >>> Then maybe a separate category for rgrep buffers could help here. >> >> This is not about rgrep buffers. > > Consider the completely untested action function below supposed to be > called with a (related-window . rgrep) alist argument. We already have 'previous-window' that I'm using for a long time, and it works nicely with such configuration: (defvar-local display-buffer-previous-window nil) (defun display-buffer-from-grep-p (_buffer-name _action) (with-current-buffer (window-buffer) (and (memq this-command '(compile-goto-error)) (derived-mode-p '(compilation-mode))))) (add-to-list 'display-buffer-alist '(display-buffer-from-grep-p display-buffer-in-previous-window (previous-window . display-buffer-previous-window) (inhibit-same-window . nil)) ;; Append to not override display-buffer-same-window 'append) (define-advice compile-goto-error (:around (ofun &rest args) previous-window) (let ((buffer (current-buffer))) (apply ofun args) (with-current-buffer buffer (setq-local display-buffer-previous-window (selected-window))))) But this is very complicated configuration. So I wanted to help people to do basically the same with much simpler setting that overrides the hard-coded 'lru' with just '(some-window . mru)'. The only problem with '(some-window . mru)' is that its NOT-SELECTED is t, so this excludes the very useful case of displaying the buffer in the same selected window. For example, with 'previous-window' I often visit rgrep results in the same window where the rgrep buffer was displayed. This keeps everything confined to one window. I see that in your display-buffer-in-related-window 'related-window' is a window parameter. I think this is much better than a buffer-local variable that I used above. But a new alist 'related-window' should also update the 'related-window' window parameter in 'post-command-hook' like 'post-command-select-window' does. Then the customization for users would be very simple: (add-to-list 'display-buffer-alist '((category . rgrep) (display-buffer-in-related-window))) Or maybe a better name would be 'display-buffer-in-last-window'? In any case this looks like a workable solution that will create a connection between windows.