From 13626c36efed39f89eb4c31af3cbc87fcd80f01f Mon Sep 17 00:00:00 2001 From: Kiso Katsuyuki Date: Mon, 7 Sep 2020 16:01:46 -0500 Subject: [PATCH] Suppress errors of tab-line-switch functions Traget errors occurs when tab-line-switch-to-prev-tab or tab-line-switch-to-next-tab is invoked in the window which has no tabs --- lisp/tab-line.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index e8c4dc4d93..3b4d3e68ad 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -652,13 +652,14 @@ tab-line-switch-to-prev-tab (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 +674,14 @@ tab-line-switch-to-next-tab (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))))))) -- 2.28.0