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

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

[nongnu] elpa/multiple-cursors 4c52fb1 358/434: Merge pull request #239


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 4c52fb1 358/434: Merge pull request #239 from ilohmar/dwim-mouse-select
Date: Sat, 7 Aug 2021 09:20:59 -0400 (EDT)

branch: elpa/multiple-cursors
commit 4c52fb1e560967ff6328fd3abca3025112201c69
Merge: 54c05c3 40eb74e
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Merge pull request #239 from ilohmar/dwim-mouse-select
    
    Extend mc/add-cursor-on-click to toggle fake cursors
---
 mc-mark-more.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index 68addce..f63887d 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -576,8 +576,9 @@ If the region is inactive or on a single line, it will 
behave like
          (<= (point) end))))
 
 ;;;###autoload
-(defun mc/add-cursor-on-click (event)
-  "Add a cursor where you click."
+(defun mc/toggle-cursor-on-click (event)
+  "Add a cursor where you click, or remove a fake cursor that is
+already there."
   (interactive "e")
   (mouse-minibuffer-check event)
   ;; Use event-end in case called from mouse-drag-region.
@@ -589,10 +590,17 @@ If the region is inactive or on a single line, it will 
behave like
     (if (numberp (posn-point position))
         (save-excursion
           (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)))
 
 ;;;###autoload
+(defalias 'mc/add-cursor-on-click 'mc/toggle-cursor-on-click)
+
+;;;###autoload
 (defun mc/mark-sgml-tag-pair ()
   "Mark the tag we're in and its pair for renaming."
   (interactive)



reply via email to

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