]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix tab-line-tabs-buffer-groups (bug#59438)
authorGabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Sun, 5 May 2024 18:37:23 +0000 (21:37 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:56:02 +0000 (18:56 +0200)
* lisp/tab-line.el (tab-line-tabs-buffer-groups): Handle case
when variable 'tab-line-tabs-buffer-groups-sort-function' is nil.

(cherry picked from commit 451863adf942bf4e3c1b9346c0f37e546e16b1fd)

lisp/tab-line.el

index 9ce5ef12f4da68b658c6cd6c0dc6354583144ba6..6898ba53e02b2375a88eeea39aee7b867f658fcf 100644 (file)
@@ -387,7 +387,7 @@ Used only for `tab-line-tabs-mode-buffers' and `tab-line-tabs-buffer-groups'.")
 (defcustom tab-line-tabs-buffer-group-function
   #'tab-line-tabs-buffer-group-by-mode
   "Function to add a buffer to the appropriate group of tabs.
-Takes a buffer as arg and should return a group name as a string.
+Takes a buffer as argument and should return a group name as a string.
 If the return value is nil, the buffer has no group, so \"No group\"
 is displayed instead of a group name and the buffer is not grouped
 together with other buffers.
@@ -475,13 +475,14 @@ If non-nil, `tab-line-tabs-buffer-group-function' is used to
 generate the group name."
   (if (window-parameter nil 'tab-line-groups)
       (let* ((buffers (funcall tab-line-tabs-buffer-list-function))
-             (groups
-              (seq-sort tab-line-tabs-buffer-groups-sort-function
-                        (delq nil (mapcar #'car (seq-group-by
-                                                 (lambda (buffer)
-                                                   (tab-line-tabs-buffer-group-name
-                                                    buffer))
-                                                 buffers)))))
+             (groups (delq nil
+                           (mapcar #'car
+                                   (seq-group-by #'tab-line-tabs-buffer-group-name
+                                                 buffers))))
+             (sorted-groups (if (functionp tab-line-tabs-buffer-groups-sort-function)
+                                (seq-sort tab-line-tabs-buffer-groups-sort-function
+                                          groups)
+                              groups))
              (selected-group (window-parameter nil 'tab-line-group))
              (tabs
               (mapcar (lambda (group)
@@ -492,9 +493,8 @@ generate the group name."
                                        (set-window-parameter nil 'tab-line-groups nil)
                                        (set-window-parameter nil 'tab-line-group group)
                                        (set-window-parameter nil 'tab-line-hscroll nil)))))
-                      groups)))
+                      sorted-groups)))
         tabs)
-
     (let* ((window-parameter (window-parameter nil 'tab-line-group))
            (group-name (tab-line-tabs-buffer-group-name (current-buffer)))
            (group (prog1 (or window-parameter group-name "No group")
@@ -507,10 +507,9 @@ generate the group name."
                                      (set-window-parameter nil 'tab-line-groups t)
                                      (set-window-parameter nil 'tab-line-group group)
                                      (set-window-parameter nil 'tab-line-hscroll nil)))))
-           (buffers
-            (seq-filter (lambda (b)
-                          (equal (tab-line-tabs-buffer-group-name b) group))
-                        (funcall tab-line-tabs-buffer-list-function)))
+           (buffers (seq-filter (lambda (b)
+                                  (equal (tab-line-tabs-buffer-group-name b) group))
+                                (funcall tab-line-tabs-buffer-list-function)))
            (sorted-buffers (if (functionp tab-line-tabs-buffer-group-sort-function)
                                (seq-sort tab-line-tabs-buffer-group-sort-function
                                          buffers)