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

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

Re: how to position cursor at top/middle/bottom of the current screen?


From: Chris McMahan
Subject: Re: how to position cursor at top/middle/bottom of the current screen?
Date: Wed, 08 Oct 2008 19:42:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (windows-nt)

I've been using this function for many years. It cycles the current
cursor and text position from the middle to the top then to the bottom
of the screen and back.

Just hit C-l repeatedly to change position.

I think this is what you're looking for... 

- Chris

;;;======================================================================
;;; modify the buffer centering command C-l
;; (thanks to Michael.Luetzeler@unibw-muenchen.de)
(defun cm-recenter-display (arg)
  "Move point in window and redisplay screen. 
First time, leaves point in the middle of the window.
Second time, leaves point near top of window.
Third time, leaves point near bottom of window.
With just one \\[universal-argument] arg, redraw screen without moving point.
With numeric arg, redraw around that line."
  (interactive "P")
    (cond ((consp arg)
           (recenter)
           (recenter line));; (redraw-display) bombs in Epoch 3.1.
          (arg
           (recenter (prefix-numeric-value arg)))
        ((eq last-command 'recenter-first)
           (setq this-command 'recenter-second)
           (recenter 1))
        ((eq last-command 'recenter-second)
           (setq this-command nil)
           (recenter -2))
        (t
           (setq this-command 'recenter-first)
           (recenter nil))))

(global-set-key "\C-l" 'cm-recenter-display)
;;;======================================================================

- Chris


"David Lam" <david.k.lam1@gmail.com> writes:

> like... theres M-< and M->, but those move to the cursor to the very
> top/bottom of the file
>
> i wanna just move the cursor relative to the current text on the
> screen... is there a built-in function for this?
>

-- 
     (.   .)
  =ooO=(_)=Ooo=====================================
  Chris McMahan | first_initiallastname@one.dot.net
  =================================================


reply via email to

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