[comp.emacs] Can scrolling be changed?

hollen@spot.megatek.uucp (Dion Hollenbeck) (10/29/88)

Can the method of scrolling be changed in GNU-emacs?  It currently
repaints the entire screen and moves the cursor to the  center
when scrolling up or down is needed.  Can it be made to scroll
one line at a time up or down like a regular terminal?


	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

                                seismo!s3sun!megatek!hollen
                                ames!scubed/

nate@mipos2.intel.com (Nate Hess) (10/30/88)

In article <392@megatek.UUCP>, hollen@spot (Dion Hollenbeck) writes:
>Can the method of scrolling be changed in GNU-emacs?  It currently
>repaints the entire screen and moves the cursor to the  center
>when scrolling up or down is needed.  Can it be made to scroll
>one line at a time up or down like a regular terminal?

In GNU Emacs, there is usually a variable that controls behavior such as
this.  What I did to discover the variable name was
'C-h v scroll TAB', which completed to 'scroll-step'.  Upon pressing
RET, I was given a help buffer containing:

scroll-step's value is 0

Documentation:
*The number of lines to try scrolling a window by when point moves out.
If that fails to bring point back on screen, point is centered instead.
If this is zero, point is always centered after it moves off screen.


So, just do a

(setq scroll-step 1)

to get what you want.

--woodstock
--
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

woodstock@sc.intel.com    ...!{decwrl|hplabs!oliveb|amd}!intelca!mipos3!nate 

spolsky-joel@CS.YALE.EDU (Joel Spolsky) (10/31/88)

In article <3097@mipos3.intel.com> woodstock@sc.intel.com (Nate Hess) writes:
|
| In article <392@megatek.UUCP>, hollen@spot (Dion Hollenbeck) writes:
| |
| | Can the method of scrolling be changed in GNU-emacs?  It currently
| | repaints the entire screen and moves the cursor to the  center
| | when scrolling up or down is needed.  Can it be made to scroll
| | one line at a time up or down like a regular terminal?
| |
| ... just do a
| 
| (setq scroll-step 1)
| 
| to get what you want.
|

This works ok in *many* cases but not always. For example, if emacs
decides that scrolling one line is not enough (e.g., when the line to
be brought in is longer than the screen width and wraps to the next
physical line), it will still scroll half a screen.

+----------------+---------------------------------------------------+
|  Joel Spolsky  | bitnet: spolsky@yalecs     uucp: ...!yale!spolsky |
|                | arpa:   spolsky@yale.edu   voicenet: 203-436-1483 |
+----------------+---------------------------------------------------+
                                               #include <disclaimer.h>

beede@pavo.SRC.Honeywell.COM (Michael Beede) (10/31/88)

Execute C-H C-V scroll-step.

Include (setq scroll-step 1) in your .emacs to get fairly reasonable
behavior.  If you drive the cursor off the screen too fast, recenter
will take place anyway.

Mike Beede  MN55-7282              Secure Computing Technology Center
Honeywell Systems & Research Center  (612) 782-7147
2855 Anthony Lane South - Suite 130
Minneapolis MN	                   beede@src.honeywell.com     

bug@bucsb.UUCP (Z^) (10/31/88)

In article <3097@mipos3.intel.com> woodstock@sc.intel.com (Nate Hess) writes:
>In article <392@megatek.UUCP>, hollen@spot (Dion Hollenbeck) writes:
>>Can the method of scrolling be changed in GNU-emacs?  It currently
>>repaints the entire screen and moves the cursor to the  center
>>when scrolling up or down is needed.  Can it be made to scroll
>>one line at a time up or down like a regular terminal?
>
>In GNU Emacs, there is usually a variable that controls behavior such as
>this.  What I did to discover the variable name was
>'C-h v scroll TAB', which completed to 'scroll-step'.  Upon pressing
>RET, I was given a help buffer containing:
>
>scroll-step's value is 0
>
>Documentation:
>*The number of lines to try scrolling a window by when point moves out.
>If that fails to bring point back on screen, point is centered instead.
>If this is zero, point is always centered after it moves off screen.
>
>
>So, just do a
>
>(setq scroll-step 1)
>
>to get what you want.
>

i tried this and it works when scrolling with arrows keys very badly...
if i scroll to fast it reverts back to the centering method....
so my question is ..can this be fixed so no matter how fast i scroll
with the arrow keys it will only go one line at a time?

