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

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

[nongnu] elpa/multiple-cursors 2d6ffce 330/434: Support unmarking with n


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 2d6ffce 330/434: Support unmarking with no region. Change mc/mark-lines to preserve point.
Date: Sat, 7 Aug 2021 09:20:53 -0400 (EDT)

branch: elpa/multiple-cursors
commit 2d6ffce4c94cdbec1ea8ec086ea346423bafcdf1
Author: Justin Dove <dove@mit.edu>
Commit: Justin Dove <dove@mit.edu>

    Support unmarking with no region. Change mc/mark-lines to preserve point.
---
 mc-mark-more.el | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index 45a87fc..eed0035 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -127,14 +127,14 @@ Use like case-fold-search, don't recommend setting it 
globally.")
 With negative ARG, delete the last one instead.
 With zero ARG, skip the last one and mark next."
   (interactive "p")
-  (if (region-active-p)
-      (if (< arg 0)
-          (let ((cursor (mc/furthest-cursor-after-point)))
-            (if cursor
-                (mc/remove-fake-cursor cursor)
-              (error "No cursors to be unmarked")))
-        (mc/mark-more-like-this (= arg 0) 'forwards))
-    (mc/mark-lines arg 'forwards))
+  (if (< arg 0)
+      (let ((cursor (mc/furthest-cursor-after-point)))
+       (if cursor
+           (mc/remove-fake-cursor cursor)
+         (error "No cursors to be unmarked")))
+    (if (region-active-p)
+        (mc/mark-more-like-this (= arg 0) 'forwards)
+      (mc/mark-lines arg 'forwards)))
   (mc/maybe-multiple-cursors-mode))
 
 ;;;###autoload
@@ -155,14 +155,14 @@ With zero ARG, skip the last one and mark next."
 With negative ARG, delete the last one instead.
 With zero ARG, skip the last one and mark next."
   (interactive "p")
-  (if (region-active-p)
-      (if (< arg 0)
-          (let ((cursor (mc/furthest-cursor-before-point)))
-            (if cursor
-                (mc/remove-fake-cursor cursor)
-              (error "No cursors to be unmarked")))
-        (mc/mark-more-like-this (= arg 0) 'backwards))
-    (mc/mark-lines arg 'backwards))
+  (if (< arg 0)
+      (let ((cursor (mc/furthest-cursor-before-point)))
+       (if cursor
+           (mc/remove-fake-cursor cursor)
+         (error "No cursors to be unmarked")))
+    (if (region-active-p)
+        (mc/mark-more-like-this (= arg 0) 'backwards)
+      (mc/mark-lines arg 'backwards)))
   (mc/maybe-multiple-cursors-mode))
 
 ;;;###autoload
@@ -179,12 +179,16 @@ With zero ARG, skip the last one and mark next."
 
 (defun mc/mark-lines (num-lines direction)
   (dotimes (i num-lines)
-    (mc/create-fake-cursor-at-point)
-    (ecase direction
-      (forwards (loop do (next-logical-line 1 nil)
-                      while (mc/all-fake-cursors (point) (1+ (point)))))
-      (backwards (loop do (previous-logical-line 1 nil)
-                       while (mc/all-fake-cursors (point) (1+ (point))))))))
+    (mc/save-excursion
+     (let ((furthest-cursor (ecase direction
+                             (forwards  (mc/furthest-cursor-after-point))
+                             (backwards (mc/furthest-cursor-before-point)))))
+       (if (overlayp furthest-cursor)
+          (goto-char (overlay-get furthest-cursor 'point))))
+     (ecase direction
+       (forwards (next-logical-line 1 nil))
+       (backwards (previous-logical-line 1 nil)))
+     (mc/create-fake-cursor-at-point))))
 
 ;;;###autoload
 (defun mc/mark-next-lines (arg)



reply via email to

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