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