Guard with 'if' rather than defun*/return-from

This commit is contained in:
Maciej Katafiasz 2013-09-06 09:33:37 +02:00
parent 8dfe725c4f
commit a86daa79ce

View File

@ -263,25 +263,26 @@ 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 "") (if (string= search "")
(return-from mc/mark-all-in-region nil)) (message "Mark aborted")
(mc/remove-fake-cursors) (progn
(goto-char beg) (mc/remove-fake-cursors)
(while (search-forward search end t) (goto-char beg)
(push-mark (match-beginning 0)) (while (search-forward search end t)
(mc/create-fake-cursor-at-point)) (push-mark (match-beginning 0))
(let ((first (mc/furthest-cursor-before-point))) (mc/create-fake-cursor-at-point))
(if (not first) (let ((first (mc/furthest-cursor-before-point)))
(error "Search failed for %S" search) (if (not first)
(mc/pop-state-from-overlay first)))) (error "Search failed for %S" search)
(if (> (mc/num-cursors) 1) (mc/pop-state-from-overlay first)))
(multiple-cursors-mode 1) (if (> (mc/num-cursors) 1)
(multiple-cursors-mode 0))) (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