Subject: Better groups for Buffer-menu-group-by

From: Juri Linkov <[email-masked]>
Date: Tue, 02 Apr 2024 19:44:27 +0300

Here is a better grouping for Buffer-menu-group-by-mode
that uses the existing mode categorization in
mouse-buffer-menu-mode-groups.

diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index ec5337e3fda..1f7d40c5a14 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -798,7 +805,11 @@ Buffer-menu--pretty-file-name
 	(t "")))
 
 (defun Buffer-menu-group-by-mode (entry)
-  (concat "* " (aref (cadr entry) 5)))
+  (let ((mode (aref (cadr entry) 5)))
+    (concat "* " (or (cdr (seq-find (lambda (group)
+                                      (string-match-p (car group) mode))
+                                    mouse-buffer-menu-mode-groups))
+                     mode))))
 
 (declare-function project-root "project" (project))
 (defun Buffer-menu-group-by-root (entry)