mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
Fix click-toggling and make it robust (address all PR #239 comments)
- use marker-position for cursor overlay's point - new helper function finds fake cursor with its actual *point* where we want it - this also eliminates any need for additional require statements
This commit is contained in:
parent
4c52fb1e56
commit
e17851efd3
@ -72,6 +72,18 @@
|
|||||||
(setq furthest cursor)))
|
(setq furthest cursor)))
|
||||||
furthest))
|
furthest))
|
||||||
|
|
||||||
|
(defun mc/fake-cursor-at-point (&optional point)
|
||||||
|
"Return the fake cursor with its point right at POINT (defaults
|
||||||
|
to (point)), or nil."
|
||||||
|
(setq point (or point (point)))
|
||||||
|
(let ((cursors (mc/all-fake-cursors))
|
||||||
|
(c nil))
|
||||||
|
(catch 'found
|
||||||
|
(while (setq c (pop cursors))
|
||||||
|
(when (eq (marker-position (overlay-get c 'point))
|
||||||
|
point)
|
||||||
|
(throw 'found c))))))
|
||||||
|
|
||||||
(defun mc/region-strings ()
|
(defun mc/region-strings ()
|
||||||
(let ((strings (list (buffer-substring-no-properties (point) (mark)))))
|
(let ((strings (list (buffer-substring-no-properties (point) (mark)))))
|
||||||
(mc/for-each-fake-cursor
|
(mc/for-each-fake-cursor
|
||||||
@ -587,14 +599,15 @@ already there."
|
|||||||
(if (not (windowp (posn-window position)))
|
(if (not (windowp (posn-window position)))
|
||||||
(error "Position not in text area of window"))
|
(error "Position not in text area of window"))
|
||||||
(select-window (posn-window position))
|
(select-window (posn-window position))
|
||||||
(if (numberp (posn-point position))
|
(let ((pt (posn-point position)))
|
||||||
(save-excursion
|
(if (numberp pt)
|
||||||
(goto-char (posn-point position))
|
;; is there a fake cursor with the actual *point* right where we are?
|
||||||
(let ((existing (mc/last-fake-cursor-before (point))))
|
(let ((existing (mc/fake-cursor-at-point pt)))
|
||||||
(if (and existing
|
(if existing
|
||||||
(eq (overlay-get existing 'point) (point)))
|
|
||||||
(mc/remove-fake-cursor existing)
|
(mc/remove-fake-cursor existing)
|
||||||
(mc/create-fake-cursor-at-point)))))
|
(save-excursion
|
||||||
|
(goto-char pt)
|
||||||
|
(mc/create-fake-cursor-at-point))))))
|
||||||
(mc/maybe-multiple-cursors-mode)))
|
(mc/maybe-multiple-cursors-mode)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
Loading…
x
Reference in New Issue
Block a user