unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* problems with scroll-preserve-screen-position and cua-mode
@ 2005-12-08 16:42 Jens Lautenbacher
  0 siblings, 0 replies; only message in thread
From: Jens Lautenbacher @ 2005-12-08 16:42 UTC (permalink / raw)


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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-08 16:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-08 16:42 problems with scroll-preserve-screen-position and cua-mode Jens Lautenbacher

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).