help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keybinding to transpose current line with next line


From: Emanuel Berg
Subject: Re: Keybinding to transpose current line with next line
Date: Thu, 24 Sep 2020 01:32:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

> (defun move-line (&optional lines)
>   (interactive "*p")
>   (let ((lin (line-number-at-pos))
>         (col (current-column))
>         (num-lines (or lines 1)) )
>     (beginning-of-line)
>     (let ((line (thing-at-point 'line)))
>       (delete-region (point-at-bol) (point-at-eol))
>       (delete-char 1)
>       (goto-char (point-min))
>       (forward-line (+ lin num-lines -1))
>       (insert line)
>       (forward-line -1)
>       (beginning-of-line)
>       (forward-char col) )))
> (defalias 'ml #'move-line)

But I still think just killing the line manually,
move point, and yank it, is preferable...

KISS (keep it simple software)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]