Function: tab-bar-get-buffer-tab
tab-bar-get-buffer-tab is a byte-compiled function defined in
tab-bar.el.gz.
Signature
(tab-bar-get-buffer-tab BUFFER-OR-NAME &optional ALL-FRAMES IGNORE-CURRENT-TAB ALL-TABS)
Documentation
Return the tab that owns the window whose buffer is BUFFER-OR-NAME.
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.
When the optional argument IGNORE-CURRENT-TAB is non-nil, don't take into account the buffers in the currently selected tab. Otherwise, prefer buffers of the current tab.
When the optional argument ALL-TABS is non-nil, return a list of all tabs that contain the buffer BUFFER-OR-NAME.
Source Code
;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-get-buffer-tab (buffer-or-name
&optional all-frames ignore-current-tab all-tabs)
"Return the tab that owns the window whose buffer is BUFFER-OR-NAME.
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.
When the optional argument IGNORE-CURRENT-TAB is non-nil,
don't take into account the buffers in the currently selected tab.
Otherwise, prefer buffers of the current tab.
When the optional argument ALL-TABS is non-nil, return a list of all tabs
that contain the buffer BUFFER-OR-NAME."
(let ((buffer (if buffer-or-name
(get-buffer buffer-or-name)
(current-buffer)))
buffer-tabs)
(when (bufferp buffer)
(funcall
(if all-tabs #'seq-each #'seq-some)
(lambda (frame)
(funcall
(if all-tabs #'seq-each #'seq-some)
(lambda (tab)
(when (if (eq (car tab) 'current-tab)
(get-buffer-window buffer frame)
(let* ((state (alist-get '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))))
(push (append tab `((index . ,(tab-bar--tab-index tab nil frame))
(frame . ,frame)))
buffer-tabs)))
(let* ((tabs (funcall tab-bar-tabs-function frame))
(current-tab (tab-bar--current-tab-find tabs)))
(setq tabs (remq current-tab tabs))
(if ignore-current-tab
;; Use tabs without current-tab.
tabs
;; Make sure current-tab is at the beginning of tabs.
(cons current-tab tabs)))))
(tab-bar--reusable-frames all-frames))
(if all-tabs (nreverse buffer-tabs) (car (last buffer-tabs))))))