[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: line-move-down-up
From: |
A Soare |
Subject: |
Re: line-move-down-up |
Date: |
Mon, 18 Apr 2011 15:37:30 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Deniz Dogan <deniz.a.m.dogan <at> gmail.com> writes:
>
> 2011/4/18 A Soare <as1789 <at> gmail.com>:
> >> Also, (next-line n) (beginning-of-line) could be replaced
> >> with (beginning-of-line (1+ n)).
> >>
> >
> > This is wrong in general.
> >
>
> Care to elaborate?
>
>
(progn
(goto-char (point-max))
(insert ? )
(beginning-of-line 4))
The definitive version I keep in .emacs is so:
;; move line
(defun line-move-down (n)
(if (> (point-max) (point-at-eol))
(let ((column (current-column) )
(line (delete-and-extract-region (point-at-bol) (1+
(point-at-eol)))))
(forward-line n)
(insert-string line)
(backward-char)
(move-to-column column) ) ) )
(define-key global-map [(meta up)]
(lambda (&optional n)
(interactive "P")
(line-move-down (if (numberp n) (- n) -1) ) ) )
(define-key global-map [(meta down)]
(lambda (&optional n)
(interactive "P")
(line-move-down (if (numberp n) n 1) ) ) )
line-move-down-up, Stephen J. Turnbull, 2011/04/18