unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jens Lautenbacher <jtl@schlund.de>
Subject: problems with scroll-preserve-screen-position and cua-mode
Date: Thu, 08 Dec 2005 17:42:29 +0100	[thread overview]
Message-ID: <1134060150.20114.5.camel@britten.laudi.ka> (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)

                 reply	other threads:[~2005-12-08 16:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1134060150.20114.5.camel@britten.laudi.ka \
    --to=jtl@schlund.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).