aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-12-05 01:00:53 +0200
committerJuri Linkov2019-12-05 01:00:53 +0200
commit1e4c6f8333989ffe16cdffa2e082a061274f1e4e (patch)
treec7e6092240cac564b75f0ede921d86d2465f7f56
parent67815c6bf2479eae5ad135782a1ce09a95734de8 (diff)
downloademacs-1e4c6f8333989ffe16cdffa2e082a061274f1e4e.tar.gz
emacs-1e4c6f8333989ffe16cdffa2e082a061274f1e4e.zip
* lisp/tab-bar.el (tab-bar-get-buffer-tab): Move code closer to its use.
-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."
1296 ((framep all-frames) (list all-frames)) 1296 ((framep all-frames) (list all-frames))
1297 (t (list (selected-frame))))) 1297 (t (list (selected-frame)))))
1298 1298
1299(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames)
1300 "Return a tab owning a window whose buffer is BUFFER-OR-NAME.
1301BUFFER-OR-NAME may be a buffer or a buffer name and defaults to
1302the current buffer.
1303
1304The optional argument ALL-FRAMES specifies the frames to consider:
1305
1306- t means consider all tabs on all existing frames.
1307
1308- `visible' means consider all tabs on all visible frames.
1309
1310- A frame means consider all tabs on that frame only.
1311
1312Any other value of ALL-FRAMES means consider all tabs on the
1313selected frame and no others."
1314 (let ((buffer (if buffer-or-name
1315 (get-buffer buffer-or-name)
1316 (current-buffer))))
1317 (when (bufferp buffer)
1318 (seq-some
1319 (lambda (frame)
1320 (seq-some
1321 (lambda (tab)
1322 (when (if (eq (car tab) 'current-tab)
1323 (get-buffer-window buffer frame)
1324 (let* ((state (cdr (assq 'ws tab)))
1325 (buffers (when state
1326 (window-state-buffers state))))
1327 (or
1328 ;; non-writable window-state
1329 (memq buffer buffers)
1330 ;; writable window-state
1331 (member (buffer-name buffer) buffers))))
1332 (append tab `((index . ,(tab-bar--tab-index tab nil frame))
1333 (frame . ,frame)))))
1334 (funcall tab-bar-tabs-function frame)))
1335 (tab-bar--reusable-frames all-frames)))))
1336
1299(defun display-buffer-in-tab (buffer alist) 1337(defun display-buffer-in-tab (buffer alist)
1300 "Display BUFFER in a tab. 1338 "Display BUFFER in a tab.
1301ALIST is an association list of action symbols and values. See 1339ALIST is an association list of action symbols and values. See
@@ -1346,44 +1384,6 @@ indirectly called by the latter."
1346 (let ((tab-bar-new-tab-choice t)) 1384 (let ((tab-bar-new-tab-choice t))
1347 (tab-bar-new-tab)))))) 1385 (tab-bar-new-tab))))))
1348 1386
1349(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames)
1350 "Return a tab owning a window whose buffer is BUFFER-OR-NAME.
1351BUFFER-OR-NAME may be a buffer or a buffer name and defaults to
1352the current buffer.
1353
1354The optional argument ALL-FRAMES specifies the frames to consider:
1355
1356- t means consider all tabs on all existing frames.
1357
1358- `visible' means consider all tabs on all visible frames.
1359
1360- A frame means consider all tabs on that frame only.
1361
1362Any other value of ALL-FRAMES means consider all tabs on the
1363selected frame and no others."
1364 (let ((buffer (if buffer-or-name
1365 (get-buffer buffer-or-name)
1366 (current-buffer))))
1367 (when (bufferp buffer)
1368 (seq-some
1369 (lambda (frame)
1370 (seq-some
1371 (lambda (tab)
1372 (when (if (eq (car tab) 'current-tab)
1373 (get-buffer-window buffer frame)
1374 (let* ((state (cdr (assq 'ws tab)))
1375 (buffers (when state
1376 (window-state-buffers state))))
1377 (or
1378 ;; non-writable window-state
1379 (memq buffer buffers)
1380 ;; writable window-state
1381 (member (buffer-name buffer) buffers))))
1382 (append tab `((index . ,(tab-bar--tab-index tab nil frame))
1383 (frame . ,frame)))))
1384 (funcall tab-bar-tabs-function frame)))
1385 (tab-bar--reusable-frames all-frames)))))
1386
1387(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord) 1387(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord)
1388 "Switch to buffer BUFFER-OR-NAME in another tab. 1388 "Switch to buffer BUFFER-OR-NAME in another tab.
1389Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab." 1389Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab."