emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/multiple-cursors 3f1611c 345/434: Factor out a superfluous


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 3f1611c 345/434: Factor out a superfluous variable
Date: Sat, 7 Aug 2021 09:20:56 -0400 (EDT)

branch: elpa/multiple-cursors
commit 3f1611c7cbd4daa52f15cb3a5f3bbcc11d4eb949
Author: Sean Allred <code@seanallred.com>
Commit: Sean Allred <code@seanallred.com>

    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.
---
 multiple-cursors-core.el | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index cba6da6..6602703 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -157,8 +157,7 @@ highlights the entire width of the window."
   (set-marker (overlay-get o 'point) nil)
   (set-marker (overlay-get o 'mark) nil)
   (mc/delete-region-overlay o)
-  (delete-overlay o)
-  (decf mc--active-cursor-count))
+  (delete-overlay o))
 
 (defun mc/pop-state-from-overlay (o)
   "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"
   (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
   "This variable maintains the original maximum number of cursors.
 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
     (setq mc--max-cursors-original mc/max-cursors))
   (when mc/max-cursors
-    (unless (< mc--active-cursor-count mc/max-cursors)
-      (if (yes-or-no-p (format "%d active cursors. Continue? " 
mc--active-cursor-count))
+    (unless (< (mc/num-cursors) mc/max-cursors)
+      (if (yes-or-no-p (format "%d active cursors. Continue? " 
(mc/num-cursors)))
           (setq mc/max-cursors (read-number "Enter a new, temporary maximum: 
"))
         (mc/remove-fake-cursors)
         (error "Aborted: too many cursors"))))
-  (incf mc--active-cursor-count)
   (let ((overlay (mc/make-cursor-overlay-at-point)))
     (overlay-put overlay 'mc-id (or id (mc/create-cursor-id)))
     (overlay-put overlay 'type 'fake-cursor)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]