bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68235: 29.1.90; Switching tabs stops following process output in sel


From: Juri Linkov
Subject: bug#68235: 29.1.90; Switching tabs stops following process output in selected window
Date: Tue, 20 Feb 2024 19:44:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

> 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'.

Thanks, it works nicely with

(defun default-window-keep-windows (_frame windows)
  (dolist (quad windows)
    (unless (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 old-buffer))
             (new-buffer (generate-new-buffer
                          (format "*Old buffer %s*" name))))
        (with-current-buffer new-buffer
          (set-auto-mode)
          (insert "This window displayed the "
                  (if file "file" "buffer")
                  (format " %s\n" name))
          (when file
            (insert-button
             "[Restore]" 'action
             (lambda (_button)
               (set-window-buffer window (find-file-noselect file))
               (set-window-point window (nth 3 quad))
               (set-window-start window (nth 2 quad) t))))
          (goto-char (point-min))
          (setq buffer-read-only t)
          (set-window-buffer window new-buffer))))))

(add-hook 'window-kept-windows-functions 'default-window-keep-windows)

that works even for (window-state-get nil 'writable).
In this case only the old buffer name is displayed as a string.
I guess there is no more data that could be extracted
from buffer's writable state.

> OK.  But note that we now run this hook even if nothing in the window
> configuration changes, typically, when calling 'read-minibuffer'.  So
> use it with due care

Indeed, this required adding such guard:

  (unless (window-minibuffer-p (nth 0 quad))

> (for example, have the tab code bind it exclusively
> around its calls of 'set-window-configuration').

Thanks for suggestion, will let-bind it in 'tab-bar-select-tab'.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]