Subject: bug#52050: [PATCH] Make tab-line-switch-cycling work with buffer groups

From: Matt Kramer <[email-masked]>
Date: Tue, 23 Nov 2021 01:41:59 -0800

>
> But it seems you also modified either tab-line-tabs-buffer-list-function,
> or tab-line-tabs-buffer-group-sort-function, or both of them.  Is this
> true?
>

Yes to tab-line-tabs-buffer-group-sort-function, no to
tab-line-tabs-buffer-list-function, yes also to
tab-line-tabs-buffer-group-function. Setup is below:

(defvar ++buffer-group-table
  (make-hash-table :test 'equal))

;; I manually populate ++buffer-group-table

(defun ++tab-line-buffer-group (buffer)
  (gethash (buffer-name buffer) ++buffer-group-table
           (with-current-buffer buffer
             (concat (symbol-name major-mode)
                     ":"
                     (and buffer-file-name
                          (file-name-directory buffer-file-name))))))

(defun ++buffer-name< (a b)
  (string< (buffer-name a) (buffer-name b)))

(setq tab-line-tabs-function #'tab-line-tabs-buffer-groups
      tab-line-tabs-buffer-group-function #'++tab-line-buffer-group
      tab-line-tabs-buffer-group-sort-function #'++buffer-name<
      tab-line-switch-cycling t)