+;; Setter function for mouse-button user-options. Switch Mouse Wheel
+;; mode off and on again so that the old button is unbound and
+;; new button is bound to mwheel-scroll.
+
+(defun mouse-wheel-change-button (var button)
+ (let ((active mouse-wheel-mode))
+ ;; Deactivate before changing the setting.
+ (when active (mouse-wheel-mode -1))
+ (set-default var button)
+ (when active (mouse-wheel-mode 1))))
+
+(defvar mouse-wheel-down-button 4)
+(make-obsolete-variable 'mouse-wheel-down-button
+ 'mouse-wheel-down-event)
+(defcustom mouse-wheel-down-event
+ ;; In the latest versions of XEmacs, we could just use mouse-%s as well.
+ (if (memq window-system '(w32 mac))
+ 'wheel-up
+ (intern (format (if (featurep 'xemacs) "button%s" "mouse-%s")
+ mouse-wheel-down-button)))
+ "Event used for scrolling down."
+ :group 'mouse
+ :type 'symbol
+ :set 'mouse-wheel-change-button)
+
+(defvar mouse-wheel-up-button 5)
+(make-obsolete-variable 'mouse-wheel-up-button
+ 'mouse-wheel-up-event)
+(defcustom mouse-wheel-up-event
+ ;; In the latest versions of XEmacs, we could just use mouse-%s as well.
+ (if (memq window-system '(w32 mac))
+ 'wheel-down
+ (intern (format (if (featurep 'xemacs) "button%s" "mouse-%s")
+ mouse-wheel-up-button)))
+ "Event used for scrolling up."
+ :group 'mouse
+ :type 'symbol
+ :set 'mouse-wheel-change-button)
+
+(defvar mouse-wheel-click-button 2)
+(make-obsolete-variable 'mouse-wheel-click-button
+ 'mouse-wheel-click-event)
+(defcustom mouse-wheel-click-event
+ ;; In the latest versions of XEmacs, we could just use mouse-%s as well.
+ (intern (format (if (featurep 'xemacs) "button%s" "mouse-%s")
+ mouse-wheel-click-button))
+ "Event that should be temporarily inhibited after mouse scrolling.
+The mouse wheel is typically on the mouse-2 button, so it may easily
+happen that text is accidentally yanked into the buffer when
+scrolling with the mouse wheel. To prevent that, this variable can be
+set to the event sent when clicking on the mouse wheel button."
+ :group 'mouse
+ :type 'symbol
+ :set 'mouse-wheel-change-button)
+
+(defcustom mouse-wheel-inhibit-click-time 0.35
+ "Time in seconds to inhibit clicking on mouse wheel button after scroll."
+ :group 'mouse
+ :type 'number)
+
+(defcustom mouse-wheel-scroll-amount '(5 ((shift) . 1) ((control) . nil))