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

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

code snippet to do very smooth scrolling


From: zhaoway
Subject: code snippet to do very smooth scrolling
Date: 11 Feb 2003 14:31:50 -0800

Here is my first try to do very smooth scrolling. Do you like it?

It moves the window one line down or up the buffer, keeps the cursor
one line down or up its current position, and if possible, at the same
column.

----8<----
(global-set-key (kbd "<next>") 'my-page-down)
(defun my-page-down ()
  "12Feb03"
  (interactive)
  (let ((pos (point)))
    (goto-char (window-start))
    (next-line 1)
    (set-window-start (selected-window)
                      (point))
    (goto-char pos)
    (next-line 1)))

(global-set-key (kbd "<prior>") 'my-page-up)
(defun my-page-up ()
  "12Feb03"
  (interactive)
  (let ((pos (point)))
    (goto-char (window-start))
    (previous-line 1)
    (set-window-start (selected-window)
                      (point))
    (goto-char pos)
    (previous-line 1)))
---->8----


reply via email to

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