summaryrefslogtreecommitdiff
path: root/lisp/tab-bar.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2019-12-05 01:00:53 +0200
committerJuri Linkov <juri@linkov.net>2019-12-05 01:00:53 +0200
commit1e4c6f8333989ffe16cdffa2e082a061274f1e4e (patch)
treec7e6092240cac564b75f0ede921d86d2465f7f56 /lisp/tab-bar.el
parent67815c6bf2479eae5ad135782a1ce09a95734de8 (diff)
downloademacs-1e4c6f8333989ffe16cdffa2e082a061274f1e4e.tar.gz
* lisp/tab-bar.el (tab-bar-get-buffer-tab): Move code closer to its use.
Diffstat (limited to 'lisp/tab-bar.el')
-rw-r--r--lisp/tab-bar.el76
1 files changed, 38 insertions, 38 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index dc6d2d0b531..acc4304deff 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1296,6 +1296,44 @@ in the selected frame."
((framep all-frames) (list all-frames))
(t (list (selected-frame)))))
+(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames)
+ "Return a tab owning a 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."
+ (let ((buffer (if buffer-or-name
+ (get-buffer buffer-or-name)
+ (current-buffer))))
+ (when (bufferp buffer)
+ (seq-some
+ (lambda (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 `((index . ,(tab-bar--tab-index tab nil frame))
+ (frame . ,frame)))))
+ (funcall tab-bar-tabs-function frame)))
+ (tab-bar--reusable-frames all-frames)))))
+
(defun display-buffer-in-tab (buffer alist)
"Display BUFFER in a tab.
ALIST is an association list of action symbols and values. See
@@ -1346,44 +1384,6 @@ indirectly called by the latter."
(let ((tab-bar-new-tab-choice t))
(tab-bar-new-tab))))))
-(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames)
- "Return a tab owning a 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."
- (let ((buffer (if buffer-or-name
- (get-buffer buffer-or-name)
- (current-buffer))))
- (when (bufferp buffer)
- (seq-some
- (lambda (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 `((index . ,(tab-bar--tab-index tab nil frame))
- (frame . ,frame)))))
- (funcall tab-bar-tabs-function frame)))
- (tab-bar--reusable-frames all-frames)))))
-
(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in another tab.
Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab."