mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 13:03:03 +00:00
Merge pull request #262 from AndreaOrru/master
mark-previous-like-this-word/symbol.
This commit is contained in:
commit
8e59a8a226
@ -57,6 +57,8 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
||||
- `mc/mark-next-word-like-this`: Like `mc/mark-next-like-this` but only for whole words.
|
||||
- `mc/mark-next-symbol-like-this`: Like `mc/mark-next-like-this` but only for whole symbols.
|
||||
- `mc/mark-previous-like-this`: Adds a cursor and region at the next part of the buffer backwards that matches the current region.
|
||||
- `mc/mark-previous-like-this-word`: Adds a cursor and region at the next part of the buffer backwards that matches the current region, if no region is selected it selects the word at the point.
|
||||
- `mc/mark-previous-like-this-symbol`: Adds a cursor and region at the next part of the buffer backwards that matches the current region, if no region is selected it selects the symbol at the point.
|
||||
- `mc/mark-previous-word-like-this`: Like `mc/mark-previous-like-this` but only for whole words.
|
||||
- `mc/mark-previous-symbol-like-this`: Like `mc/mark-previous-like-this` but only for whole symbols.
|
||||
- `mc/mark-more-like-this-extended`: Use arrow keys to quickly mark/skip next/previous occurances.
|
||||
|
@ -14,6 +14,14 @@ Feature: Marking multiple parts of the buffer
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Marking next like this, word
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "This text has the word text in it"
|
||||
And I go to word "text"
|
||||
And I press "C-S-c C->"
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Skipping a mark
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "Here's text, text and text"
|
||||
@ -54,6 +62,14 @@ Feature: Marking multiple parts of the buffer
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Marking prev like this, word
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "This text has the word text in it"
|
||||
And I go to last word "text"
|
||||
And I press "C-S-c C-<"
|
||||
And I type "sentence"
|
||||
Then I should see "This sentence has the word sentence in it"
|
||||
|
||||
Scenario: Skipping a prev mark
|
||||
Given I turn on delete-selection-mode
|
||||
When I insert "Here's text, text and text"
|
||||
|
@ -12,6 +12,12 @@
|
||||
(When "^I mark previous like this$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this)))
|
||||
|
||||
(When "^I mark previous like this word$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this-word)))
|
||||
|
||||
(When "^I mark previous like this symbol$"
|
||||
(lambda () (call-interactively 'mc/mark-previous-like-this-symbol)))
|
||||
|
||||
(When "^I mark all like this$"
|
||||
(lambda () (call-interactively 'mc/mark-all-like-this)))
|
||||
|
||||
@ -144,6 +150,12 @@
|
||||
(cl-assert search nil message word (espuds-buffer-contents))
|
||||
(if (string-equal "front" pos) (backward-word)))))
|
||||
|
||||
(When "^I go to last word \"\\(.+\\)\"$"
|
||||
(lambda (text)
|
||||
(goto-char (point-max))
|
||||
(let ((search (re-search-backward text nil t)))
|
||||
(cl-assert search nil "The text '%s' was not found in the current buffer." text))))
|
||||
|
||||
(When "^I select the last \"\\(.+\\)\"$"
|
||||
(lambda (text)
|
||||
(goto-char (point-max))
|
||||
|
@ -24,6 +24,8 @@
|
||||
(global-set-key (kbd "C-S-c C->") 'mc/mark-next-like-this-word)
|
||||
(global-set-key (kbd "C-S-c M->") 'mc/mark-next-like-this-symbol)
|
||||
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
|
||||
(global-set-key (kbd "C-S-c C-<") 'mc/mark-previous-like-this-word)
|
||||
(global-set-key (kbd "C-S-c M-<") 'mc/mark-previous-like-this-symbol)
|
||||
(global-set-key (kbd "M-!") 'mc/mark-all-like-this)
|
||||
(global-set-key (kbd "M-$") 'mc/mark-all-like-this-dwim)
|
||||
(global-set-key (kbd "C-$") 'mc/mark-all-dwim)
|
||||
|
@ -225,6 +225,42 @@ With zero ARG, skip the last one and mark next."
|
||||
(mc/mark-lines arg 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-like-this-word (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
If no region is active, mark the word at the point and find the previous match
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark previous."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc--select-thing-at-point 'word)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
(defun mc/mark-previous-like-this-symbol (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
If no region is active, mark the symbol at the point and find the previous match
|
||||
With negative ARG, delete the last one instead.
|
||||
With zero ARG, skip the last one and mark previous."
|
||||
(interactive "p")
|
||||
(if (< arg 0)
|
||||
(let ((cursor (mc/furthest-cursor-after-point)))
|
||||
(if cursor
|
||||
(mc/remove-fake-cursor cursor)
|
||||
(error "No cursors to be unmarked")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc--select-thing-at-point 'symbol)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)))
|
||||
(mc/maybe-multiple-cursors-mode))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/mark-previous-word-like-this (arg)
|
||||
"Find and mark the previous part of the buffer matching the currently active region
|
||||
|
@ -621,6 +621,8 @@ for running commands with multiple cursors.")
|
||||
mc/mark-next-word-like-this
|
||||
mc/mark-next-symbol-like-this
|
||||
mc/mark-previous-like-this
|
||||
mc/mark-previous-like-this-word
|
||||
mc/mark-previous-like-this-symbol
|
||||
mc/mark-previous-word-like-this
|
||||
mc/mark-previous-symbol-like-this
|
||||
mc/mark-all-like-this
|
||||
|
Loading…
x
Reference in New Issue
Block a user