Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to stop Emacs from automatically moving my text-cursor position (aka, point) while I'm scrolling? I keep losing my location and marks with this annoying behavior.

I tested the following suggestion, with no success:

(setq scroll-preserve-screen-position t
scroll-conservatively 0)

(I'm running Emacs 24.2 on Ubuntu and on OS X.)

share|improve this question

3 Answers 3

I think you want the behavior of cursor(point) and visible area should be like in notepad, gedit, others modern editors: ability to change visible area independently of point position and to immediately return visible area to point position after moving point. But emacs has another conception: the visible area always follows the point position and vise versa.

See also http://stackoverflow.com/questions/9616623/ctrl-up-down-style-scrolling-in-emacs

Previous answer shows special idiom: if you want to move the visible area (with the point together) far from current position and then to return the point in exactly the previous position you should have a habit to use mark-ring. There always is a way through mark ring to current working position: many commands, like isearch-forward, beginning-of-buffer, ace-jump-mode automatically save previous position in mark ring and you shouldn't use C-<SPC> C-<SPC> before, but only C-u C-<SPC> for jumping back. Scrolling commands, like scroll-up or mwheel-scroll, don't automatically save previous position by default because it may produce too many excessive marks.

You can use commands clone-indirect-buffer or view-buffer-other-window for independent work with buffer in few places. And use command recenter-top-bottom (C-l) to continuously hold point in center of visible area.

share|improve this answer
    
Thanks. Interesting answer. There seems to be a problem with my Emacs, though (both in Mac and in Ubuntu): C-u C-<SPC> doesn't seem to be working. I don't know if it's a problem of cua-mode or something. I tried running Emacs with -q option, but nothing changed. Any ideas? –  NVaughan Jan 8 '13 at 23:44

I don't know if there is a way to stop emacs from moving your point when scrolling. But if you would like to save your location to return to it later, you can use the mark ring.

That is, type C-<SPC> C-<SPC> to push the current point location onto the mark ring, then later type C-u C-<SPC> to set point to the previous location in the mark ring.

share|improve this answer

I use this:

;;; scrollers - M-f, M-b
(global-set-key "\M-f" "\C-u1\C-v")
(global-set-key "\M-b" "\C-u1\M-v")
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.