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

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

[nongnu] elpa/multiple-cursors 45c6cd0 256/434: Add mc/mark-all-dwim


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 45c6cd0 256/434: Add mc/mark-all-dwim
Date: Sat, 7 Aug 2021 09:20:37 -0400 (EDT)

branch: elpa/multiple-cursors
commit 45c6cd0be44039f3c35dc0e37952716962c3e430
Author: Maciej Katafiasz <mathrick@gmail.com>
Commit: Maciej Katafiasz <mathrick@gmail.com>

    Add mc/mark-all-dwim
---
 mc-mark-more.el          | 16 ++++++++++++++++
 multiple-cursors-core.el |  1 +
 2 files changed, 17 insertions(+)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index 7e240a1..26bbe6f 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -416,6 +416,22 @@ With prefix, it behaves the same as original 
`mc/mark-all-like-this'"
         (when (<= (mc/num-cursors) before)
           (mc/mark-all-like-this))))))
 
+(defun mc/mark-all-dwim (arg)
+  "Tries even harder to guess what you want to mark all of.
+
+If the region is active and spans multiple lines, it will behave
+as if `mc/mark-all-in-region'. Otherwise, it will delegate to
+`mc/mark-all-like-this-dwim' or `mc/mark-all-like-this' (if the
+prefix ARG is present)"
+  (interactive "P")
+  (if (and (use-region-p)
+           (not (= (line-number-at-pos (region-beginning))
+                   (line-number-at-pos (region-end)))))
+      (call-interactively 'mc/mark-all-in-region)
+    (progn
+      (setq this-command 'mc/mark-all-like-this-dwim)
+      (mc/mark-all-like-this-dwim arg))))
+
 (defun mc--in-defun ()
   (bounds-of-thing-at-point 'defun))
 
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index d073090..4b30cf9 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -573,6 +573,7 @@ for running commands with multiple cursors.")
                                      mc/mark-all-words-like-this-in-defun
                                      mc/mark-all-symbols-like-this-in-defun
                                      mc/mark-all-like-this-dwim
+                                     mc/mark-all-dwim
                                      mc/mark-sgml-tag-pair
                                      mc/insert-numbers
                                      mc/sort-regions



reply via email to

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