Hook multiple-cursors into mark-multiple, first step:

- C-g in mark-multiple takes you to multiple-cursors
   Note: C-g again to remove extra cursors
This commit is contained in:
Magnar Sveen 2012-01-25 09:13:37 +01:00
parent 487e8be4a9
commit 80fdb6f68d

View File

@ -97,7 +97,7 @@ from being executed if in multiple-cursors-mode."
(unless multiple-cursors-mode
ad-do-it))))
;; Commands that makes a giant mess of multiple cursors
;; Commands that make a giant mess of multiple cursors
(unsupported-cmd yank-pop)
;; Commands that should be mirrored by all cursors
@ -114,8 +114,8 @@ from being executed if in multiple-cursors-mode."
kill-region-or-backward-word
backward-kill-word
backward-delete-char-untabify
delete-char
delete-backward-char
delete-char c-electric-delete-forward
delete-backward-char c-electric-backspace
zap-to-char
move-end-of-line-or-next-line
move-start-of-line-or-prev-line))
@ -216,6 +216,20 @@ mark-multiple if point and mark is on different columns."
(mc/execute-command-for-all-cursors 'beginning-of-line)
(beginning-of-line))
(defun mc/switch-to-cursors-from-mark-multiple ()
"Removes mark-multiple and switches to multiple cursors instead"
(interactive)
(let ((offset (- (point) (overlay-start mm/master))))
(save-excursion
(dolist (mirror mm/mirrors)
(goto-char (+ offset (overlay-start mirror)))
(mc/add-cursor-at-point)))
(mm/clear-all)
(deactivate-mark)
(multiple-cursors-mode)))
(define-key mm/keymap (kbd "C-g") 'mc/switch-to-cursors-from-mark-multiple)
(provide 'multiple-cursors)
;;; multiple-cursors.el ends here