[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7a41de3d515: Simplify tab-line-switch-to-prev-tab and tab-line-sw
From: |
Juri Linkov |
Subject: |
master 7a41de3d515: Simplify tab-line-switch-to-prev-tab and tab-line-switch-to-next-tab. |
Date: |
Wed, 3 Apr 2024 13:42:40 -0400 (EDT) |
branch: master
commit 7a41de3d515077e3895fe9201d7786134c82ca26
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
Simplify tab-line-switch-to-prev-tab and tab-line-switch-to-next-tab.
* lisp/tab-line.el (tab-line-switch-to-prev-tab)
(tab-line-switch-to-next-tab): Use buffers instead of tabs.
---
lisp/tab-line.el | 47 +++++++++++++++++++----------------------------
1 file changed, 19 insertions(+), 28 deletions(-)
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index cc60f94c9c5..8c59f7b2e6d 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -853,20 +853,15 @@ Its effect is the same as using the `previous-buffer'
command
(if (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
(switch-to-prev-buffer window)
(with-selected-window (or window (selected-window))
- (let* ((tabs (seq-filter
- (lambda (tab) (or (bufferp tab) (assq 'buffer tab)))
- (funcall tab-line-tabs-function)))
- (pos (seq-position
- tabs (current-buffer)
- (lambda (tab buffer)
- (if (bufferp tab)
- (eq buffer tab)
- (eq buffer (cdr (assq 'buffer tab)))))))
- (tab (if pos
- (if (and tab-line-switch-cycling (<= pos 0))
- (nth (1- (length tabs)) tabs)
- (nth (1- pos) tabs))))
- (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
+ (let* ((buffers (seq-keep
+ (lambda (tab) (or (and (bufferp tab) tab)
+ (alist-get 'buffer tab)))
+ (funcall tab-line-tabs-function)))
+ (pos (seq-position buffers (current-buffer)))
+ (buffer (when pos
+ (if (and tab-line-switch-cycling (<= pos 0))
+ (nth (1- (length buffers)) buffers)
+ (nth (1- pos) buffers)))))
(when (bufferp buffer)
(switch-to-buffer buffer)))))))
@@ -879,20 +874,16 @@ Its effect is the same as using the `next-buffer' command
(if (eq tab-line-tabs-function #'tab-line-tabs-window-buffers)
(switch-to-next-buffer window)
(with-selected-window (or window (selected-window))
- (let* ((tabs (seq-filter
- (lambda (tab) (or (bufferp tab) (assq 'buffer tab)))
- (funcall tab-line-tabs-function)))
- (pos (seq-position
- tabs (current-buffer)
- (lambda (tab buffer)
- (if (bufferp tab)
- (eq buffer tab)
- (eq buffer (cdr (assq 'buffer tab)))))))
- (tab (if pos
- (if (and tab-line-switch-cycling (<= (length tabs) (1+
pos)))
- (car tabs)
- (nth (1+ pos) tabs))))
- (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
+ (let* ((buffers (seq-keep
+ (lambda (tab) (or (and (bufferp tab) tab)
+ (alist-get 'buffer tab)))
+ (funcall tab-line-tabs-function)))
+ (pos (seq-position buffers (current-buffer)))
+ (buffer (when pos
+ (if (and tab-line-switch-cycling
+ (<= (length buffers) (1+ pos)))
+ (car buffers)
+ (nth (1+ pos) buffers)))))
(when (bufferp buffer)
(switch-to-buffer buffer)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7a41de3d515: Simplify tab-line-switch-to-prev-tab and tab-line-switch-to-next-tab.,
Juri Linkov <=