[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:27:07 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
OK, so how about this?
- does not use the kill ring
- point remains in the same (textual) line, at the
same column
- move forward or backward (with lines, e.g., -1 to
move backward one line)
- move forward or backward any number of lines (with
lines by any number of lines)
- set up keys and aliases as fit...
(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)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
- Keybinding to transpose current line with next line, Christopher Dimech, 2020/09/22
- Re: Keybinding to transpose current line with next line, Yuri Khan, 2020/09/22
- Re: Keybinding to transpose current line with next line, Emanuel Berg, 2020/09/22
- Re: Keybinding to transpose current line with next line, Yuri Khan, 2020/09/23
- Re: Keybinding to transpose current line with next line, Emanuel Berg, 2020/09/23
- Re: Keybinding to transpose current line with next line, Marcin Borkowski, 2020/09/23
- Re: Keybinding to transpose current line with next line, Emanuel Berg, 2020/09/23
- Re: Keybinding to transpose current line with next line,
Emanuel Berg <=
- Re: Keybinding to transpose current line with next line, Emanuel Berg, 2020/09/23
- Re: Keybinding to transpose current line with next line, Emanuel Berg, 2020/09/23
Re: Keybinding to transpose current line with next line, Francis Belliveau, 2020/09/22