-Jay-

-- 


                              -Jay-
**************************************************************************
Remember- to err is human......
			to moo is bovine.
**************************************************************************

kjones@talos.UUCP (Kyle Jones) (11/01/88)

In article <392@megatek.UUCP>, hollen@spot (Dion Hollenbeck) writes:
>Can it be made to scroll one line at a time up or down like a regular
>terminal?

woodstock, et. al.
>(setq scroll-step 1)

In article <2120@bucsb.UUCP> bug@bucsb.bu.edu (Jay Wasserman) writes:
>i tried this and it works when scrolling with arrows keys very badly...
>if i scroll to fast it reverts back to the centering method....
>so my question is ..can this be fixed so no matter how fast i scroll
>with the arrow keys it will only go one line at a time?

No, unless you're willing (and capable!) of hacking the Emacs display
code.  Not too long ago someone else wanted one-step scrolling but
they wanted it in a shell buffer, which isn't what you asked for.

The only use that I can think of for the type of one-step scrolling
you want is searching for a particular point in a file.  That can be
accomplished much easier and faster with a fixed string or regular
expression search.

norden@oucsace.cs.OHIOU.EDU (Jeffrey Norden) (11/04/88)

In article <347@talos.UUCP> kjones@talos.UUCP (Kyle Jones) writes:
>>Can it be made to scroll one line at a time up or down like a regular
>>terminal?
 <discussion of scroll-step omitted>
>> ..can this be fixed so no matter how fast i scroll
>>with the arrow keys it will only go one line at a time?
>No, unless you're willing (and capable!) of hacking the Emacs display
>code. 

Here is a hackey way to get emacs to (almost) always scroll one line at a
time.  Put the following re-defintions of next-line and prev-line in
your .emacs file:

------------------------------------------------------------------------------
;; My own versions of next-line and previous-line.  These almost never recenter
;; the buffer.
(defun next-line (arg) (interactive"p")
  (if (> arg 0) (setq dir 1) (setq dir -1))
  (while
      (not (pos-visible-in-window-p (save-excursion (line-move arg) (point))))
    (scroll-up dir))
  (line-move arg))
(defun previous-line (arg) (interactive"p")
  (next-line (- arg)))
------------------------------------------------------------------------------

My own feeling is that scroll-step should be extended to allow you to do this.
A reasonable extension would be to have (setq scroll-step -1) cause emacs to
always scroll by the minimum number of lines needed to bring the point back
onto the screen.  I've been meaning to do this for a while (hacking at the 
c-code is necessary), I might have some time next month.  If I'm successful,
I'll post the results.
				-Jeff Norden, norden@ace.cs.ohio.edu
				 Dept of Math, Ohio Univ, Athens OH 45701

tim@lucretia.esa.oz (Tim Bunce) (11/21/88)

In article <3097@mipos3.intel.com> woodstock@sc.intel.com (Nate Hess) writes:
>In article <392@megatek.UUCP>, hollen@spot (Dion Hollenbeck) writes:
>>Can the method of scrolling be changed in GNU-emacs?  It currently
>>repaints the entire screen and moves the cursor to the  center
>>when scrolling up or down is needed.  Can it be made to scroll
>>one line at a time up or down like a regular terminal?
>...
>So, just do a
>(setq scroll-step 1)
>to get what you want.
>...

As an aside, VAXTPU on VMS machines has a very flexible approach to scrolling
that the GNU project may like to emulate.

Under TPU you can not only specify by how much the screen should scroll (up or
down) but also at what point a cursor motion will trigger a scroll.

For example, you can specify that the window should scroll down by one line
when ever the cursor tries to move onto the top line of the window and similarly
for scrolling down. (This is my favourite set-up -- it means that you can always
some of the context of the line that you are on.)

This approach also allows you to keep the cursor centered in the window, or on
the 2nd line or last line or ...

I have not looked at the emacs code but I sure someone could produce and publish
a simple patch. What do you think?

-- 
Tim Bunce:             tim@attila.oz.AU (tim%attila.oz.AU@UUNET.UU.NET)
---------              {uunet,mcvax,ukc,nttlab}!munnari!attila.oz!tim
JANET: (POST) tim%au.oz.attila@EAN-RELAY  (MAIL) EAN%"tim@au.oz.attila"