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

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

[nongnu] elpa/multiple-cursors e31b1eb 360/434: Merge pull request #240


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors e31b1eb 360/434: Merge pull request #240 from ilohmar/toggle-click-improvements
Date: Sat, 7 Aug 2021 09:20:59 -0400 (EDT)

branch: elpa/multiple-cursors
commit e31b1eb59ce85f6f001b990112e6503aed357eba
Merge: 4c52fb1 e17851e
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Merge pull request #240 from ilohmar/toggle-click-improvements
    
    Fix click-toggling and make it robust (address all PR #239 comments)
---
 mc-mark-more.el | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index f63887d..02a67f4 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -72,6 +72,18 @@
        (setq furthest cursor)))
     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 ()
   (let ((strings (list (buffer-substring-no-properties (point) (mark)))))
     (mc/for-each-fake-cursor
@@ -587,14 +599,15 @@ already there."
     (if (not (windowp (posn-window position)))
         (error "Position not in text area of window"))
     (select-window (posn-window position))
-    (if (numberp (posn-point position))
-        (save-excursion
-          (goto-char (posn-point position))
-          (let ((existing (mc/last-fake-cursor-before (point))))
-            (if (and existing
-                     (eq (overlay-get existing 'point) (point)))
+    (let ((pt (posn-point position)))
+      (if (numberp pt)
+          ;; is there a fake cursor with the actual *point* right where we are?
+          (let ((existing (mc/fake-cursor-at-point pt)))
+            (if 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)))
 
 ;;;###autoload



reply via email to

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