[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 641eb68 212/434: Can use mc/reverse-regio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 641eb68 212/434: Can use mc/reverse-regions w/o region or cursors |
Date: |
Sat, 7 Aug 2021 09:20:28 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 641eb680ca09be80205bd8501bbf3499ad76481b
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Can use mc/reverse-regions w/o region or cursors
- will flip sexp at point with the one below it
---
README.md | 3 +++
mc-edit-lines.el | 6 ++----
mc-separate-operations.el | 19 ++++++++++++-------
multiple-cursors-core.el | 5 +++++
multiple-cursors.el | 21 ++++++++++++---------
5 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 968ec56..2c2f24f 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,9 @@ You can [watch an intro to multiple-cursors at Emacs
Rocks](http://emacsrocks.co
from the kill-ring of main cursor. To yank from the kill-rings of
every cursor use yank-rectangle, normally found at C-x r y.
+- You can use `mc/reverse-regions` with nothing selected and just one cursor.
+ It will then flip the sexp at point and the one below it.
+
- If you would like to keep the global bindings clean, and get custom
keybindings
when the region is active, you can try
[region-bindings-mode](https://github.com/fgallina/region-bindings-mode).
diff --git a/mc-edit-lines.el b/mc-edit-lines.el
index d185a2c..d9e20cb 100644
--- a/mc-edit-lines.el
+++ b/mc-edit-lines.el
@@ -57,16 +57,14 @@ line point is on."
"Add one cursor to the end of each line in the active region."
(interactive)
(mc/edit-lines)
- (mc/execute-command-for-all-fake-cursors 'end-of-line)
- (end-of-line))
+ (mc/execute-command-for-all-cursors 'end-of-line))
;;;###autoload
(defun mc/edit-beginnings-of-lines ()
"Add one cursor to the beginning of each line in the active region."
(interactive)
(mc/edit-lines)
- (mc/execute-command-for-all-fake-cursors 'beginning-of-line)
- (beginning-of-line))
+ (mc/execute-command-for-all-cursors 'beginning-of-line))
(provide 'mc-edit-lines)
diff --git a/mc-separate-operations.el b/mc-separate-operations.el
index 17d37c0..abbfaee 100644
--- a/mc-separate-operations.el
+++ b/mc-separate-operations.el
@@ -58,7 +58,7 @@
(defun mc--replace-region-strings-1 ()
(interactive)
(delete-region (region-beginning) (region-end))
- (insert (car mc--strings-to-replace))
+ (save-excursion (insert (car mc--strings-to-replace)))
(setq mc--strings-to-replace (cdr mc--strings-to-replace)))
(defun mc--replace-region-strings ()
@@ -68,18 +68,23 @@
;;;###autoload
(defun mc/reverse-regions ()
(interactive)
- (if (not (use-region-p))
- (message "Mark regions to reverse first.")
+ (if (not multiple-cursors-mode)
+ (progn
+ (mc/mark-next-lines 1)
+ (mc/reverse-regions)
+ (multiple-cursors-mode 0))
+ (unless (use-region-p)
+ (mc/execute-command-for-all-cursors 'mark-sexp))
(setq mc--strings-to-replace (nreverse (mc--ordered-region-strings)))
(mc--replace-region-strings)))
;;;###autoload
(defun mc/sort-regions ()
(interactive)
- (if (not (use-region-p))
- (message "Mark regions to sort first.")
- (setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
- (mc--replace-region-strings)))
+ (unless (use-region-p)
+ (mc/execute-command-for-all-cursors 'mark-sexp))
+ (setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
+ (mc--replace-region-strings))
(provide 'mc-separate-operations)
;;; mc-separate-operations.el ends here
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index fc358cb..4494201 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -223,6 +223,11 @@ cursor with updated info."
(mc/execute-command-for-fake-cursor cmd cursor)))))
(mc--reset-read-prompts))
+(defun mc/execute-command-for-all-cursors (cmd)
+ "Calls CMD interactively for the real cursor and all fakes."
+ (call-interactively cmd)
+ (mc/execute-command-for-all-fake-cursors cmd))
+
;; Intercept some reading commands so you won't have to
;; answer them for every single cursor
diff --git a/multiple-cursors.el b/multiple-cursors.el
index 7ada1cc..7ea861a 100644
--- a/multiple-cursors.el
+++ b/multiple-cursors.el
@@ -91,24 +91,27 @@
;; - To get out of multiple-cursors-mode, press `<return>` or `C-g`. The
latter will
;; first disable multiple regions before disabling multiple cursors. If you
want to
;; insert a newline in multiple-cursors-mode, use `C-j`.
-
+;;
;; - Sometimes you end up with cursors outside of your view. You can
;; scroll the screen to center on each cursor with `C-v` and `M-v`.
-
+;;
;; - Try pressing `mc/mark-next-like-this` with no region selected. It will
just add a cursor
;; on the next line.
-
+;;
;; - Try pressing `mc/mark-all-like-this-dwim` on a tagname in html-mode.
-
+;;
;; - Notice that the number of cursors active can be seen in the modeline.
-
+;;
;; - If you get out of multiple-cursors-mode and yank - it will yank only
-;; from the kill-ring of main cursor. To yank from the kill-rings of
-;; every cursor use yank-rectangle, normally found at C-x r y.
-
+;; from the kill-ring of main cursor. To yank from the kill-rings of
+;; every cursor use yank-rectangle, normally found at C-x r y.
+;;
+;; - You can use `mc/reverse-regions` with nothing selected and just one
cursor.
+;; It will then flip the sexp at point and the one below it.
+;;
;; - If you would like to keep the global bindings clean, and get custom
keybindings
;; when the region is active, you can try
[region-bindings-mode](https://github.com/fgallina/region-bindings-mode).
-
+;;
;; BTW, I highly recommend adding `mc/mark-next-like-this` to a key binding
that's
;; right next to the key for `er/expand-region`.
- [nongnu] elpa/multiple-cursors d534132 122/434: Remove todo.org - use issues instead, (continued)
- [nongnu] elpa/multiple-cursors d534132 122/434: Remove todo.org - use issues instead, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors f7d393d 128/434: Don't use next-line and previous-line in non-interactive ways., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fc59b63 131/434: Fix typo, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d98b85b 138/434: Bump to 1.1.2, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6e9ea1a 149/434: Merge pull request #20 from tkf/diff-friendly-save-lists, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6d4979d 144/434: Bump to 1.1.3, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b3ca408 171/434: Have to require 'cl for now, because of count-if., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a6984a1 203/434: Merge pull request #53 from oneself/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a37e02b 177/434: Add new mc-commands to default run-once list., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6339657 192/434: Fix byte-compilation warnings, and avoid unnecessary use of "eval", ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 641eb68 212/434: Can use mc/reverse-regions w/o region or cursors,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 0ee76bf 214/434: Add mc/add-cursor-on-click, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 16589a5 224/434: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 5c60757 216/434: export ECUKES_EMACS in run-travis-ci.sh, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6467fe2 277/434: Add mc/mark-all-dwim to autoloads, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c69be0e 282/434: Travis CI: Update location of cask install, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4da58ea 302/434: Merge pull request #146 from bling/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors f0dcd06 323/434: Merge pull request #175 from lexa/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2d6ffce 330/434: Support unmarking with no region. Change mc/mark-lines to preserve point., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 36b7025 348/434: Add alternative to mc/mark-next-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a393384 353/434: Merge pull request #227 from jtamagnan/insert_letters, ELPA Syncer, 2021/08/07