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#45688: 28.0.50; New action for display-buffer? Date: Tue, 12 Jan 2021 20:36:33 +0200 Organization: LINKOV.NET Message-ID: <87v9c2rpfi.fsf@mail.linkov.net> References: <87im8a1dff.fsf@gnus.org> <83y2h6133r.fsf@gnu.org> <8735ze0yp7.fsf@gnus.org> <83o8i20w1f.fsf@gnu.org> <87lfd5yny9.fsf@gnus.org> <87ft3cpoy9.fsf@mail.linkov.net> <6859d73c-da77-af77-481f-3046d5195d53@gmx.at> <87pn2dvxqi.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33073"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 45688@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 12 20:18:48 2021 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 1kzPBn-0008TS-Ni for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Jan 2021 20:18:47 +0100 Original-Received: from localhost ([::1]:48190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzPBl-0003gv-QP for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Jan 2021 14:18:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzOlv-0008Rw-F2 for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 13:52:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzOlu-0004AV-V9 for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 13:52:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kzOlu-0003oG-U3 for bug-gnu-emacs@gnu.org; Tue, 12 Jan 2021 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Jan 2021 18:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45688 X-GNU-PR-Package: emacs Original-Received: via spool by 45688-submit@debbugs.gnu.org id=B45688.161047748314589 (code B ref 45688); Tue, 12 Jan 2021 18:52:02 +0000 Original-Received: (at 45688) by debbugs.gnu.org; 12 Jan 2021 18:51:23 +0000 Original-Received: from localhost ([127.0.0.1]:33133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzOlH-0003nE-Ff for submit@debbugs.gnu.org; Tue, 12 Jan 2021 13:51:23 -0500 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:55113) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kzOlF-0003mR-Ut for 45688@debbugs.gnu.org; Tue, 12 Jan 2021 13:51:22 -0500 X-Originating-IP: 91.129.98.64 Original-Received: from mail.gandi.net (m91-129-98-64.cust.tele2.ee [91.129.98.64]) (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 641442000C; Tue, 12 Jan 2021 18:51:13 +0000 (UTC) In-Reply-To: <87pn2dvxqi.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 10 Jan 2021 12:26:45 +0100") 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" Xref: news.gmane.io gmane.emacs.bugs:197836 Archived-At: >> We're asking too much from 'display-buffer' here. It can't second-guess >> a user's intentions in particular with the interpretation of grep and >> xref hits. I see three basic patterns here: > > I'm wondering whether there should be a separate > `display-buffer-command' that's bound to `C-x 4 C-o' with its own > display rules. :-) That is, when the user is using this command > explicitly, then it's not obvious that the user wants the same rules as > with the "automatic" display-buffer stuff (popping from *grep* buffers > and the like). Currently I'm using windmove-display-* group of commands to instruct display-buffer where I want to display the buffer, e.g.: 's- C-o' to open a grep/xref hit in the bottom window, 's- C-o' to open a grep/xref hit in the left window, etc. It's quite tedious to type that prefix before every key that visits a grep hit. What is still missing is some kind of DWIM to make display-buffer smarter. Here is what seems to work to visit grep/xref hits in the same window where all previous hits were visited: #+begin_src emacs-lisp (defun display-buffer-from-grep-p (_buffer-name _action) (with-current-buffer (window-buffer) (derived-mode-p 'compilation-mode))) (push '(display-buffer-from-grep-p display-buffer-reuse-previous-window) display-buffer-alist) (defvar-local display-buffer-previous-window nil) (defun display-buffer-reuse-previous-window (buffer alist) "Display BUFFER in the same window that was already used as destination." (let ((window display-buffer-previous-window)) (if (window-live-p window) (window--display-buffer buffer window 'reuse alist) (setq window (display-buffer-use-some-window buffer (cons (cons 'inhibit-same-window t) alist))) (setq-local display-buffer-previous-window window) window))) #+end_src One problem is that other display-buffer actions don't set 'display-buffer-previous-window'. It would be nice to do this in some low-level function in window.el.