diff --git a/lisp/window.el b/lisp/window.el index c750ea71ea..b46abd6ced 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6231,6 +6231,17 @@ window-state-put (delete-window window)))) (window--check frame)))) +(defun window-state-buffers (state) + "Return all buffers saved to the given window state STATE." + (let ((buffer (cadr (assq 'buffer state))) + (buffers (mapcan (lambda (item) + (when (memq (car item) '(leaf vc hc)) + (window-state-buffers item))) + (if (consp (car state)) (list (cdr state)) (cdr state))))) + (if buffer + (cons (get-buffer buffer) buffers) + buffers))) + (defun window-swap-states (&optional window-1 window-2 size) "Swap the states of live windows WINDOW-1 and WINDOW-2. WINDOW-1 must specify a live window and defaults to the selected diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 5eb332884c..9c8c38fb83 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1284,6 +1284,12 @@ display-buffer-in-tab (tab-bar-rename-tab name)))) (tab-bar-new-tab)))) +(defun tab-bar-buffer-visible-in-tabs-p (buffer) + "Return non-nil when BUFFER is visible in other tabs." + (seq-some (lambda (tab) + (memq buffer (window-state-buffers (cdr (assq 'ws tab))))) + (funcall tab-bar-tabs-function))) + (defun switch-to-buffer-other-tab (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in another tab. diff --git a/lisp/desktop.el b/lisp/desktop.el index 498f769bd3..6f45278218 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -946,7 +946,9 @@ desktop-outvar ")\n")))) ;; ---------------------------------------------------------------------------- -(defun desktop-save-buffer-p (filename bufname mode &rest _dummy) +(defvar desktop-buffers-not-to-save-function nil) + +(defun desktop-save-buffer-p (filename bufname mode &rest rest) "Return t if buffer should have its state saved in the desktop file. FILENAME is the visited file name, BUFNAME is the buffer name, and MODE is the major mode. @@ -970,6 +972,9 @@ desktop-save-buffer-p (and (null filename) (null dired-skip) ; bug#5755 (with-current-buffer bufname desktop-save-buffer))) + (or (null desktop-buffers-not-to-save-function) + (funcall desktop-buffers-not-to-save-function + filename bufname mode rest)) t))) ;; ----------------------------------------------------------------------------