From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: zw@netspeed-tech.com (zhaoway) Newsgroups: gmane.emacs.help Subject: code snippet to do very smooth scrolling Date: 11 Feb 2003 14:31:50 -0800 Organization: http://groups.google.com/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <345c8989.0302111431.1db3f4e6@posting.google.com> NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1045002835 32248 80.91.224.249 (11 Feb 2003 22:33:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 11 Feb 2003 22:33:55 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18iiyN-0008Nf-00 for ; Tue, 11 Feb 2003 23:33:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18iizy-0006QG-02 for gnu-help-gnu-emacs@m.gmane.org; Tue, 11 Feb 2003 17:35:30 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: 218.2.232.132 Original-X-Trace: posting.google.com 1045002710 32607 127.0.0.1 (11 Feb 2003 22:31:50 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: 11 Feb 2003 22:31:50 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:110066 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6570 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6570 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 "") '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 "") '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----