GNU bug report logs -
#67993
Selecting buffer automatically
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Sat, 23 Dec 2023 17:56:01 UTC
Severity: wishlist
Tags: patch
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[From emacs-devel]
>>> 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:
[select-window.patch (text/x-diff, inline)]
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)
This bug report was last modified 1 year and 125 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.