Added mc-version of mark-all-in-region

This commit is contained in:
Magnar Sveen 2012-07-25 19:34:45 +02:00
parent 0d89125f60
commit f42e467bf8
4 changed files with 32 additions and 3 deletions

View File

@ -85,3 +85,12 @@ Feature: Marking multiple parts of the buffer
And I select "text" And I select "text"
And I press "M-!" And I press "M-!"
Then I should have 3 cursors Then I should have 3 cursors
Scenario: Marking in region
Given I turn on delete-selection-mode
When I insert "Here's text, text and text"
And I select "text, text"
And I press "M-# text <return>"
And I type "more"
Then I should have 2 cursors
And I should see "Here's more, more and text"

View File

@ -23,6 +23,7 @@
(global-set-key (kbd "M->") 'mc/mark-next-like-this) (global-set-key (kbd "M->") 'mc/mark-next-like-this)
(global-set-key (kbd "M-<") 'mc/mark-previous-like-this) (global-set-key (kbd "M-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-!") 'mc/mark-all-like-this) (global-set-key (kbd "M-!") 'mc/mark-all-like-this)
(global-set-key (kbd "M-#") 'mc/mark-all-in-region)
(global-set-key (kbd "H-SPC") 'set-rectangular-region-anchor) (global-set-key (kbd "H-SPC") 'set-rectangular-region-anchor)
(switch-to-buffer (switch-to-buffer
(get-buffer-create "*multiple-cursors*")) (get-buffer-create "*multiple-cursors*"))

View File

@ -129,4 +129,25 @@ With zero ARG, skip the last one and mark next."
(multiple-cursors-mode 1) (multiple-cursors-mode 1)
(multiple-cursors-mode 0))) (multiple-cursors-mode 0)))
;;;###autoload
(defun mc/mark-all-in-region (beg end)
"Find and mark all the parts in the region matching the given search"
(interactive "r")
(let ((search (read-from-minibuffer "Mark all in region: "))
(case-fold-search nil))
(mc/remove-fake-cursors)
(goto-char beg)
(while (search-forward search end t)
(push-mark (match-beginning 0))
(mc/create-fake-cursor-at-point))
(let ((first (mc/furthest-cursor-before-point)))
(if (not first)
(error "Search failed for %S" search)
(mc/pop-state-from-overlay first))))
(if (> (mc/num-cursors) 1)
(multiple-cursors-mode 1)
(multiple-cursors-mode 0)))
(provide 'mc-mark-more) (provide 'mc-mark-more)

View File

@ -10,9 +10,7 @@
Possible to do C-s ... Possible to do C-s ...
Any way to make M-z just prompt for letter once? Any way to make M-z just prompt for letter once?
** TODO mark-multiple-mode ** TODO mark-multiple-mode
mark-multiple has some advantages mark-multiple has some advantages -> moving out of the marked area quits the mode
-> simpler visuals, no extra cursors (matter of taste?)
-> moving out of the marked area quits the mode
** DONE unknown command: Do for (a)ll, (o)nce or (i)gnore -> (did that work ok? (k)eep doing that or (d)on't) ** DONE unknown command: Do for (a)ll, (o)nce or (i)gnore -> (did that work ok? (k)eep doing that or (d)on't)
unknown-command ran once - what now? (o)nce is enough, repeat for (a)ll, (u)ndo - that did NOT work. unknown-command ran once - what now? (o)nce is enough, repeat for (a)ll, (u)ndo - that did NOT work.
unknown-command ran for all - did that work as expected? (y)es, (n)o unknown-command ran for all - did that work as expected? (y)es, (n)o