From: Gerd Moellmann Date: Fri, 27 Jul 2001 08:41:35 +0000 (+0000) Subject: (mouse-wheel-down-button, mouse-wheel-up-button): X-Git-Tag: emacs-pretest-21.0.105~371 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bf85004b276981766a2773a07f861af6572d97ce;p=emacs.git (mouse-wheel-down-button, mouse-wheel-up-button): New user-options. (mouse-wheel-change-button): New function. (mouse-wheel-mode): Use mouse-wheel-{up,down}-button. (mwheel-scroll): Ditto. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 53746876b0a..4de616fddcb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2001-07-27 Gerd Moellmann + + * mwheel.el (mouse-wheel-down-button, mouse-wheel-up-button): + New user-options. + (mouse-wheel-change-button): New function. + (mouse-wheel-mode): Use mouse-wheel-{up,down}-button. + (mwheel-scroll): Ditto. + 2001-07-26 Gerd Moellmann * emacs-lisp/lisp-mode.el (eval-last-sexp-1): Don't search for diff --git a/lisp/mwheel.el b/lisp/mwheel.el index b58d42ebf23..461ae41575b 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -1,6 +1,6 @@ ;;; mwheel.el --- Mouse support for MS intelli-mouse type mice -;; Copyright (C) 1998, 2000, Free Software Foundation, Inc. +;; Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. ;; Maintainer: William M. Perry ;; Keywords: mouse @@ -41,6 +41,28 @@ (require 'custom) +;; 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) + (set-default var button) + (when mouse-wheel-mode + (mouse-wheel-mode 0) + (mouse-wheel-mode 1))) + +(defcustom mouse-wheel-down-button 4 + "Mouse button number for scrolling down." + :group 'mouse + :type 'integer + :set 'mouse-wheel-change-button) + +(defcustom mouse-wheel-up-button 5 + "Mouse button number for scrolling up." + :group 'mouse + :type 'integer + :set 'mouse-wheel-change-button) + (defcustom mouse-wheel-scroll-amount '(5 . 1) "Amount to scroll windows by when spinning the mouse wheel. This is actually a cons cell, where the first item is the amount to scroll @@ -89,8 +111,8 @@ This can be slightly disconcerting, but some people may prefer it." (car mouse-wheel-scroll-amount)))) (unwind-protect (let ((button (mwheel-event-button event))) - (cond ((= button 4) (scroll-down amt)) - ((= button 5) (scroll-up amt)) + (cond ((= button mouse-wheel-down-button) (scroll-down amt)) + ((= button mouse-wheel-up-button) (scroll-up amt)) (t (error "Bad binding in mwheel-scroll")))) (if curwin (select-window curwin))))) @@ -112,8 +134,14 @@ Returns non-nil if the new state is enabled." ;; versions of XEmacs as it can. (let ((keys (if (featurep 'xemacs) - '(button4 [(shift button4)] button5 [(shift button5)]) - '([mouse-4] [S-mouse-4] [mouse-5] [S-mouse-5])))) + (let ((down (intern (format "button%d" mouse-wheel-down-button))) + (up (intern (format "button%d" mouse-wheel-up-button)))) + `(,down [(shift ,down)] ,up [(shift ,up)])) + (let ((down (intern (format "mouse-%d" mouse-wheel-down-button))) + (s-down (intern (format "S-mouse-%d" mouse-wheel-down-button))) + (up (intern (format "mouse-%d" mouse-wheel-up-button))) + (s-up (intern (format "S-mouse-%d" mouse-wheel-up-button)))) + `([,down] [,s-down] [,up] [,s-up]))))) ;; This condition-case is here because Emacs 19 will throw an error ;; if you try to define a key that it does not know about. I for one ;; prefer to just unconditionally do a mwheel-install in my .emacs, so @@ -133,7 +161,6 @@ Returns non-nil if the new state is enabled." "Enable mouse wheel support." (mouse-wheel-mode t)) - (provide 'mwheel) ;;; mwheel.el ends here