GNU bug report logs - #68235
29.1.90; Switching tabs stops following process output in selected window

Previous Next

Package: emacs;

Reported by: Dan McCarthy <daniel.c.mccarthy <at> gmail.com>

Date: Wed, 3 Jan 2024 20:49:02 UTC

Severity: normal

Found in version 29.1.90

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 68235 <at> debbugs.gnu.org
Subject: bug#68235: 29.1.90; Switching tabs stops following process output in selected window
Date: Tue, 05 Mar 2024 19:27:18 +0200
[Message part 1 (text/plain, inline)]
>> Patch attached.  I now provide only one hook I called
>> 'window-kept-windows-functions' which is run by both
>> 'set-window-configuration' and 'window-state-put'.
>
> Should be on master now.

Thanks.  This will allow such option:

[tab-bar-select-keep-windows-function.patch (text/x-diff, inline)]
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 61efa332e0b..b2eb1c9d576 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1393,6 +1405,44 @@ tab-bar-tab-post-select-functions
   :group 'tab-bar
   :version "30.1")
 
+(defcustom tab-bar-select-keep-windows-function #'tab-bar-select-keep-windows
+  "Function that handles the killed buffers after selecting a tab."
+  :type '(choice (const :tag "Show placeholder buffers"
+                        tab-bar-select-keep-windows)
+                 (function  :tag "Function"))
+  :group 'tab-bar
+  :version "30.1")
+
+(defun tab-bar-select-keep-windows (_frame windows)
+  (dolist (quad windows)
+    (when (and (window-live-p (nth 0 quad))
+               (not (window-minibuffer-p (nth 0 quad))))
+      (let* ((window (nth 0 quad))
+             (old-buffer (nth 1 quad))
+             (file (when (bufferp old-buffer)
+                     (buffer-file-name old-buffer)))
+             (name (or file
+                       (and (fboundp 'buffer-last-name)
+                            (buffer-last-name old-buffer))
+                       old-buffer))
+             (new-buffer (generate-new-buffer
+                          (format "*Old buffer %s*" name))))
+        (with-current-buffer new-buffer
+          (set-auto-mode)
+          (insert (format-message "This window displayed the %s `%s'.\n"
+                                  (if file "file" "buffer")
+                                  name))
+          (when file
+            (insert-button
+             "[Restore]" 'action
+	     (lambda (_button)
+               (set-window-buffer window (find-file-noselect file))
+	       (set-window-start window (nth 2 quad) t)
+	       (set-window-point window (nth 3 quad)))))
+          (goto-char (point-min))
+          (setq buffer-read-only t)
+	  (set-window-buffer window new-buffer))))))
+
 (defvar tab-bar-minibuffer-restore-tab nil
   "Tab number for `tab-bar-minibuffer-restore-tab'.")
 
@@ -1438,7 +1488,10 @@ tab-bar-select-tab
       (let* ((from-tab (tab-bar--tab))
              (to-tab (nth to-index tabs))
              (wc (alist-get 'wc to-tab))
-             (ws (alist-get 'ws to-tab)))
+             (ws (alist-get 'ws to-tab))
+             (window-kept-windows-functions
+              (delq nil (cons tab-bar-select-keep-windows-function
+                              window-kept-windows-functions))))
 
         ;; During the same session, use window-configuration to switch
         ;; tabs, because window-configurations are more reliable

This bug report was last modified 1 year and 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.