From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: how to move the contents of the buffer one line up/down? Date: Mon, 14 Jul 2008 13:27:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <6e0qu9F4kpduU2@mid.individual.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1216068225 14474 80.91.229.12 (14 Jul 2008 20:43:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Jul 2008 20:43:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 14 22:44:32 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 1KIUuJ-0007cQ-AJ for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jul 2008 22:44:27 +0200 Original-Received: from localhost ([127.0.0.1]:37384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIUtR-0002bH-63 for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Jul 2008 16:43:33 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!x35g2000hsb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 68 Original-NNTP-Posting-Host: 24.6.97.120 Original-X-Trace: posting.google.com 1216067235 17524 127.0.0.1 (14 Jul 2008 20:27:15 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 14 Jul 2008 20:27:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x35g2000hsb.googlegroups.com; posting-host=24.6.97.120; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:160222 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:55572 Archived-At: Like Alan Mackenzie, i also defined a keystroke to scroll screen up or down by just 1 line. Had this for like 10 years. basically i just have this: (global-set-key (kbd "C-") (lambda () (interactive) (scroll-down 2))) (global-set-key (kbd "C-") (lambda () (interactive) (scroll-up 2))) However, this week i actually took them off. :D Relying on mouse scroll wheel instead, or recenter (default to C-l), just for a fresh change. If mouse is not available, well possibly i don't need to scroll screen in such way since as far as i looked, vast majority of major editors (X-code, Visual Studio, Eclipse) don't have it (i might be wrong since i haven't yet checked in detail). (so this is to experiment) Part of the other reason is that i can free up the modifier+arrow keyspace for more consistent use for, say, sexp navigation or other, havn't really decided what. Xah =E2=88=91 http://xahlee.org/ =E2=98=84 On Jul 14, 6:16 am, Alan Mackenzie wrote: > Hi, Tamas! > > On Mon, Jul 14, 2008 at 11:17:29AM +0000, Tamas K Papp wrote: > > Hi, > > I know that I can "center" my cursor with C-l. But sometimes it would = be > > really useful to do the following: have the contents of the buffer move > > up or down a couple of lines, with the cursor staying in the same place= . > > What function would do that? Then I could bind it to a key. > > There isn't really a decent existing Emacs function, but it's very easy > to write them. In fact, these commands were the first I ever wrote. > Here they are: I've bound them to - and -, so > they'll only work if you're in a GUI system (or you've already enhanced > your terminal keyboard setup). > > Additionally, - moves point 6 lines up, and > -- scrolls the screen 6 lines; just the same for > .... And quite a few other goodies, too. Try them! > > Enjoy! > > ######################################################################### > (defun scrollup-n (&optional n) > "Scroll the text up n (default 1) lines." > (interactive "p") > (scroll-up (or n 1)) > ) > (global-set-key [S-down] 'scrollup-n) > > (defun scrolldown-n (&optional n) > "Scroll the text down n (default 1) lines." > (interactive "p") > (scroll-down (or n 1)) > ) > (global-set-key [S-up] 'scrolldown-n) > > ...