Answering your EMACS questions

Contributed by Ben Wong
"Han" == Han Xu  writes:


    Han> How can I let emacs only move the window displaying down
    Han> ONE line ? i.e. the invisible line just shows up at the
    Han> bottom of the window, instead of the center ?


The answer is to put the following line in your .emacs file. (I
haven't tried this personally, let me know if it doesn't work):

(setq scroll-conservatively 1)


By the way, here's one way you could have found the solution. I'm
laying this out explicitly so you can try it and then answer emacs
questions other people ask on slush.

First, you might look and see if the answer is in the FAQ:

   KEYS I TYPED				COMMENTARY
   ------------				----------
   C-h					; Control H gets you help in emacs
   ?					; Show possible ways of getting help
   SPACE				; Page down to find the option for FAQ
   F					; Ah, it's the capital letter F
   C-s scroll				; Search the FAQ for the word scroll
   C-s					; First hit was a dud, go to the next
   RET					; Ah, there it is

The FAQ has a solution, but also suggests read the "Scrolling" section
of the online manual. So, you could do this to read the emacs manual:

   KEYS I TYPED				COMMENTARY
   ------------				----------
   C-h					; Help prefix
   ?					; I forget, what key next for info?
   					; Ah, it's 'i' for "info"
   i					; Go to the meta info node
   m emacs RET				; Choose the "emacs" menu option
   m scrolling RET			; Choose the "scrolling" section

Read through the text and you'll come across this paragraph:

   Scrolling happens automatically if point has moved out of the
   visible portion of the text when it is time to display. Normally,
   automatic scrolling centers point vertically within the window.
   However, if you set `scroll-conservatively' to a small number N,
   then if you move point just a little off the screen--less than N
   lines--then Emacs scrolls the text just far enough to bring point
   back on screen. By default, `scroll-conservatively' is 0.

This is an even better answer than in the FAQ (which is old). (By the
way, the term "point" is just an affectionate name emacs uses for the
cursor). Since we know that the .emacs file (which gets read when
emacs starts up) is just lisp, we can create a command to make emacs
not recenter the screen if you scroll just one-line down whether via
the arrow keys or C-n / C-p.

     (setq scroll-conservatively 1).

Voila.


	 Ben

P.S. That's not how I actually found the answer. I actually did this
     to search through the online emacs manual:

          C-h i m emacs M-s scroll RET RET

     Normally, I keep hitting M-s until I find the right page, but in
     this case a section labelled "scrolling" came up first so I just
     cancelled the search with the first RETURN and then opened the
     section with the second.


Monitor this page for changes