[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you scroll the screen without moving the cursor ? (the C-E an
From: |
Joe Casadonte |
Subject: |
Re: How do you scroll the screen without moving the cursor ? (the C-E and C-Y keys in vi) |
Date: |
Fri, 10 Oct 2008 17:49:56 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (windows-nt) |
I wrote these years ago; maybe they will help?
(defun scroll-in-place (scroll-up)
"Scroll window up (or down) without moving point (if possible).
SCROLL-Up is non-nil to scroll up one line, nil to scroll down."
(interactive)
(let ((pos (point))
(col (current-column))
(up-or-down (if scroll-up 1 -1)))
(scroll-up up-or-down)
(if (pos-visible-in-window-p pos)
(goto-char pos)
(if (or (eq last-command 'next-line)
(eq last-command 'previous-line))
(move-to-column temporary-goal-column)
(move-to-column col)
(setq temporary-goal-column col))
(setq this-command 'next-line))))
;;;; ------------------------------------------------------------------------
(defun scroll-up-in-place ()
"Scroll window up without moving point (if possible)."
(interactive)
(scroll-in-place t))
;;;; ------------------------------------------------------------------------
(defun scroll-down-in-place ()
"Scroll window up without moving point (if possible)."
(interactive)
(scroll-in-place nil))
(global-set-key (read-kbd-macro "M-<down>") 'scroll-up-in-place)
(global-set-key (read-kbd-macro "M-<up>") 'scroll-down-in-place)
--
Regards,
joe
Joe Casadonte
jcasadonte@northbound-train.com
------------------------------------------------------------------------------
Llama Fresh Farms => http://www.northbound-train.com
Ramblings of a Gay Man => http://www.northbound-train.com/ramblings
Emacs Stuff => http://www.northbound-train.com/emacs.html
Music CD Trading => http://www.northbound-train.com/cdr.html
------------------------------------------------------------------------------
Live Free, that's the message!
------------------------------------------------------------------------------