mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 13:03:03 +00:00
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.
This commit is contained in:
parent
a0f771f3e4
commit
fcbb7a4df9
@ -54,23 +54,31 @@
|
|||||||
(setq prev cursor))))
|
(setq prev cursor))))
|
||||||
prev))
|
prev))
|
||||||
|
|
||||||
(defun mc/cycle-forward ()
|
(defun mc/cycle-forward (&optional error-if-no-next-cursor)
|
||||||
(interactive)
|
(interactive (list prefix-arg))
|
||||||
(let ((next-cursor (mc/next-cursor-after-point)))
|
(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"))
|
(error "We're already at the last cursor"))
|
||||||
(mc/create-fake-cursor-at-point)
|
(t
|
||||||
(mc/pop-state-from-overlay next-cursor)
|
(mc/cycle-backward t)))))
|
||||||
(recenter)))
|
|
||||||
|
|
||||||
(defun mc/cycle-backward ()
|
(defun mc/cycle-backward (&optional error-if-no-previous-cursor)
|
||||||
(interactive)
|
(interactive (list prefix-arg))
|
||||||
(let ((prev-cursor (mc/prev-cursor-before-point)))
|
(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"))
|
(error "We're already at the first cursor"))
|
||||||
(mc/create-fake-cursor-at-point)
|
(t
|
||||||
(mc/pop-state-from-overlay prev-cursor)
|
(mc/cycle-forward t)))))
|
||||||
(recenter)))
|
|
||||||
|
|
||||||
(define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)
|
(define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)
|
||||||
(define-key mc/keymap (kbd "M-v") 'mc/cycle-backward)
|
(define-key mc/keymap (kbd "M-v") 'mc/cycle-backward)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user