+(defgroup msb nil
+ "Customizable buffer-selection with multiple menus."
+ :prefix "msb-"
+ :group 'mouse)
+
+(defun msb-custom-set (symbol value)
+ "Set the value of custom variables for msb."
+ (set symbol value)
+ (if (and (featurep 'msb) msb-mode)
+ ;; wait until package has been loaded before bothering to update
+ ;; the buffer lists.
+ (msb-menu-bar-update-buffers t)))
+
+(defcustom msb-menu-cond msb--very-many-menus
+ "*List of criteria for splitting the mouse buffer menu.
+The elements in the list should be of this type:
+ (CONDITION MENU-SORT-KEY MENU-TITLE ITEM-HANDLING-FN ITEM-SORT-FN).
+
+When making the split, the buffers are tested one by one against the
+CONDITION, just like a Lisp cond: When hitting a true condition, the
+other criteria are *not* tested and the buffer name will appear in the
+menu with the menu-title corresponding to the true condition.
+
+If the condition returns the symbol `multi', then the buffer will be
+added to this menu *and* tested for other menus too. If it returns
+`no-multi', then the buffer will only be added if it hasn't been added
+to any other menu.
+
+During this test, the buffer in question is the current buffer, and
+the test is surrounded by calls to `save-excursion' and
+`save-match-data'.
+
+The categories are sorted by MENU-SORT-KEY. Smaller keys are on top.
+nil means don't display this menu.
+
+MENU-TITLE is really a format. If you add %d in it, the %d is
+replaced with the number of items in that menu.
+
+ITEM-HANDLING-FN, is optional. If it is supplied and is a function,
+than it is used for displaying the items in that particular buffer
+menu, otherwise the function pointed out by
+`msb-item-handling-function' is used.
+
+ITEM-SORT-FN, is also optional.
+If it is not supplied, the function pointed out by
+`msb-item-sort-function' is used.
+If it is nil, then no sort takes place and the buffers are presented
+in least-recently-used order.
+If it is t, then no sort takes place and the buffers are presented in
+most-recently-used order.
+If it is supplied and non-nil and not t than it is used for sorting
+the items in that particular buffer menu.
+
+Note1: There should always be a `catch-all' as last element, in this
+list. That is an element like (t TITLE ITEM-HANDLING-FUNCTION).
+Note2: A buffer menu appears only if it has at least one buffer in it.
+Note3: If you have a CONDITION that can't be evaluated you will get an
+error every time you do \\[msb]."
+ :type `(choice (const :tag "long" :value ,msb--very-many-menus)
+ (const :tag "short" :value ,msb--few-menus)
+ (sexp :tag "user"))
+ :set 'msb-custom-set
+ :group 'msb)
+
+(defcustom msb-modes-key 4000
+ "The sort key for files sorted by mode."
+ :type 'integer
+ :set 'msb-custom-set
+ :group 'msb
+ :version "20.3")
+
+(defcustom msb-separator-diff 100