unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67993: Selecting buffer automatically
@ 2023-12-23 17:51 Juri Linkov
  2024-01-04 17:12 ` Juri Linkov
  0 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2023-12-23 17:51 UTC (permalink / raw)
  To: 67993; +Cc: martin rudalics

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

[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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: select-window.patch --]
[-- Type: text/x-diff, Size: 914 bytes --]

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)

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-01-16 16:54 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-23 17:51 bug#67993: Selecting buffer automatically Juri Linkov
2024-01-04 17:12 ` Juri Linkov
2024-01-05  9:23   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06 17:40     ` Juri Linkov
2024-01-07 14:56       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-07 16:51         ` Juri Linkov
2024-01-08  8:55           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-09 17:20             ` Juri Linkov
2024-01-10  8:37               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10 17:12                 ` Juri Linkov
2024-01-11  9:15                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-12  7:46                     ` Juri Linkov
2024-01-13 10:39                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-14 18:48                         ` Juri Linkov
2024-01-15 10:23                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-15 17:56                             ` Juri Linkov
2024-01-16 10:18                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-16 16:54                                 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).