branch: elpa/multiple-cursors
commit 39e4eb2389b9c9aed1949b086ff9fb07fa6b78b3
Author: Magnar Sveen <[email protected]>
Commit: Magnar Sveen <[email protected]>
Added mc-version of mark-more-like-this-extended
---
mc-mark-more.el | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/mc-mark-more.el b/mc-mark-more.el
index fdffc78..0814567 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -148,6 +148,51 @@ With zero ARG, skip the last one and mark next."
(multiple-cursors-mode 1)
(multiple-cursors-mode 0)))
+;;;###autoload
+(defun mc/mark-more-like-this-extended ()
+ "Like mark-more-like-this, but then lets you adjust with arrows key.
+The actual adjustment made depends on the final component of the
+key-binding used to invoke the command, with all modifiers removed:
+
+ <up> Mark previous like this
+ <down> Mark next like this
+ <left> If last was previous, skip it
+ If last was next, remove it
+ <right> If last was next, skip it
+ If last was previous, remove it
+Then, continue to read input events and further add or move marks
+as long as the input event read (with all modifiers removed)
+is one of the above."
+ (interactive)
+ (let ((first t)
+ (ev last-command-event)
+ (cmd 'mc/mark-next-like-this)
+ (arg 1)
+ last echo-keystrokes)
+ (while cmd
+ (let ((base (event-basic-type ev)))
+ (cond ((eq base 'left)
+ (if (eq last 'mc/mark-previous-like-this)
+ (setq cmd last arg 0)
+ (setq cmd 'mc/mark-next-like-this arg -1)))
+ ((eq base 'up)
+ (setq cmd 'mc/mark-previous-like-this arg 1))
+ ((eq base 'right)
+ (if (eq last 'mc/mark-next-like-this)
+ (setq cmd last arg 0)
+ (setq cmd 'mc/mark-previous-like-this arg -1)))
+ ((eq base 'down)
+ (setq cmd 'mc/mark-next-like-this arg 1))
+ (first
+ (setq cmd 'mc/mark-next-like-this arg 1))
+ (t
+ (setq cmd nil))))
+ (when cmd
+ (ignore-errors
+ (funcall cmd arg))
+ (setq first nil last cmd)
+ (setq ev (read-event "Use arrow keys for more marks: "))))
+ (push ev unread-command-events)))
(provide 'mc-mark-more)