help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How do you scroll the screen without moving the cursor ? (theC-E and


From: Livin Stephen
Subject: Re: How do you scroll the screen without moving the cursor ? (theC-E and C-Y keys in vi)
Date: Sat, 4 Oct 2008 14:24:08 -0700 (PDT)
User-agent: G2/1.0

On Oct 3, 9:09 pm, Paul R <paul.r...@gmail.com> wrote:
> Chris> If that's not what you have in mind, I've been using these for
> Chris> some time. They keep the cursor in place and move the text
> Chris> underneath it.
>
> Chris> (defun scroll-down-in-place (n) (interactive "p")
> Chris> (previous-line n) (scroll-down n))
>
> Chris> (defun scroll-up-in-place (n) (interactive "p") (next-line n)
> Chris> (scroll-up n))
>
> To avoid weird behaviour when seeing ends of your buffer, use the code
> below.
>
> (global-set-key [down] (lambda ()
>                          (interactive)
>                          (next-line 1)
>                          (unless (eq (window-end) (point-max))
>                            (scroll-up 1))))
> (global-set-key [up] (lambda ()
>                        (interactive)
>                        (previous-line 1)
>                        (unless (eq (window-start) (point-min))
>                          (scroll-down 1))))
>
> --
>   Paul

The initial request from David Lam was for scrolling-in-place such
that
 the cursor remained "in place" with respect to the text - not with
respect to the frame/window.

In VI, C-e (C-y is the counterpart),
1. scrolls the page up by line, AND
2. moves the up cursor ALSO by one line - so that it stays at the same
character at which it was originally.

In the lisp examples (thanks for them!), I commented out "(previous-
line 1)" and "(next-line 1)" to achieve this.

 I *do* also like what your original lisp samples do.



reply via email to

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