[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors cc45842 241/434: Improved mc/mark-more-li
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors cc45842 241/434: Improved mc/mark-more-like-this-extended |
Date: |
Sat, 7 Aug 2021 09:20:34 -0400 (EDT) |
branch: elpa/multiple-cursors
commit cc45842384824ffb8afd1a314ad432b05a082144
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Improved mc/mark-more-like-this-extended
- support for terminal
- more instructive message
- keymap that can be rebound
Fixes #84
---
README.md | 8 ++++
mc-mark-more.el | 119 +++++++++++++++++++++++++++++++++++---------------------
2 files changed, 83 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index 04ef59e..3437f23 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,14 @@ You can [watch an intro to multiple-cursors at Emacs
Rocks](http://emacsrocks.co
- `mc/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking.
See tips-section.
- `mc/pop-mark`: Set a cursor at the current point and move to the next
(different) position on the mark stack. This allows for fine grained control
over the placement of cursors.
+### Juggle around with the current cursors
+
+ - `mc/unmark-next-like-this`: Remove the cursor furthest down in the buffer.
+ - `mc/unmark-previous-like-this`: Remove the cursor furthest up in the buffer.
+ - `mc/skip-to-next-like-this`: Remove the cursor furthest down, marking the
next occurance down.
+ - `mc/skip-to-previous-like-this`: Remove the cursor furthest up, marking the
next occurance up.
+ - `mc/mark-next-like-this-extended`: Temporarily bind the arrow keys to
mark/unmark/skip cursors.
+
### Mark many occurrences
- `mc/edit-lines`: Adds one cursor to each line in the current region.
diff --git a/mc-mark-more.el b/mc-mark-more.el
index ac669fc..d641673 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -191,18 +191,30 @@ With zero ARG, skip the last one and mark next."
(mc/maybe-multiple-cursors-mode))
;;;###autoload
-(defun mc/unmark-next-like-this (arg)
+(defun mc/unmark-next-like-this ()
"Deselect next part of the buffer matching the currently active region."
(interactive)
(mc/mark-next-like-this -1))
;;;###autoload
-(defun mc/unmark-previous-like-this (arg)
+(defun mc/unmark-previous-like-this ()
"Deselect prev part of the buffer matching the currently active region."
(interactive)
(mc/mark-previous-like-this -1))
;;;###autoload
+(defun mc/skip-to-next-like-this ()
+ "Skip the current one and select the next part of the buffer matching the
currently active region."
+ (interactive)
+ (mc/mark-next-like-this 0))
+
+;;;###autoload
+(defun mc/skip-to-previous-like-this ()
+ "Skip the current one and select the prev part of the buffer matching the
currently active region."
+ (interactive)
+ (mc/mark-previous-like-this 0))
+
+;;;###autoload
(defun mc/mark-all-like-this ()
"Find and mark all the parts of the buffer matching the currently active
region"
(interactive)
@@ -272,49 +284,68 @@ With zero ARG, skip the last one and mark next."
;;;###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."
+The adjustments work like this:
+
+ <up> Mark previous like this and set direction to 'up
+ <down> Mark next like this and set direction to 'down
+
+If direction is 'up:
+
+ <left> Skip past the cursor furthest up
+ <right> Remove the cursor furthest up
+
+If direction is 'down:
+
+ <left> Remove the cursor furthest down
+ <right> Skip past the cursor furthest down
+
+The bindings for these commands can be changed. See
`mc/mark-more-like-this-extended-keymap'."
(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)))
+ (mc/mmlte--down)
+ (set-temporary-overlay-map mc/mark-more-like-this-extended-keymap t))
+
+(defvar mc/mark-more-like-this-extended-direction nil
+ "When using mc/mark-more-like-this-extended are we working on the next or
previous cursors?")
+
+(make-variable-buffer-local 'mc/mark-more-like-this-extended)
+
+(defun mc/mmlte--message ()
+ (if (eq mc/mark-more-like-this-extended-direction 'up)
+ (message "<up> to mark previous, <left> to skip, <right> to remove,
<down> to mark next")
+ (message "<down> to mark next, <right> to skip, <left> to remove, <up> to
mark previous")))
+
+(defun mc/mmlte--up ()
+ (interactive)
+ (mc/mark-previous-like-this 1)
+ (setq mc/mark-more-like-this-extended-direction 'up)
+ (mc/mmlte--message))
+
+(defun mc/mmlte--down ()
+ (interactive)
+ (mc/mark-next-like-this 1)
+ (setq mc/mark-more-like-this-extended-direction 'down)
+ (mc/mmlte--message))
+
+(defun mc/mmlte--left ()
+ (interactive)
+ (if (eq mc/mark-more-like-this-extended-direction 'down)
+ (mc/unmark-next-like-this)
+ (mc/skip-to-previous-like-this))
+ (mc/mmlte--message))
+
+(defun mc/mmlte--right ()
+ (interactive)
+ (if (eq mc/mark-more-like-this-extended-direction 'up)
+ (mc/unmark-previous-like-this)
+ (mc/skip-to-next-like-this))
+ (mc/mmlte--message))
+
+(defvar mc/mark-more-like-this-extended-keymap (make-sparse-keymap))
+
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<up>") 'mc/mmlte--up)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<down>")
'mc/mmlte--down)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<left>")
'mc/mmlte--left)
+(define-key mc/mark-more-like-this-extended-keymap (kbd "<right>")
'mc/mmlte--right)
(defvar mc--restrict-mark-all-to-symbols nil)
- [nongnu] elpa/multiple-cursors 8e59a8a 390/434: Merge pull request #262 from AndreaOrru/master, (continued)
- [nongnu] elpa/multiple-cursors 8e59a8a 390/434: Merge pull request #262 from AndreaOrru/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fa91dfb 397/434: Don't display message while loading mc/list-file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6f183a1 405/434: Merge pull request #304 from angadgill92/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 18f992b 403/434: Merge pull request #290 from raxod502/feat/silent-load, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 75dd6bf 413/434: Merge pull request #327 from notetiene/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9c49874 415/434: Merge pull request #333 from drrlvn/patch-1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6a7c3c0 418/434: Fix whitespace, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b39e963 425/434: Faster line-number-at-pos calculation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cb7a145 210/434: Release 1.2.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 25dd14d 219/434: Add more scenarios for mark-all-*-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cc45842 241/434: Improved mc/mark-more-like-this-extended,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 4535033 235/434: Added a new function mc/mark-pop that sets cursors by popping marks off the mark stack., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4748386 238/434: Make mc/mark-pop only run once per invocation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors be7905d 258/434: Update README to note that there is a mode allowing search in multiple-cursors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a86daa7 270/434: Guard with 'if' rather than defun*/return-from, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 18d858f 272/434: Fall straight through in 'mc/mark-all-dwim' if multiple cursors are already active, as that means we can't sensibly edit lines or mark all in region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2b536cb 283/434: Added mc/edit-lines-empty-lines, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 75ece68 288/434: Merge pull request #118 from aspiers/fix-compile-warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9f4502b 304/434: Change file load timing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e94567c 303/434: Add installation instructions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 98f2346 305/434: Merge pull request #152 from ShingoFukuyama/master, ELPA Syncer, 2021/08/07