Extend mc/add-cursor-on-click to toggle fake cursors

- rename function accordingly and add alias
This commit is contained in:
Ingo Lohmar 2016-03-01 20:31:47 +01:00
parent 54c05c3e24
commit 40eb74e3e4

View File

@ -576,8 +576,9 @@ If the region is inactive or on a single line, it will behave like
(<= (point) end)))) (<= (point) end))))
;;;###autoload ;;;###autoload
(defun mc/add-cursor-on-click (event) (defun mc/toggle-cursor-on-click (event)
"Add a cursor where you click." "Add a cursor where you click, or remove a fake cursor that is
already there."
(interactive "e") (interactive "e")
(mouse-minibuffer-check event) (mouse-minibuffer-check event)
;; Use event-end in case called from mouse-drag-region. ;; Use event-end in case called from mouse-drag-region.
@ -589,9 +590,16 @@ If the region is inactive or on a single line, it will behave like
(if (numberp (posn-point position)) (if (numberp (posn-point position))
(save-excursion (save-excursion
(goto-char (posn-point position)) (goto-char (posn-point position))
(mc/create-fake-cursor-at-point))) (let ((existing (mc/last-fake-cursor-before (point))))
(if (and existing
(eq (overlay-get existing 'point) (point)))
(mc/remove-fake-cursor existing)
(mc/create-fake-cursor-at-point)))))
(mc/maybe-multiple-cursors-mode))) (mc/maybe-multiple-cursors-mode)))
;;;###autoload
(defalias 'mc/add-cursor-on-click 'mc/toggle-cursor-on-click)
;;;###autoload ;;;###autoload
(defun mc/mark-sgml-tag-pair () (defun mc/mark-sgml-tag-pair ()
"Mark the tag we're in and its pair for renaming." "Mark the tag we're in and its pair for renaming."