Function: mc/mark-all-in-region-regexp

mc/mark-all-in-region-regexp is an interactive and natively compiled function defined in mc-mark-more.el.

Signature

(mc/mark-all-in-region-regexp BEG END)

Documentation

Find and mark all the parts in the region matching the given regexp.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/5q7a78ihkz25lf4xmxaa9m7b2ym63m36-emacs-packages-deps/share/emacs/site-lisp/elpa/multiple-cursors-20260419.931/mc-mark-more.el
;;;###autoload
(defun mc/mark-all-in-region-regexp (beg end)
  "Find and mark all the parts in the region matching the given regexp."
  (interactive "r")
  (let ((search (read-regexp "Mark regexp in region: "))
        (case-fold-search nil))
    (if (string= search "")
        (message "Mark aborted")
      (progn
        (mc/remove-fake-cursors)
        (goto-char beg)
        (let ((lastmatch))
          (while (and (< (point) end) ; can happen because of (forward-char)
                      (search-forward-regexp search end t))
            (push-mark (match-beginning 0))
            (mc/create-fake-cursor-at-point)
            (setq lastmatch (point))
            (when (= (point) (match-beginning 0))
              (forward-char)))
          (unless lastmatch
            (error "Search failed for %S" search)))
        (goto-char (match-end 0))
        (if (< (mc/num-cursors) 3)
            (mc/disable-multiple-cursors-mode)
          (mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
          (multiple-cursors-mode 1))))))