Merge pull request #109 from mathrick/fix-mark-all-in-region-hang

Guard against empty search pattern in 'mc/mark-all-in-region', otherwise...
This commit is contained in:
Magnar Sveen 2013-09-06 03:09:25 -07:00
commit 68dfa461f1

View File

@ -268,18 +268,21 @@ With zero ARG, skip the last one and mark next."
(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))
(mc/remove-fake-cursors) (if (string= search "")
(goto-char beg) (message "Mark aborted")
(while (search-forward search end t) (progn
(push-mark (match-beginning 0)) (mc/remove-fake-cursors)
(mc/create-fake-cursor-at-point)) (goto-char beg)
(let ((first (mc/furthest-cursor-before-point))) (while (search-forward search end t)
(if (not first) (push-mark (match-beginning 0))
(error "Search failed for %S" search) (mc/create-fake-cursor-at-point))
(mc/pop-state-from-overlay first)))) (let ((first (mc/furthest-cursor-before-point)))
(if (> (mc/num-cursors) 1) (if (not first)
(multiple-cursors-mode 1) (error "Search failed for %S" search)
(multiple-cursors-mode 0))) (mc/pop-state-from-overlay first)))
(if (> (mc/num-cursors) 1)
(multiple-cursors-mode 1)
(multiple-cursors-mode 0))))))
(when (not (fboundp 'set-temporary-overlay-map)) (when (not (fboundp 'set-temporary-overlay-map))
;; Backport this function from newer emacs versions ;; Backport this function from newer emacs versions