summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2000-10-25 11:39:51 +0000
committerMiles Bader <miles@gnu.org>2000-10-25 11:39:51 +0000
commitf4cbc7a0ddcf48c84469bfd3e8350664667657ce (patch)
tree6220d637608630bf18b1eb0cfec8bd2bbf94b03a
parenta30ccae670fd30dcffca14a9bd499cccc8dae044 (diff)
downloademacs-f4cbc7a0ddcf48c84469bfd3e8350664667657ce.tar.gz
(mouse-wheel-mode): New global minor mode.
(mwheel-install): Use `mouse-wheel-mode'.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/mwheel.el31
2 files changed, 33 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f30be3f6bac..7882d1e4624 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2000-10-25 Miles Bader <miles@gnu.org>
+
+ * recentf.el (recentf-mode): Variable removed.
+ (recentf-mode): Use `define-minor-mode'.
+
+ * mwheel.el (mouse-wheel-mode): New global minor mode.
+ (mwheel-install): Use `mouse-wheel-mode'.
+
2000-10-25 Dave Love <fx@gnu.org>
* wid-edit.el (widget-field-keymap, widget-text-keymap): Don't
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index d6b562b55e3..f7feab41250 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -94,9 +94,19 @@ This can be slightly disconcerting, but some people may prefer it."
(t (error "Bad binding in mwheel-scroll"))))
(if curwin (select-window curwin)))))
+
+;;; Note this definition must be at the end of the file, because
+;;; `define-minor-mode' actually calls the mode-function if the
+;;; associated variable is non-nil, which requires that all needed
+;;; functions be already defined. [This is arguably a bug in d-m-m]
;;;###autoload
-(defun mwheel-install ()
- "Enable mouse wheel support."
+(define-minor-mode mouse-wheel-mode
+ "Toggle mouse wheel support.
+With prefix argument ARG, turn on if positive, otherwise off.
+Returns non-nil if the new state is enabled."
+ nil nil nil
+ :global t
+ :group 'mouse
;; In the latest versions of XEmacs, we could just use
;; (S-)*mouse-[45], since those are aliases for the button
;; equivalents in XEmacs, but I want this to work in as many
@@ -111,11 +121,20 @@ This can be slightly disconcerting, but some people may prefer it."
;; that if the wheeled-mouse is there, it just works, and this way it
;; doesn't yell at me if I'm on my laptop or another machine, etc.
(condition-case ()
- (while keys
- (define-key global-map (car keys) 'mwheel-scroll)
- (setq keys (cdr keys)))
+ (dolist (key keys)
+ (cond (mouse-wheel-mode
+ (define-key global-map key 'mwheel-scroll))
+ ((eq (lookup-key global-map key) 'mwheel-scroll)
+ (define-key global-map key nil))))
(error nil))))
-
+
+;;; Compatibility entry point
+;;;###autoload
+(defun mwheel-install (&optional uninstall)
+ "Enable mouse wheel support."
+ (mouse-wheel-mode t))
+
+
(provide 'mwheel)
;;; mwheel.el ends here