53

When I scroll in Emacs using mouse wheel, it scrolls 5 lines at a time, which, I think, is way too much - where do I set a new value?

Also, when I scroll in Emacs with a mouse (either wheel or scrollbar), the cursor jumps to stay inside the visible screen area - is there a way to override that behavior, making it staying on the line it was on, even when it goes out of screen? In other words, I don't want the position where newly typed symbols appear changed by the scrolling.

Any alternative suggestion on how I could peek into some remote section of code and then quickly return to the former position is also welcome.

Matt McClure
  • 16,009
  • 2
  • 28
  • 30
Headcrab
  • 6,838
  • 8
  • 40
  • 45

7 Answers7

87

You can control the amount in variable mouse-wheel-scroll-amount (in mwheel.el).

EDIT: E.g. Add (setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil))) to your .emacs for 1 line at a time.

I also have (setq mouse-wheel-progressive-speed nil) in my .emacs which I think is nicer behaviour.

luapyad
  • 3,860
  • 26
  • 20
  • 1
    Added (setq mouse-wheel-scroll-amount '(1)) into my .emacs, it works. And I like (setq mouse-wheel-progressive-speed nil) as well. – Headcrab Jan 15 '09 at 07:20
  • Headcrab, is this the answer you were looking for? If so, please accept it. – Geoff Feb 08 '12 at 20:29
  • Geoff, it's kind of a 3-in-1 question, with each answer addressing a different "1" of the "3", so I can't choose one particular answer. – Headcrab Feb 18 '12 at 06:03
  • Here's a link to the documentation if anyone doesn't want to look for it: https://www.gnu.org/software/emacs/manual/html_node/emacs/Mouse-Commands.html – userABC123 Jan 26 '16 at 21:51
  • 2
    You can use a higher number after `shift` for fast scrolling when the `shift` key is pressed. – xuhdev Apr 11 '16 at 01:20
  • Man, that "progressive speed" was killing me! Just nilling this one setting makes mouse scrolling work as expected. Who ever thought this was a good idea... – SnakE Jul 24 '18 at 17:22
8

Here is my setup:

(setq mouse-wheel-scroll-amount '(0.07))
(setq mouse-wheel-progressive-speed nil)
(setq ring-bell-function 'ignore)
Ivelin
  • 12,293
  • 5
  • 37
  • 35
6

I use breadcrumb to leave a trail around a buffer or all buffers.

Drop the breadcrumb, go look at whatever you want/need, then jump back to the breadcrumb. Here's what I have things set to, FWIW:

(global-set-key [(f6)] 'bc-set)
(global-set-key [(shift f6)] 'bc-list)
(global-set-key [(control f6)] 'bc-previous)
(global-set-key [(meta f6)] 'bc-next)
(global-set-key [(shift control f6)] 'bc-local-previous)
(global-set-key [(shift meta f6)] 'bc-local-next)

Hope that helps.

Joe Casadonte
  • 15,888
  • 11
  • 45
  • 57
  • I cannot find such "breadcrumb" or "bc" in either ELPA or MELPA. The website you mentioned is working but it has no info on where to get the package. Would you please edit the post and explain these parts. Thanks. – Mehrad Mahmoudian Jun 01 '23 at 10:42
2

It's impossible to have 'point' to exist somewhere outside of the current view; all the point movement commands move the display as well. I think that's a fundamental assumption that emacs makes.

I think what you want in your last point - to peek to a remote section and return - can be accomplished with registers:

This saves your position in register A:

C-x r A

And this restores the position from register A:

C-x r j A

If you do this a lot I'd advise binding those to things slightly less verbose :)

  • Tried those, it said "C-x r A is undefined". – Headcrab Jan 20 '09 at 06:32
  • `C-x r SPC A` where `A` is the name of the register (i.e. any single character). In cases like this, you can use `C-x r C-h` to see all bindings beginning with the prefix `C-x r`. – phils Nov 02 '11 at 20:17
2

You can use some bookmark solution or the register, but also the build-in mark and the mark-ring -

(default binding) 

C-Space to set mark (push a mark in mark ring)
C-u C-Space to pop a mark off the ring; repeat this a few more time should 
            get you where you like to be

or if you don't have highlight region on or you don't mind seeing the highlighting,

C-x C-x (exchange-point-and-mark) switch between you current point and your previous mark.
polyglot
  • 9,945
  • 10
  • 49
  • 63
2

Any alternative suggestion on how I could peek into some remote section of code and then quickly return to the former position is also welcome.

Ch 3 of Bob Glickstein's "Writing GNU Emacs Extensions" builds an unscroll-function (to return to a specified location in a scroll-command stack) as an programming example.

The code appears on-line, but there is a reported conflict with the ECB, if you use that.

Michael Paulukonis
  • 9,020
  • 5
  • 48
  • 68
0

Use easy-come-easy-go autonamed bookmarks -- Bookmark+. Just hit a key to create or delete -- as easy as setting the mark. They can be persistent or temporary. They can be automatically highlighted, if you like (the fringe or the line).

Drew
  • 29,895
  • 7
  • 74
  • 104