Add mc/mark-all-dwim

This commit is contained in:
Maciej Katafiasz 2013-08-30 22:36:01 +02:00
parent 186cb3b63f
commit 45c6cd0be4
2 changed files with 17 additions and 0 deletions

View File

@ -416,6 +416,22 @@ With prefix, it behaves the same as original `mc/mark-all-like-this'"
(when (<= (mc/num-cursors) before) (when (<= (mc/num-cursors) before)
(mc/mark-all-like-this)))))) (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 () (defun mc--in-defun ()
(bounds-of-thing-at-point 'defun)) (bounds-of-thing-at-point 'defun))

View File

@ -573,6 +573,7 @@ for running commands with multiple cursors.")
mc/mark-all-words-like-this-in-defun mc/mark-all-words-like-this-in-defun
mc/mark-all-symbols-like-this-in-defun mc/mark-all-symbols-like-this-in-defun
mc/mark-all-like-this-dwim mc/mark-all-like-this-dwim
mc/mark-all-dwim
mc/mark-sgml-tag-pair mc/mark-sgml-tag-pair
mc/insert-numbers mc/insert-numbers
mc/sort-regions mc/sort-regions