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

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

[nongnu] elpa/multiple-cursors fcbb7a4 152/434: Make mc/cycle-forward an


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors fcbb7a4 152/434: Make mc/cycle-forward and mc/cycle-backward loop around by default.
Date: Sat, 7 Aug 2021 09:20:15 -0400 (EDT)

branch: elpa/multiple-cursors
commit fcbb7a4df99eb37c2fe7589c3a8ac1dcbe953395
Author: Marco Baringer <mb@bese.it>
Commit: Marco Baringer <mb@bese.it>

    Make mc/cycle-forward and mc/cycle-backward loop around by default.
    
    Instead of erroring if there is no next (respectively previous) cursor
    mc/cycle-forward (respectively mc/cycle-backward) will just loop back
    to the first (respectively last) cursor.
---
 mc-cycle-cursors.el | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el
index f70a96a..2aaade0 100644
--- a/mc-cycle-cursors.el
+++ b/mc-cycle-cursors.el
@@ -54,23 +54,31 @@
          (setq prev cursor))))
     prev))
 
-(defun mc/cycle-forward ()
-  (interactive)
+(defun mc/cycle-forward (&optional error-if-no-next-cursor)
+  (interactive (list prefix-arg))
   (let ((next-cursor (mc/next-cursor-after-point)))
-    (unless next-cursor
+    (cond
+     (next-cursor 
+      (mc/create-fake-cursor-at-point)
+      (mc/pop-state-from-overlay next-cursor)
+      (recenter))
+     (error-if-no-next-cursor
       (error "We're already at the last cursor"))
-    (mc/create-fake-cursor-at-point)
-    (mc/pop-state-from-overlay next-cursor)
-    (recenter)))
+     (t
+      (mc/cycle-backward t)))))
 
-(defun mc/cycle-backward ()
-  (interactive)
+(defun mc/cycle-backward (&optional error-if-no-previous-cursor)
+  (interactive (list prefix-arg))
   (let ((prev-cursor (mc/prev-cursor-before-point)))
-    (unless prev-cursor
+    (cond 
+     (prev-cursor
+      (mc/create-fake-cursor-at-point)
+      (mc/pop-state-from-overlay prev-cursor)
+      (recenter))
+     (error-if-no-previous-cursor
       (error "We're already at the first cursor"))
-    (mc/create-fake-cursor-at-point)
-    (mc/pop-state-from-overlay prev-cursor)
-    (recenter)))
+     (t
+      (mc/cycle-forward t)))))
 
 (define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)
 (define-key mc/keymap (kbd "M-v") 'mc/cycle-backward)



reply via email to

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