]> git.eshelyaron.com Git - emacs.git/commitdiff
Suppress errors of tab-line-switch functions
authorKiso Katsuyuki <katsuyuki2388@gmail.com>
Wed, 9 Sep 2020 19:16:34 +0000 (22:16 +0300)
committerJuri Linkov <juri@linkov.net>
Wed, 9 Sep 2020 19:24:06 +0000 (22:24 +0300)
Traget errors occurs when tab-line-switch-to-prev-tab or
tab-line-switch-to-next-tab is invoked in a buffer which is not in
tabs

Copyright-paperwork-exempt: yes

lisp/tab-line.el

index 40f80959ccf2eae2589b58f7ba635d7d4eae9ce7..140ee8c389e45e6a8322e40f22cf9bcf9eab454e 100644 (file)
@@ -652,13 +652,13 @@ Its effect is the same as using the `previous-buffer' command
         (switch-to-prev-buffer window)
       (with-selected-window (or window (selected-window))
         (let* ((tabs (funcall tab-line-tabs-function))
-               (tab (nth (1- (seq-position
-                              tabs (current-buffer)
-                              (lambda (tab buffer)
-                                (if (bufferp tab)
-                                    (eq buffer tab)
-                                  (eq buffer (cdr (assq 'buffer tab)))))))
-                         tabs))
+               (pos (seq-position
+                     tabs (current-buffer)
+                     (lambda (tab buffer)
+                       (if (bufferp tab)
+                           (eq buffer tab)
+                         (eq buffer (cdr (assq 'buffer tab)))))))
+               (tab (if pos (nth (1- pos) tabs)))
                (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
           (when (bufferp buffer)
             (switch-to-buffer buffer)))))))
@@ -673,13 +673,13 @@ Its effect is the same as using the `next-buffer' command
         (switch-to-next-buffer window)
       (with-selected-window (or window (selected-window))
         (let* ((tabs (funcall tab-line-tabs-function))
-               (tab (nth (1+ (seq-position
-                              tabs (current-buffer)
-                              (lambda (tab buffer)
-                                (if (bufferp tab)
-                                    (eq buffer tab)
-                                  (eq buffer (cdr (assq 'buffer tab)))))))
-                         tabs))
+               (pos (seq-position
+                     tabs (current-buffer)
+                     (lambda (tab buffer)
+                       (if (bufferp tab)
+                           (eq buffer tab)
+                         (eq buffer (cdr (assq 'buffer tab)))))))
+               (tab (if pos (nth (1+ pos) tabs)))
                (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
           (when (bufferp buffer)
             (switch-to-buffer buffer)))))))