Permalink
Browse files

Adds move-region to emacs

  • Loading branch information...
picandocodigo committed Mar 4, 2013
1 parent b88963d commit 6b6d384b0e37f5d7c2b74b7f86921d7239846bf8
Showing with 33 additions and 2 deletions.
  1. +33 −2 .emacs
35 .emacs
@@ -8,9 +8,9 @@
'(progn
(color-theme-initialize)
;(color-theme-arjen)))
;(color-theme-gray30)))
(color-theme-gray30)))
;(color-theme-ld-dark)))
(color-theme-kingsajz)))
;(color-theme-kingsajz)))
(setq default-directory "~/workspace/")
(set-face-attribute 'default nil :height 90)
@@ -131,3 +131,34 @@
;; acute-to-html
(load "custom_libs/acute-to-html.el")
(defun move-line-region-up (start end n)
(interactive "r\np")
(if (region-active-p) (move-region-up start end n) (move-line-up n)))
(defun move-line-region-down (start end n)
(interactive "r\np")
(if (region-active-p) (move-region-down start end n) (move-line-down n)))
(defun move-region (start end n)
"Move the current region up or down by N lines."
(interactive "r\np")
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(let ((start (point)))
(insert line-text)
(setq deactivate-mark nil)
(set-mark start))))
(defun move-region-up (start end n)
"Move the current line up by N lines."
(interactive "r\np")
(move-region start end (if (null n) -1 (- n))))
(defun move-region-down (start end n)
"Move the current line down by N lines."
(interactive "r\np")
(move-region start end (if (null n) 1 n)))
(global-set-key (kbd "M-p") 'move-region-up)
(global-set-key (kbd "M-n") 'move-region-down)

0 comments on commit 6b6d384

Please sign in to comment.