]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-line.el: Use defcustom for group sort variables (bug#59438).
authorJuri Linkov <juri@linkov.net>
Sun, 5 May 2024 18:32:22 +0000 (21:32 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:55:59 +0000 (18:55 +0200)
(tab-line-tabs-buffer-group-sort-function)
(tab-line-tabs-buffer-groups-sort-function): Turn defvar into defcustom.
Suggested by Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>.
(tab-line-tabs-buffer-group-name): Fall back to
'tab-line-tabs-buffer-group-by-mode' when
'tab-line-tabs-buffer-group-function' is nil (its previous default value).

(cherry picked from commit 12132ec1efb1c4ea5f73d7018896964ce2e0311e)

lisp/tab-line.el

index 896e1c802f7000af2e6cd5e4ff9f80e2d27d561e..9ce5ef12f4da68b658c6cd6c0dc6354583144ba6 100644 (file)
@@ -408,15 +408,34 @@ as a group name."
   :group 'tab-line
   :version "30.1")
 
-(defvar tab-line-tabs-buffer-group-sort-function
+(defcustom tab-line-tabs-buffer-group-sort-function
   #'tab-line-tabs-buffer-group-sort-by-name
-  "Function to sort buffers in a group.")
+  "Function to sort buffers in a group."
+  :type '(choice (const :tag "Don't sort" nil)
+                 (const :tag "Sort by name alphabetically"
+                        tab-line-tabs-buffer-group-sort-by-name)
+                 (function :tag "Custom function"))
+  :initialize 'custom-initialize-default
+  :set (lambda (sym val)
+         (set-default sym val)
+         (force-mode-line-update))
+  :group 'tab-line
+  :version "30.1")
 
 (defun tab-line-tabs-buffer-group-sort-by-name (a b)
   (string< (buffer-name a) (buffer-name b)))
 
-(defvar tab-line-tabs-buffer-groups-sort-function #'string<
-  "Function to sort group names.")
+(defcustom tab-line-tabs-buffer-groups-sort-function #'string<
+  "Function to sort group names."
+  :type '(choice (const :tag "Don't sort" nil)
+                 (const :tag "Sort alphabetically" string<)
+                 (function :tag "Custom function"))
+  :initialize 'custom-initialize-default
+  :set (lambda (sym val)
+         (set-default sym val)
+         (force-mode-line-update))
+  :group 'tab-line
+  :version "30.1")
 
 (defvar tab-line-tabs-buffer-groups mouse-buffer-menu-mode-groups
   "How to group various major modes together in the tab line.
@@ -445,7 +464,8 @@ named the same as the mode.")
 
 (defun tab-line-tabs-buffer-group-name (&optional buffer)
   (if (functionp tab-line-tabs-buffer-group-function)
-      (funcall tab-line-tabs-buffer-group-function buffer)))
+      (funcall tab-line-tabs-buffer-group-function buffer)
+    (tab-line-tabs-buffer-group-by-mode buffer)))
 
 (defun tab-line-tabs-buffer-groups ()
   "Return a list of tabs that should be displayed in the tab line.