move-line.el
author Luke Hoersten <Luke@Hoersten.org>
Thu, 31 Oct 2013 00:28:51 -0500
changeset 66 b6182e0be08d
parent 65 839e0a541c76
permissions -rw-r--r--
Removed bell and added menu bar on OS X.

;; http://www.emacswiki.org/emacs/MoveLine

(defun move-line (n)
  "Move the current line up or down by N lines."
  (interactive "p")
  (setq col (current-column))
  (beginning-of-line) (setq start (point))
  (end-of-line) (forward-char) (setq end (point))
  (let ((line-text (delete-and-extract-region start end)))
    (forward-line n)
    (insert line-text)
    ;; restore point to original column in moved line
    (forward-line -1)
    (forward-char col)))

(defun move-line-up (n)
  "Move the current line up by N lines."
  (interactive "p")
  (move-line (if (null n) -1 (- n))))

(defun move-line-down (n)
  "Move the current line down by N lines."
  (interactive "p")
  (move-line (if (null n) 1 n)))

(message "Loading move-line...done")
(provide 'move-line)