Abort immediately when empty search pattern is passed to 'mc/mark-all-in-region'

This commit is contained in:
Maciej Katafiasz 2013-09-05 23:53:59 +02:00
parent 5e879f9b5c
commit 8dfe725c4f

View File

@ -263,15 +263,16 @@ With zero ARG, skip the last one and mark next."
(mc/mark-all-like-this))) (mc/mark-all-like-this)))
;;;###autoload ;;;###autoload
(defun mc/mark-all-in-region (beg end) (defun* mc/mark-all-in-region (beg end)
"Find and mark all the parts in the region matching the given search" "Find and mark all the parts in the region matching the given search"
(interactive "r") (interactive "r")
(let ((search (read-from-minibuffer "Mark all in region: ")) (let ((search (read-from-minibuffer "Mark all in region: "))
(case-fold-search nil)) (case-fold-search nil))
(when (string= search "")
(return-from mc/mark-all-in-region nil))
(mc/remove-fake-cursors) (mc/remove-fake-cursors)
(goto-char beg) (goto-char beg)
(while (and (not (string= search "")) (while (search-forward search end t)
(search-forward search end t))
(push-mark (match-beginning 0)) (push-mark (match-beginning 0))
(mc/create-fake-cursor-at-point)) (mc/create-fake-cursor-at-point))
(let ((first (mc/furthest-cursor-before-point))) (let ((first (mc/furthest-cursor-before-point)))