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

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

[nongnu] elpa/multiple-cursors 39e4eb2 091/434: Added mc-version of mark


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 39e4eb2 091/434: Added mc-version of mark-more-like-this-extended
Date: Sat, 7 Aug 2021 09:20:02 -0400 (EDT)

branch: elpa/multiple-cursors
commit 39e4eb2389b9c9aed1949b086ff9fb07fa6b78b3
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    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)



reply via email to

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