Colin Woodbury
Colin Woodbury

Reputation: 1809

Disabling mouse scrolling in Emacs

Everything I've found on the internet has told me that emacs disables mouse scrolling by default, but mine is very enthusiastic and scrolls to its hearts content when my thumbs get too close to the trackpad on my laptop. I have not given it permission to do so, and here is my .emacs to prove it:

;; Line by line scrolling                                                                                                                                      
(setq scroll-step 1)

;; Turn off backup file creation                                                                                                                               
;;(setq make-backup-files nil)                                                                                                                                 

;; Enable backup files                                                                                                                                         
(setq make-backup-files t)

;; Save all backup files to this directory                                                                                                                     
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))

;; Show column number                                                                                                                                          
(column-number-mode 1)

;; Fix C indenting                                                                                                                                             
(setq c-default-style "bsd"
      c-basic-offset 8)

Every once and a while my thumbs will brush the track pad, and suddenly I'll be typing in the middle of another line way up or way below from where I had just been. How can I stop this from happening?

EDIT Running M-x customize-option mouse-wheel-mode yields:

Mouse Wheel Mode: [Hide Value] [Toggle] off (nil)

[State]: CHANGED outside Customize; operating on it here may be unreliable.

Non-nil if Mouse-Wheel mode is enabled. [Hide Rest]
See the command mouse-wheel-mode' for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node
Easy Customization')
or call the function `mouse-wheel-mode'. Groups: [Mouse]

Upvotes: 4

Views: 3426

Answers (4)

gmas
gmas

Reputation: 21

Here's what I did to disable all mouse scrolling (including horizontal):

(mouse-wheel-mode -1)
(global-set-key [wheel-up] 'ignore)
(global-set-key [double-wheel-up] 'ignore)
(global-set-key [triple-wheel-up] 'ignore)
(global-set-key [wheel-down] 'ignore)
(global-set-key [double-wheel-down] 'ignore)
(global-set-key [triple-wheel-down] 'ignore)
(global-set-key [wheel-left] 'ignore)
(global-set-key [double-wheel-left] 'ignore)
(global-set-key [triple-wheel-left] 'ignore)
(global-set-key [wheel-right] 'ignore)
(global-set-key [double-wheel-right] 'ignore)
(global-set-key [triple-wheel-right] 'ignore)

Upvotes: 2

Stefan Arentz
Stefan Arentz

Reputation: 34945

I did the following:

;; Disable mouse wheel (and two finger swipe) scrolling because
;; it scrolls horribly and I would rather work without it.

(mouse-wheel-mode -1)

(global-set-key [wheel-up] 'ignore)
(global-set-key [wheel-down] 'ignore)
(global-set-key [double-wheel-up] 'ignore)
(global-set-key [double-wheel-down] 'ignore)
(global-set-key [triple-wheel-up] 'ignore)
(global-set-key [triple-wheel-down] 'ignore)

The last part disables the scroll wheel events, which gets rid of the annoying beeping.

Upvotes: 4

Ross Patterson
Ross Patterson

Reputation: 5742

I don't think what you're seeing is mouse wheel scrolling as much as tap-to-click on your trackpad. If your mouse pointer is pointed to a different part of the document than where you typing and you accidentally brush the trackpad and your trackpad/OS interprets that as a mouse click, then the your input point will jump to the place the mouse cursor is pointed at.

You can address by disabling tap-to-click or by using the feature availabe with some trackpad/OSes that disable the trackpad all together while you're typing. How you do those will depend on your trackpad/driver/OS combination.

Upvotes: 0

Michael Markert
Michael Markert

Reputation: 4026

It's enabled by default (at least since Emacs 23).

To turn it off (locally):

(mouse-wheel-mode -1)

To turn it off (globally):

M-x customize-option mouse-wheel-mode ; set to nil and save

But maybe you just want to adjust the settings: Take a look at M-x customize-group mouse RET

Upvotes: 8

Related Questions