mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
Factor out a superfluous variable
`mc--active-cursor-count' was effectively duplicating the purpose of `mc/num-cursors'. While the latter is necessarily slower (being a function), it is well-tested and stable.
This commit is contained in:
parent
cd967e720f
commit
3f1611c7cb
@ -157,8 +157,7 @@ highlights the entire width of the window."
|
|||||||
(set-marker (overlay-get o 'point) nil)
|
(set-marker (overlay-get o 'point) nil)
|
||||||
(set-marker (overlay-get o 'mark) nil)
|
(set-marker (overlay-get o 'mark) nil)
|
||||||
(mc/delete-region-overlay o)
|
(mc/delete-region-overlay o)
|
||||||
(delete-overlay o)
|
(delete-overlay o))
|
||||||
(decf mc--active-cursor-count))
|
|
||||||
|
|
||||||
(defun mc/pop-state-from-overlay (o)
|
(defun mc/pop-state-from-overlay (o)
|
||||||
"Restore the state stored in given overlay and then remove the overlay."
|
"Restore the state stored in given overlay and then remove the overlay."
|
||||||
@ -177,11 +176,6 @@ highlights the entire width of the window."
|
|||||||
"Returns a unique cursor id"
|
"Returns a unique cursor id"
|
||||||
(incf mc--current-cursor-id))
|
(incf mc--current-cursor-id))
|
||||||
|
|
||||||
(defvar mc--active-cursor-count 1
|
|
||||||
"Number of active cursors.
|
|
||||||
This number is incremented by `mc/create-fake-cursor-at-point'
|
|
||||||
and decremented by `mc/remove-fake-cursor'.")
|
|
||||||
|
|
||||||
(defvar mc--max-cursors-original nil
|
(defvar mc--max-cursors-original nil
|
||||||
"This variable maintains the original maximum number of cursors.
|
"This variable maintains the original maximum number of cursors.
|
||||||
When `mc/create-fake-cursor-at-point' is called and
|
When `mc/create-fake-cursor-at-point' is called and
|
||||||
@ -208,12 +202,11 @@ Saves the current state in the overlay to be restored later."
|
|||||||
(unless mc--max-cursors-original
|
(unless mc--max-cursors-original
|
||||||
(setq mc--max-cursors-original mc/max-cursors))
|
(setq mc--max-cursors-original mc/max-cursors))
|
||||||
(when mc/max-cursors
|
(when mc/max-cursors
|
||||||
(unless (< mc--active-cursor-count mc/max-cursors)
|
(unless (< (mc/num-cursors) mc/max-cursors)
|
||||||
(if (yes-or-no-p (format "%d active cursors. Continue? " mc--active-cursor-count))
|
(if (yes-or-no-p (format "%d active cursors. Continue? " (mc/num-cursors)))
|
||||||
(setq mc/max-cursors (read-number "Enter a new, temporary maximum: "))
|
(setq mc/max-cursors (read-number "Enter a new, temporary maximum: "))
|
||||||
(mc/remove-fake-cursors)
|
(mc/remove-fake-cursors)
|
||||||
(error "Aborted: too many cursors"))))
|
(error "Aborted: too many cursors"))))
|
||||||
(incf mc--active-cursor-count)
|
|
||||||
(let ((overlay (mc/make-cursor-overlay-at-point)))
|
(let ((overlay (mc/make-cursor-overlay-at-point)))
|
||||||
(overlay-put overlay 'mc-id (or id (mc/create-cursor-id)))
|
(overlay-put overlay 'mc-id (or id (mc/create-cursor-id)))
|
||||||
(overlay-put overlay 'type 'fake-cursor)
|
(overlay-put overlay 'type 'fake-cursor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user