|
|
|
@ -222,6 +222,30 @@ there's a region, all lines that region covers will be duplicated." |
|
|
|
(setq end (point)))) |
|
|
|
(goto-char (+ origin (* (length region) arg) arg))))) |
|
|
|
|
|
|
|
;; TODO: Remove code duplication by extracting something more generic |
|
|
|
(defun prelude-duplicate-and-comment-current-line-or-region (arg) |
|
|
|
"Duplicates and comments the current line or region ARG times. |
|
|
|
If there's no region, the current line will be duplicated. However, if |
|
|
|
there's a region, all lines that region covers will be duplicated." |
|
|
|
(interactive "p") |
|
|
|
(let (beg end (origin (point))) |
|
|
|
(if (and mark-active (> (point) (mark))) |
|
|
|
(exchange-point-and-mark)) |
|
|
|
(setq beg (line-beginning-position)) |
|
|
|
(if mark-active |
|
|
|
(exchange-point-and-mark)) |
|
|
|
(setq end (line-end-position)) |
|
|
|
(let ((region (buffer-substring-no-properties beg end))) |
|
|
|
(comment-or-uncomment-region beg end) |
|
|
|
(setq end (line-end-position)) |
|
|
|
(-dotimes arg |
|
|
|
(lambda (n) |
|
|
|
(goto-char end) |
|
|
|
(newline) |
|
|
|
(insert region) |
|
|
|
(setq end (point)))) |
|
|
|
(goto-char (+ origin (* (length region) arg) arg))))) |
|
|
|
|
|
|
|
(defun prelude-rename-file-and-buffer () |
|
|
|
"Renames current buffer and file it is visiting." |
|
|
|
(interactive) |
|
|
|
|