Separate secondary stuff from core.

This commit is contained in:
Magnar Sveen
2012-06-07 11:11:19 +02:00
parent 00896cf47f
commit 139202758b
5 changed files with 280 additions and 266 deletions

35
mc-edit-lines.el Normal file
View File

@@ -0,0 +1,35 @@
(defun mc/edit-lines ()
"Add one cursor to each line of the active region.
Starts from mark and moves in straight down or up towards the
line point is on.
Could possibly be used to mark multiple regions with
mark-multiple if point and mark is on different columns."
(interactive)
(when (not (use-region-p))
(error "Mark a set of lines first."))
(mc/remove-additional-cursors)
(let* ((point-line (line-number-at-pos))
(mark-line (progn (exchange-point-and-mark) (line-number-at-pos)))
(navigation-func (if (< point-line mark-line) 'previous-line 'next-line)))
(deactivate-mark)
(while (not (eq (line-number-at-pos) point-line))
(mc/create-fake-cursor-at-point)
(funcall navigation-func))
(multiple-cursors-mode)))
(defun mc/edit-ends-of-lines ()
"Add one cursor to the end of each line in the active region."
(interactive)
(mc/edit-lines)
(mc/execute-command-for-all-fake-cursors 'end-of-line)
(end-of-line))
(defun mc/edit-beginnings-of-lines ()
"Add one cursor to the beginning of each line in the active region."
(interactive)
(mc/edit-lines)
(mc/execute-command-for-all-fake-cursors 'beginning-of-line)
(beginning-of-line))
(provide 'mc-edit-lines)