From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: liyer.vijay@gmail.com Newsgroups: gmane.emacs.help Subject: Re: Anyone have a 'move-line' function? Date: 3 May 2006 14:03:44 -0700 Organization: http://groups.google.com Message-ID: <1146690224.061525.281590@j73g2000cwa.googlegroups.com> References: <87d5ewj931.fsf@tallis.ilo.ucl.ac.uk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1146692436 8035 80.91.229.2 (3 May 2006 21:40:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 3 May 2006 21:40:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 03 23:40:35 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FbP5C-0000Vh-Tn for geh-help-gnu-emacs@m.gmane.org; Wed, 03 May 2006 23:40:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbP5C-00058A-FE for geh-help-gnu-emacs@m.gmane.org; Wed, 03 May 2006 17:40:30 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!j73g2000cwa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: 216.47.130.51 Original-X-Trace: posting.google.com 1146690230 27306 127.0.0.1 (3 May 2006 21:03:50 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 3 May 2006 21:03:50 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.2) Gecko/20060502 Ubuntu/dapper Firefox/1.5.0.2,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j73g2000cwa.googlegroups.com; posting-host=216.47.130.51; posting-account=dPba2w0AAAAAulCJ1KybNHojA2NW0cbx Original-Xref: shelby.stanford.edu gnu.emacs.help:139167 Original-To: help-gnu-emacs@gnu.org 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:34790 Archived-At: Joe Smith wrote: > If I start with this (^=point): > > one > two > th^ree > four > > And I run 'move-line-up' (say by M-up), I want this: > > one > th^ree > two > four > > Then run 'move-line-down' twice (say by M-down M-down) to get this: > > one > two > four > th^ree Here's a solution that doesn't add to the kill-ring (not that we'll reach the kill ring limit :-) (defun move-line-up (&optional n) "Moves current line up leaving point in place. With a prefix argument, moves up N lines." (interactive "p") (if (null n) (setq n 1)) (let ((col (current-column))) (beginning-of-line) (next-line 1) (transpose-lines (- n)) (previous-line 1) (forward-char col))) Cheers Vijay