From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Bourgneuf Francois" Newsgroups: gmane.emacs.help Subject: RE: Anyone have a 'move-line' function? Date: Thu, 4 May 2006 14:11:05 +0200 Message-ID: <8A921A5AACA1A64F936C730FC1F817210F3975@zw67246c.societe.mma.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1146744814 25697 80.91.229.2 (4 May 2006 12:13:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 May 2006 12:13:34 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 04 14:13:33 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 1Fbchy-0007iU-RZ for geh-help-gnu-emacs@m.gmane.org; Thu, 04 May 2006 14:13:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbchy-0000If-4V for geh-help-gnu-emacs@m.gmane.org; Thu, 04 May 2006 08:13:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fbcgz-0008Nh-2l for help-gnu-emacs@gnu.org; Thu, 04 May 2006 08:12:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fbcgv-0008Ll-53 for help-gnu-emacs@gnu.org; Thu, 04 May 2006 08:12:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbcgv-0008Lh-0h for help-gnu-emacs@gnu.org; Thu, 04 May 2006 08:12:21 -0400 Original-Received: from [195.101.229.226] (helo=Z3A7255c.societe.mma.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FbchV-0004m0-10 for help-gnu-emacs@gnu.org; Thu, 04 May 2006 08:12:58 -0400 Original-Received: from ZW67246C.societe.mma.fr ([10.200.3.36]) by zw67216c.societe.mma.fr with Microsoft SMTPSVC(5.0.2195.6713); Thu, 4 May 2006 14:11:06 +0200 content-class: urn:content-classes:message x-mimeole: Produced By Microsoft Exchange V6.0.6603.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Anyone have a 'move-line' function? Thread-Index: AcZu+jxrXxvzRZvXRL694/OnsfjK/AAePIxA Original-To: , X-OriginalArrivalTime: 04 May 2006 12:11:06.0308 (UTC) FILETIME=[D213E840:01C66F73] 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:34807 Archived-At: I think the transpose-line command may be what you're looking for. It is bound to C-x C-t. Exchange current line and previous line, leaving point after both. With argument ARG, takes previous line and moves it past ARG lines. With argument 0, interchanges line point is in with line mark is in. Bour9 -----Message d'origine----- De : help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.fr@gnu.org = [mailto:help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.fr@gnu.org= ] De la part de liyer.vijay@gmail.com Envoy=E9 : mercredi 3 mai 2006 23:04 =C0 : help-gnu-emacs@gnu.org Objet : Re: Anyone have a 'move-line' function? Joe Smith wrote: > If I start with this (^=3Dpoint): > > 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 _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs