Created
June 2, 2011 19:49
-
-
Save georgi/1005148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun copy-line (n) | |
(let ((column (current-column)) | |
(line (buffer-substring (line-beginning-position) (+ (line-end-position) 1)))) | |
(beginning-of-line) | |
(forward-line n) | |
(insert line) | |
(forward-line -1) | |
(forward-char column))) | |
(defun copy-line-up () | |
"Copy the current line up" | |
(interactive) | |
(copy-line 0)) | |
(defun copy-line-down () | |
"Copy the current line down" | |
(interactive) | |
(copy-line 1)) | |
(defun move-line (n) | |
(let ((column (current-column)) | |
(line (delete-and-extract-region (line-beginning-position) (+ (line-end-position) 1)))) | |
(forward-line n) | |
(insert line) | |
(forward-line -1) | |
(forward-char column))) | |
(defun move-line-up () | |
"Move the current line up" | |
(interactive) | |
(move-line -1)) | |
(defun move-line-down () | |
"Move the current line down" | |
(interactive) | |
(move-line 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment