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

[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`.
 



reply via email to

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