all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chris McMahan <cmcmahan@one.net>
To: help-gnu-emacs@gnu.org
Subject: Re: how to position cursor at top/middle/bottom of the current screen?
Date: Wed, 08 Oct 2008 19:42:03 -0400	[thread overview]
Message-ID: <7shc7m64dw.fsf@one.net> (raw)
In-Reply-To: mailman.624.1223507380.25473.help-gnu-emacs@gnu.org

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	other threads:[~2008-10-08 23:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.624.1223507380.25473.help-gnu-emacs@gnu.org>
2008-10-08 23:42 ` Chris McMahan [this message]
2008-11-03  9:25   ` how to position cursor at top/middle/bottom of the current screen? Xavier Maillard
     [not found]   ` <mailman.2762.1225711680.25473.help-gnu-emacs@gnu.org>
2008-11-03 13:29     ` Richard Riley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7shc7m64dw.fsf@one.net \
    --to=cmcmahan@one.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.