emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problems with scroll-preserve-screen-position and cua-mode


From: Jens Lautenbacher
Subject: problems with scroll-preserve-screen-position and cua-mode
Date: Thu, 08 Dec 2005 17:42:29 +0100

Hi,

using cua mode and it's scroll commands has the annoying problem that
the scrolling up to the top or down to the end of the buffer will kill
the ability to always have the cursor positioned  on the same screenline
- but more importantly to have the cursor positioned on the same buffer
positions while scrolling through the buffer (what i mean with this is:
I have point on a certain line, say the beginning of function "FOO" when
I start scrolling up and down with prior/next. The desired behavior is
that no matter how much I scroll, I want to be able to hit the original
position at the FOO function while scrolling by.)

This works more or less (not completely) when not using cua. But with
cu, the last thing when the buffer is scrolled up (or to the end) is to
move the cursor to point-min or point-max resp. Of course, scrolling
into the opposite direction breaks the desired behavior.

I have the following snippet in my .emacs, which does what I want. Maybe
one could add something similar to the cua scroll commands to always
have that behavior.

(setq ms-before-down 0)
(setq ms-before-up 0)

(defun my-scroll-down (&optional arg)
  (interactive)
  (if (not (equal ms-before-up 0))
      (progn
        (goto-char ms-before-up)
        (setq ms-before-up 0))
    (if (not (equal (point) (point-min)))
        (setq ms-before-down (point)))
    (cua-scroll-down arg)
    (if (not (equal (point) (point-min)))
        (setq ms-before-down 0))))

(defun my-scroll-up (&optional arg)
  (interactive)
  (if (not (equal ms-before-down 0))
      (progn
        (goto-char ms-before-down)
        (setq ms-before-down 0))
    (if (not (equal (point) (point-max)))
        (setq ms-before-up (point)))
    (cua-scroll-up arg)
    (if (not (equal (point) (point-max)))
        (setq ms-before-up 0))))

(global-set-key [next] 'my-scroll-up)
(global-set-key [prior] 'my-scroll-down)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]