mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2026-05-10 09:28:18 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d17c89e418 | |||
| 65c0c0c6fe | |||
| ec4781394c | |||
| ad79ad8b52 | |||
| 18d858f0de | |||
| 68dfa461f1 | |||
| a86daa79ce | |||
| 8dfe725c4f | |||
| d8c5227443 | |||
| 9f91a0455d | |||
| bf4b0c669b | |||
| 45ed43e1f8 | |||
| af66635a05 | |||
| 61388fedef | |||
| 49027c6717 | |||
| 5e879f9b5c | |||
| 23459589eb | |||
| e28090d635 | |||
| be7905d9e0 | |||
| a37403178f | |||
| 45c6cd0be4 | |||
| 186cb3b63f | |||
| c94eca57ae | |||
| 725369c445 | |||
| e8d734452e | |||
| 398cc9e466 | |||
| 2186e1b6e5 |
@@ -1,3 +1,4 @@
|
|||||||
|
(source gnu)
|
||||||
(source melpa)
|
(source melpa)
|
||||||
|
|
||||||
(package-file "multiple-cursors.el")
|
(package-file "multiple-cursors.el")
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ You can [watch an intro to multiple-cursors at Emacs Rocks](http://emacsrocks.co
|
|||||||
- `mc/mark-all-like-this-in-defun`: Marks all parts of the current defun that matches the current region.
|
- `mc/mark-all-like-this-in-defun`: Marks all parts of the current defun that matches the current region.
|
||||||
- `mc/mark-all-words-like-this-in-defun`: Like `mc/mark-all-like-this-in-defun` but only for whole words.
|
- `mc/mark-all-words-like-this-in-defun`: Like `mc/mark-all-like-this-in-defun` but only for whole words.
|
||||||
- `mc/mark-all-symbols-like-this-in-defun`: Like `mc/mark-all-like-this-in-defun` but only for whole symbols.
|
- `mc/mark-all-symbols-like-this-in-defun`: Like `mc/mark-all-like-this-in-defun` but only for whole symbols.
|
||||||
- `mc/mark-all-like-this-dwim`: Tries to be smart about marking everything you want. Can be pressed multiple times.
|
- `mc/mark-all-dwim`: Tries to be smart about marking everything you want. Can be pressed multiple times.
|
||||||
|
|
||||||
### Special
|
### Special
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ the location with:
|
|||||||
## Known limitations
|
## Known limitations
|
||||||
|
|
||||||
* isearch-forward and isearch-backward aren't supported with multiple cursors.
|
* isearch-forward and isearch-backward aren't supported with multiple cursors.
|
||||||
You should feel free to add a simplified version that can work with it.
|
If you want this functionality, you can use [phi-search](https://github.com/zk-phi/phi-search).
|
||||||
* Commands run with `M-x` won't be repeated for all cursors.
|
* Commands run with `M-x` won't be repeated for all cursors.
|
||||||
* All key bindings that refer to lambdas are always run for all cursors. If you
|
* All key bindings that refer to lambdas are always run for all cursors. If you
|
||||||
need to limit it, you will have to give it a name.
|
need to limit it, you will have to give it a name.
|
||||||
@@ -170,6 +170,7 @@ Run the tests with:
|
|||||||
* [Ivan Andrus](https://github.com/gvol) added showing number of cursors in mode-line
|
* [Ivan Andrus](https://github.com/gvol) added showing number of cursors in mode-line
|
||||||
* [Fuco](https://github.com/Fuco1) added the first version of `mc/mark-all-like-this-dwim`
|
* [Fuco](https://github.com/Fuco1) added the first version of `mc/mark-all-like-this-dwim`
|
||||||
* [Zach Kost-Smith](https://github.com/smithzvk) added `mc/mark-pop`
|
* [Zach Kost-Smith](https://github.com/smithzvk) added `mc/mark-pop`
|
||||||
|
* [Maciej Katafiasz](https://github.com/mathrick) added `mc/mark-all-dwim`
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
Feature: Mark all do-what-I-mean
|
Feature: Mark all do-what-I-mean
|
||||||
|
|
||||||
Scenario: Mark symbols in defun
|
Background:
|
||||||
Given I turn on emacs-lisp-mode
|
Given I turn on emacs-lisp-mode
|
||||||
And I turn on delete-selection-mode
|
And I turn on delete-selection-mode
|
||||||
And I insert:
|
And I insert:
|
||||||
"""
|
"""
|
||||||
(defun abc (ghi) (message ghi))
|
(defun abc (ghi) (message ghi))
|
||||||
(defun def (ghi) (message some-other-ghi))
|
(defun def (ghi) (message some-other-ghi))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Mark symbols in defun
|
||||||
When I go to the end of the word "abc"
|
When I go to the end of the word "abc"
|
||||||
And I press "M-f"
|
And I press "M-f"
|
||||||
And I press "M-$"
|
And I press "M-$"
|
||||||
@@ -17,15 +20,17 @@ Feature: Mark all do-what-I-mean
|
|||||||
(defun abc (hmm) (message hmm))
|
(defun abc (hmm) (message hmm))
|
||||||
(defun def (ghi) (message some-other-ghi))
|
(defun def (ghi) (message some-other-ghi))
|
||||||
"""
|
"""
|
||||||
|
When I press "C-g"
|
||||||
|
And I go to the front of the word "hmm"
|
||||||
|
And I press "C-$"
|
||||||
|
And I type "foo"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
(defun abc (foo) (message foo))
|
||||||
|
(defun def (ghi) (message some-other-ghi))
|
||||||
|
"""
|
||||||
|
|
||||||
Scenario: Mark all symbols by pressing twice
|
Scenario: Mark all symbols by pressing twice
|
||||||
Given I turn on emacs-lisp-mode
|
|
||||||
And I turn on delete-selection-mode
|
|
||||||
And I insert:
|
|
||||||
"""
|
|
||||||
(defun abc (ghi) (message ghi))
|
|
||||||
(defun def (ghi) (message ghi))
|
|
||||||
"""
|
|
||||||
When I go to the end of the word "abc"
|
When I go to the end of the word "abc"
|
||||||
And I press "M-f"
|
And I press "M-f"
|
||||||
And I press "M-$"
|
And I press "M-$"
|
||||||
@@ -34,5 +39,52 @@ Feature: Mark all do-what-I-mean
|
|||||||
Then I should see:
|
Then I should see:
|
||||||
"""
|
"""
|
||||||
(defun abc (hmm) (message hmm))
|
(defun abc (hmm) (message hmm))
|
||||||
(defun def (hmm) (message hmm))
|
(defun def (hmm) (message some-other-hmm))
|
||||||
|
"""
|
||||||
|
When I press "C-g"
|
||||||
|
And I press "M->"
|
||||||
|
And I insert:
|
||||||
|
"""
|
||||||
|
(defun def (hmm-hmm) (message hmm))
|
||||||
|
"""
|
||||||
|
And I go to the front of the word "hmm"
|
||||||
|
And I press "C-$"
|
||||||
|
And I press "C-$"
|
||||||
|
And I type "humm"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
(defun abc (humm) (message humm))
|
||||||
|
(defun def (humm) (message some-other-humm))
|
||||||
|
(defun def (humm-humm) (message humm))
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Mark dwim from selection
|
||||||
|
When I press "M-<"
|
||||||
|
And I press "S-M->"
|
||||||
|
And I press "C-$ ghi RET"
|
||||||
|
And I type "xyz"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
(defun abc (xyz) (message xyz))
|
||||||
|
(defun def (xyz) (message some-other-xyz))
|
||||||
|
"""
|
||||||
|
When I press "C-g"
|
||||||
|
And I go to the front of the word "xyz"
|
||||||
|
And I press "C-M-SPC"
|
||||||
|
And I press "C-$"
|
||||||
|
And I type "foo"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
(defun abc (foo) (message foo))
|
||||||
|
(defun def (xyz) (message some-other-xyz))
|
||||||
|
"""
|
||||||
|
When I press "C-g"
|
||||||
|
And I press "M-<"
|
||||||
|
And I press "S-M->"
|
||||||
|
And I press "C-u C-$"
|
||||||
|
And I type ";;"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
;;(defun abc (foo) (message foo))
|
||||||
|
;;(defun def (xyz) (message some-other-xyz))
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
|
(global-set-key (kbd "C-<") '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-like-this-dwim)
|
(global-set-key (kbd "M-$") 'mc/mark-all-like-this-dwim)
|
||||||
|
(global-set-key (kbd "C-$") 'mc/mark-all-dwim)
|
||||||
(global-set-key (kbd "M-#") 'mc/mark-all-in-region)
|
(global-set-key (kbd "M-#") 'mc/mark-all-in-region)
|
||||||
(global-set-key (kbd "H-0") 'mc/insert-numbers)
|
(global-set-key (kbd "H-0") 'mc/insert-numbers)
|
||||||
(global-set-key (kbd "H-1") 'mc/reverse-regions)
|
(global-set-key (kbd "H-1") 'mc/reverse-regions)
|
||||||
|
|||||||
+38
-14
@@ -173,9 +173,9 @@ With zero ARG, skip the last one and mark next."
|
|||||||
(dotimes (i num-lines)
|
(dotimes (i num-lines)
|
||||||
(mc/create-fake-cursor-at-point)
|
(mc/create-fake-cursor-at-point)
|
||||||
(ecase direction
|
(ecase direction
|
||||||
(forwards (loop do (next-line 1 nil)
|
(forwards (loop do (next-logical-line 1 nil)
|
||||||
while (mc/all-fake-cursors (point) (1+ (point)))))
|
while (mc/all-fake-cursors (point) (1+ (point)))))
|
||||||
(backwards (loop do (previous-line 1 nil)
|
(backwards (loop do (previous-logical-line 1 nil)
|
||||||
while (mc/all-fake-cursors (point) (1+ (point))))))))
|
while (mc/all-fake-cursors (point) (1+ (point))))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@@ -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
|
||||||
@@ -416,6 +419,27 @@ With prefix, it behaves the same as original `mc/mark-all-like-this'"
|
|||||||
(when (<= (mc/num-cursors) before)
|
(when (<= (mc/num-cursors) before)
|
||||||
(mc/mark-all-like-this))))))
|
(mc/mark-all-like-this))))))
|
||||||
|
|
||||||
|
(defun mc/mark-all-dwim (arg)
|
||||||
|
"Tries even harder to guess what you want to mark all of.
|
||||||
|
|
||||||
|
If the region is active and spans multiple lines, it will behave
|
||||||
|
as if `mc/mark-all-in-region'. With the prefix ARG, it will call
|
||||||
|
`mc/edit-lines' instead.
|
||||||
|
|
||||||
|
If the region is inactive or on a single line, it will behave like
|
||||||
|
`mc/mark-all-like-this-dwim'."
|
||||||
|
(interactive "P")
|
||||||
|
(if (and (use-region-p)
|
||||||
|
(not (> (mc/num-cursors) 1))
|
||||||
|
(not (= (line-number-at-pos (region-beginning))
|
||||||
|
(line-number-at-pos (region-end)))))
|
||||||
|
(if arg
|
||||||
|
(call-interactively 'mc/edit-lines)
|
||||||
|
(call-interactively 'mc/mark-all-in-region))
|
||||||
|
(progn
|
||||||
|
(setq this-command 'mc/mark-all-like-this-dwim)
|
||||||
|
(mc/mark-all-like-this-dwim arg))))
|
||||||
|
|
||||||
(defun mc--in-defun ()
|
(defun mc--in-defun ()
|
||||||
(bounds-of-thing-at-point 'defun))
|
(bounds-of-thing-at-point 'defun))
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun mc/mark-pop ()
|
(defun mc/mark-pop ()
|
||||||
"Add one cursor to each line of the active region.
|
"Add a cursor at the current point, pop off mark ring and jump
|
||||||
Starts from mark and moves in straight down or up towards the
|
to the popped mark."
|
||||||
line point is on."
|
|
||||||
(interactive)
|
(interactive)
|
||||||
;; If the mark happens to be at the current point, just pop that one off.
|
;; If the mark happens to be at the current point, just pop that one off.
|
||||||
(while (eql (mark) (point))
|
(while (eql (mark) (point))
|
||||||
|
|||||||
@@ -306,8 +306,8 @@ been remapped. And certain modes (cua comes to mind) will change their
|
|||||||
remapping based on state. So a command that changes the state will afterwards
|
remapping based on state. So a command that changes the state will afterwards
|
||||||
not be recognized through the command-remapping lookup."
|
not be recognized through the command-remapping lookup."
|
||||||
(unless mc--executing-command-for-fake-cursor
|
(unless mc--executing-command-for-fake-cursor
|
||||||
(let (cmd (or (command-remapping this-original-command)
|
(let ((cmd (or (command-remapping this-original-command)
|
||||||
this-original-command))
|
this-original-command)))
|
||||||
(setq mc--this-command (and (not (eq cmd 'god-mode-self-insert))
|
(setq mc--this-command (and (not (eq cmd 'god-mode-self-insert))
|
||||||
cmd)))))
|
cmd)))))
|
||||||
|
|
||||||
@@ -573,6 +573,7 @@ for running commands with multiple cursors.")
|
|||||||
mc/mark-all-words-like-this-in-defun
|
mc/mark-all-words-like-this-in-defun
|
||||||
mc/mark-all-symbols-like-this-in-defun
|
mc/mark-all-symbols-like-this-in-defun
|
||||||
mc/mark-all-like-this-dwim
|
mc/mark-all-like-this-dwim
|
||||||
|
mc/mark-all-dwim
|
||||||
mc/mark-sgml-tag-pair
|
mc/mark-sgml-tag-pair
|
||||||
mc/insert-numbers
|
mc/insert-numbers
|
||||||
mc/sort-regions
|
mc/sort-regions
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
(define-package "multiple-cursors" "1.2.1"
|
(define-package "multiple-cursors" "1.3.0"
|
||||||
"Multiple cursors for Emacs.")
|
"Multiple cursors for Emacs.")
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
cask exec ecukes "$@"
|
cask exec ecukes "$@" --no-win
|
||||||
|
|||||||
Reference in New Issue
Block a user