[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 092b0a1 074/434: Cycle through cursors wi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 092b0a1 074/434: Cycle through cursors with C-v and M-v |
Date: |
Sat, 7 Aug 2021 09:19:58 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 092b0a1017cc00947825fd52451c38f146313a57
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Cycle through cursors with C-v and M-v
---
mc-cycle-cursors.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
multiple-cursors.el | 1 +
2 files changed, 49 insertions(+)
diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el
new file mode 100644
index 0000000..f89a9d0
--- /dev/null
+++ b/mc-cycle-cursors.el
@@ -0,0 +1,48 @@
+(eval-when-compile (require 'cl))
+
+(defun mc/next-cursor-after-point ()
+ (let ((pos (point))
+ (next-pos (point-max))
+ next)
+ (mc/for-each-fake-cursor
+ (let ((cursor-pos (overlay-get cursor 'point)))
+ (when (and (< pos cursor-pos)
+ (< cursor-pos next-pos))
+ (setq next-pos cursor-pos)
+ (setq next cursor))))
+ next))
+
+(defun mc/prev-cursor-before-point ()
+ (let ((pos (point))
+ (prev-pos (point-min))
+ prev)
+ (mc/for-each-fake-cursor
+ (let ((cursor-pos (overlay-get cursor 'point)))
+ (when (and (> pos cursor-pos)
+ (> cursor-pos prev-pos))
+ (setq prev-pos cursor-pos)
+ (setq prev cursor))))
+ prev))
+
+(defun mc/cycle-forward ()
+ (interactive)
+ (let ((next-cursor (mc/next-cursor-after-point)))
+ (unless next-cursor
+ (error "We're already at the last cursor"))
+ (mc/create-fake-cursor-at-point)
+ (mc/pop-state-from-overlay next-cursor)
+ (recenter)))
+
+(defun mc/cycle-backward ()
+ (interactive)
+ (let ((prev-cursor (mc/prev-cursor-before-point)))
+ (unless prev-cursor
+ (error "We're already at the first cursor"))
+ (mc/create-fake-cursor-at-point)
+ (mc/pop-state-from-overlay prev-cursor)
+ (recenter)))
+
+(define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)
+(define-key mc/keymap (kbd "M-v") 'mc/cycle-backward)
+
+(provide 'mc-cycle-cursors)
diff --git a/multiple-cursors.el b/multiple-cursors.el
index 505dadf..3ceeaef 100644
--- a/multiple-cursors.el
+++ b/multiple-cursors.el
@@ -74,6 +74,7 @@
(require 'multiple-cursors-core)
(require 'mc-edit-lines)
+(require 'mc-cycle-cursors)
(require 'mc-mark-multiple-integration)
(require 'rectangular-region-mode)
- [nongnu] elpa/multiple-cursors 9875982 038/434: Add smart-forward to whitelist, (continued)
- [nongnu] elpa/multiple-cursors 9875982 038/434: Add smart-forward to whitelist, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 87169c8 040/434: Clean up multiple-cursors-core, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors efd79f3 043/434: Add undo to list of known run-only-once commands., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b60cbc3 044/434: Add support for yank-pop, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 1db643c 048/434: Add support for modes that remap commands., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 37ddaf2 053/434: Set this-command for each cursor., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d7be50e 041/434: rectangular-region-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 45488df 052/434: yank-pop is supported, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6f9911f 054/434: Add more explanatory prose., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 466d036 063/434: Prompt for inclusion in white/black-lists when met with an unknown command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 092b0a1 074/434: Cycle through cursors with C-v and M-v,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 0512561 076/434: Skip lines in rectangular-region-mode that are too short for the rectangle., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 84ef509 072/434: Save users own white/black lists in .mc-lists.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 15e88c6 071/434: Move more mode-specific cmds into personal lists., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 0bfd611 068/434: More consistent naming., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors ca0e0ae 084/434: Tests for rectangular-region-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a4c4714 081/434: Remove multiple cursors when reverting buffer., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 36b262c 086/434: Added mc-version of mark-next-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 491b206 103/434: Use forward-line instead of next/previous-line in lisp code., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b1ea7f2 095/434: Add licences to all el-files., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors f6403ea 112/434: Fix assertion, ELPA Syncer, 2021/08/07