")\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.
(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)))
;; ----------------------------------------------------------------------------
(kill-buffer (current-buffer))
;; Delete the current window configuration of tab list
;; without storing it in the undo list of closed tabs
- (let (tab-bar-closed-tabs)
+ (let ((tab-bar-mode t) ; avoid message about deleted tab
+ tab-bar-closed-tabs)
(tab-bar-close-tab nil (1+ (tab-bar--tab-index to-tab))))))
(defun tab-bar-list-mouse-select (event)
(tab-bar-rename-tab name))))
(tab-bar-new-tab))))
+(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames)
+ "Return a tab whose window contains BUFFER-OR-NAME, or nil if none.
+BUFFER-OR-NAME may be a buffer or a buffer name and defaults to
+the current buffer.
+
+The optional argument ALL-FRAMES specifies the frames to consider:
+
+- t means consider all tabs on all existing frames.
+
+- `visible' means consider all tabs on all visible frames.
+
+- A frame means consider all tabs on that frame only.
+
+Any other value of ALL-FRAMES means consider all tabs on the
+selected frame and no others."
+ (let ((buffer (if buffer-or-name
+ (get-buffer buffer-or-name)
+ (current-buffer))))
+ (when (bufferp buffer)
+ (let ((frames (cond
+ ((eq all-frames t) (frame-list))
+ ((eq all-frames 'visible) (visible-frame-list))
+ ((framep all-frames) (list all-frames))
+ (t (list (selected-frame))))))
+ (seq-some (lambda (frame)
+ (with-selected-frame frame
+ (seq-some (lambda (tab)
+ (when (if (eq (car tab) 'current-tab)
+ (get-buffer-window buffer frame)
+ (let* ((state (cdr (assq 'ws tab)))
+ (buffers (when state
+ (window-state-buffers state))))
+ (or
+ ;; non-writable window-state
+ (memq buffer buffers)
+ ;; writable window-state
+ (member (buffer-name buffer) buffers))))
+ (append tab `((frame . ,frame)))))
+ (funcall tab-bar-tabs-function))))
+ frames)))))
+
\f
(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in another tab.
(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 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