From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Kamphausen Newsgroups: gmane.emacs.help Subject: Re: How to move the cursor to the bottom of the screen? Date: Thu, 10 Jan 2008 17:06:29 +0100 Organization: Church of Emacs Message-ID: <85zlvdpsvu.fsf@usenet.my.skamphausen.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1199983308 16945 80.91.229.12 (10 Jan 2008 16:41:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Jan 2008 16:41:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 10 17:42:10 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JD0Tp-0005Iv-5B for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Jan 2008 17:42:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JD0TR-0000KF-Lr for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Jan 2008 11:41:45 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!nuzba.szn.dk!pnx.dk!news.albasani.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-X-Trace: news.albasani.net HYwNyYTHKVrd7p4UtDlM8NBAr6V1GcflvGLDqvOmdgQ1bTeSvBzgBz2VeDD1D59AN/CAeySjCX9H4yOxlWZU6yIhFUWPkrDCARvEqpldgfFTSs0Aayx8nH5P+RKPu2GE Original-X-Complaints-To: abuse@albasani.net Original-NNTP-Posting-Date: Thu, 10 Jan 2008 16:06:29 +0000 (UTC) X-User-ID: S4CswC2rNFVKYjWBraZFMHBGhLlc1KGJIFXvfLMBCso= Cancel-Lock: sha1:I4rix0KtKC088EWwpnRRFn7APjE= sha1:6hG7ndHIZjK+javdvyNBP8gOoO8= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-NNTP-Posting-Host: MyN/qUjXPjOp8/7G7/4UxUzxpEfpOqYWzzTk2I1+SW4= Original-Xref: shelby.stanford.edu gnu.emacs.help:155209 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:50629 Archived-At: "Ye ilho" writes: > Hi everyone, > > I am sorry for my ignorance but I was trying to find out how to move > the cursor to the bottom/middle/top of the screen? > In other words, when I edit something, I sometimes want to go to the > top of the screen I see with one key stroke. There are two functions I've been using for years which allow me to use the home and end keys as follows: press once goto beginning/end of line press twice goto beginning/end of window press thrice goto beginning/end of buffer Those functions are: (defun chb-home () (interactive) (if (not (bolp)) (beginning-of-line) (if (eq this-command last-command) (cond ((not (= (point) (window-start))) (move-to-window-line 0) (beginning-of-line)) (t (goto-char (point-min))))))) (defun chb-end () (interactive) (if (not (eolp)) (end-of-line) (if (eq this-command last-command) (cond ((not (= (point) (save-excursion (move-to-window-line -1) (end-of-line) (point)))) (move-to-window-line -1) (end-of-line)) (t (goto-char (point-max))))))) I bind them like this: (global-set-key '[(home)] 'chb-home) (global-set-key '[(end)] 'chb-end) Very convenient. Regards, Stefan -- Stefan Kamphausen --- http://www.skamphausen.de a blessed +42 regexp of confusion (weapon in hand) You hit. The format string crumbles and turns to dust.