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#67993: Selecting buffer automatically Date: Thu, 04 Jan 2024 19:12:23 +0200 Organization: LINKOV.NET Message-ID: <865y09nmp0.fsf@mail.linkov.net> References: <86zfy0g641.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="5434"; 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: martin rudalics To: 67993@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 04 18:14:19 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 1rLRIQ-0001FT-T8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jan 2024 18:14:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLRIA-0002BI-Kl; Thu, 04 Jan 2024 12:14:02 -0500 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 1rLRI8-0002AB-Dj for bug-gnu-emacs@gnu.org; Thu, 04 Jan 2024 12:14:00 -0500 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 1rLRI6-0004gD-NV for bug-gnu-emacs@gnu.org; Thu, 04 Jan 2024 12:14:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLRIA-0000Fm-5k for bug-gnu-emacs@gnu.org; Thu, 04 Jan 2024 12:14: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: Thu, 04 Jan 2024 17:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67993 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67993-submit@debbugs.gnu.org id=B67993.1704388395912 (code B ref 67993); Thu, 04 Jan 2024 17:14:02 +0000 Original-Received: (at 67993) by debbugs.gnu.org; 4 Jan 2024 17:13:15 +0000 Original-Received: from localhost ([127.0.0.1]:55585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLRHP-0000Ee-Fs for submit@debbugs.gnu.org; Thu, 04 Jan 2024 12:13:15 -0500 Original-Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:33297) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLRHN-0000E1-BB for 67993@debbugs.gnu.org; Thu, 04 Jan 2024 12:13:14 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 0585A1BF203; Thu, 4 Jan 2024 17:13:01 +0000 (UTC) In-Reply-To: <86zfy0g641.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 23 Dec 2023 19:51:10 +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:277320 Archived-At: Martin, do you agree with this change? If ok, then I could update the documentation as well. >>>> I believe this should be customizable with something like >>>> >>>> (setopt display-buffer-alist >>>> '(("\\*Compile-Log\\*" nil (select-window . t)))) >>> >>> Thank you for the advice, but I tried this and it didn't work. >>> *Compile-log* buffer isn't selected. >> >> This feature was discussed in bug#33258 and bug#46034, >> but not yet implemented. It should be easy to implement >> exactly the same way as 'windmove-display-in-direction' >> selects the old or new window in 'post-command-hook'. >> Ok, I will post a patch to bug-gnu-emacs. > > Here is the patch that allows using (select-window . t) in display-buffer-alist > to select the displayed window, and (select-window . nil) to deselect windows > selected by such functions as pop-to-buffer: > > diff --git a/lisp/window.el b/lisp/window.el > index 40070a4d929..fad95601a55 100644 > --- a/lisp/window.el > +++ b/lisp/window.el > @@ -7851,6 +7856,16 @@ display-buffer > (while (and functions (not window)) > (setq window (funcall (car functions) buffer alist) > functions (cdr functions))) > + (when-let ((select-window (assq 'select-window alist))) > + (letrec ((postfun > + (lambda () > + (if (cdr select-window) > + (when (window-live-p window) > + (select-window window)) > + (when (window-live-p (old-selected-window)) > + (select-window (old-selected-window)))) > + (remove-hook 'post-command-hook postfun)))) > + (add-hook 'post-command-hook postfun))) > (and (windowp window) window)))) > > (defun display-buffer-other-frame (buffer)