[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Anyone have a 'move-line' function?
From: |
liyer . vijay |
Subject: |
Re: Anyone have a 'move-line' function? |
Date: |
3 May 2006 14:03:44 -0700 |
User-agent: |
G2/0.2 |
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
RE: Anyone have a 'move-line' function?, Bourgneuf Francois, 2006/05/04