Re: move-lines.el: a lazy programmer's package to move lines around
Philip Kaludercic <[email protected]> Thu, 30 Jul 2026 20:02:28 +0000
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Pedro Andres Aranda Gutierrez <[email protected]> writes: > Hi, > I've been using this for some time now as an alternative to the move-text > package and was thinking about the possibility of releasing it in elpa: > > https://codeberg.org/paaguti/move-lines I am not sure if the complexity of the package really warrants a package, it is essentially just a single function that you can trim down to something like --8<---------------cut here---------------start------------->8--- ;;;###autoload (defun move-lines-down (arg start end) "Move region or line ARG times down. Use the current line when nothing is selected. Move full lines regardless of the position of the mark and the point." (interactive (list (prefix-numeric-value current-prefix-arg) (or (use-region-beginning) (pos-bol)) (or (use-region-end) (pos-eol)))) (let ((start (save-excursion (goto-char start) (pos-bol))) (end (save-excursion (goto-char end) (pos-bol (if (bolp) 1 2)))) (deactivate-mark nil)) (goto-char (if (> arg 0) end start)) (unless (= (forward-line arg) 0) (user-error "Cannot move %d lines" arg)) (when (use-region-p) (set-mark (point))) (insert (delete-and-extract-region start end)))) --8<---------------cut here---------------end--------------->8--- IIUC. This is just a rough rewrite, there are likely some edge-cases missing but I think something like this would be better added to Emacs itself instead of as a micro-package. But if you insist, I think we can clean up the code a bit (`move-lines-down' and `move-lines-up' are almost duplicates) and we could add the package to ELPA. > > Comments highly appretiated. > Best, /PA