Mercurial > emacs
comparison lisp/mwheel.el @ 32867:553975760fe9
(mouse-wheel-mode): New global minor mode.
(mwheel-install): Use `mouse-wheel-mode'.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 25 Oct 2000 11:38:29 +0000 |
parents | 55a234a9fe88 |
children | d70bb5e33b91 |
comparison
equal
deleted
inserted
replaced
32866:8ef794e21542 | 32867:553975760fe9 |
---|---|
92 (cond ((= button 4) (scroll-down amt)) | 92 (cond ((= button 4) (scroll-down amt)) |
93 ((= button 5) (scroll-up amt)) | 93 ((= button 5) (scroll-up amt)) |
94 (t (error "Bad binding in mwheel-scroll")))) | 94 (t (error "Bad binding in mwheel-scroll")))) |
95 (if curwin (select-window curwin))))) | 95 (if curwin (select-window curwin))))) |
96 | 96 |
97 | |
98 ;;; Note this definition must be at the end of the file, because | |
99 ;;; `define-minor-mode' actually calls the mode-function if the | |
100 ;;; associated variable is non-nil, which requires that all needed | |
101 ;;; functions be already defined. [This is arguably a bug in d-m-m] | |
97 ;;;###autoload | 102 ;;;###autoload |
98 (defun mwheel-install () | 103 (define-minor-mode mouse-wheel-mode |
99 "Enable mouse wheel support." | 104 "Toggle mouse wheel support. |
105 With prefix argument ARG, turn on if positive, otherwise off. | |
106 Returns non-nil if the new state is enabled." | |
107 nil nil nil | |
108 :global t | |
109 :group 'mouse | |
100 ;; In the latest versions of XEmacs, we could just use | 110 ;; In the latest versions of XEmacs, we could just use |
101 ;; (S-)*mouse-[45], since those are aliases for the button | 111 ;; (S-)*mouse-[45], since those are aliases for the button |
102 ;; equivalents in XEmacs, but I want this to work in as many | 112 ;; equivalents in XEmacs, but I want this to work in as many |
103 ;; versions of XEmacs as it can. | 113 ;; versions of XEmacs as it can. |
104 (let* ((mwheel-running-xemacs (string-match "XEmacs" (emacs-version))) | 114 (let* ((mwheel-running-xemacs (string-match "XEmacs" (emacs-version))) |
109 ;; if you try to define a key that it does not know about. I for one | 119 ;; if you try to define a key that it does not know about. I for one |
110 ;; prefer to just unconditionally do a mwheel-install in my .emacs, so | 120 ;; prefer to just unconditionally do a mwheel-install in my .emacs, so |
111 ;; that if the wheeled-mouse is there, it just works, and this way it | 121 ;; that if the wheeled-mouse is there, it just works, and this way it |
112 ;; doesn't yell at me if I'm on my laptop or another machine, etc. | 122 ;; doesn't yell at me if I'm on my laptop or another machine, etc. |
113 (condition-case () | 123 (condition-case () |
114 (while keys | 124 (dolist (key keys) |
115 (define-key global-map (car keys) 'mwheel-scroll) | 125 (cond (mouse-wheel-mode |
116 (setq keys (cdr keys))) | 126 (define-key global-map key 'mwheel-scroll)) |
127 ((eq (lookup-key global-map key) 'mwheel-scroll) | |
128 (define-key global-map key nil)))) | |
117 (error nil)))) | 129 (error nil)))) |
118 | 130 |
131 ;;; Compatibility entry point | |
132 ;;;###autoload | |
133 (defun mwheel-install (&optional uninstall) | |
134 "Enable mouse wheel support." | |
135 (mouse-wheel-mode t)) | |
136 | |
137 | |
119 (provide 'mwheel) | 138 (provide 'mwheel) |
120 | 139 |
121 ;;; mwheel.el ends here | 140 ;;; mwheel.el ends here |