27 Commits

Author SHA1 Message Date
Magnar Sveen d17c89e418 Release 1.3.0 2013-09-06 22:21:57 +02:00
Magnar Sveen 65c0c0c6fe Merge pull request #104 from mathrick/mark-all-dwim
Add new command, mark-all-dwim
2013-09-06 12:57:31 -07:00
Maciej Katafiasz ec4781394c Derp, multiple cursors means > 1, not > 0. 2013-09-06 19:44:31 +02:00
Maciej Katafiasz ad79ad8b52 Mention only 'mc/mark-all-dwim' in README to prevent confusing redundancy 2013-09-06 14:53:35 +02:00
Maciej Katafiasz 18d858f0de Fall straight through in 'mc/mark-all-dwim' if multiple cursors are already active, as that means we can't sensibly edit lines or mark all in region 2013-09-06 14:52:16 +02:00
Magnar Sveen 68dfa461f1 Merge pull request #109 from mathrick/fix-mark-all-in-region-hang
Guard against empty search pattern in 'mc/mark-all-in-region', otherwise...
2013-09-06 03:09:25 -07:00
Maciej Katafiasz a86daa79ce Guard with 'if' rather than defun*/return-from 2013-09-06 09:33:37 +02:00
Maciej Katafiasz 8dfe725c4f Abort immediately when empty search pattern is passed to 'mc/mark-all-in-region' 2013-09-05 23:53:59 +02:00
Magnar Sveen d8c5227443 Merge pull request #103 from mathrick/compat-24.2
Add gnu repo to Cask, which is needed for cl-lib on Emacs <24.3
2013-09-05 11:52:11 -07:00
Maciej Katafiasz 9f91a0455d Add 'mc/mark-all-dwim' to README 2013-09-05 18:51:51 +02:00
Maciej Katafiasz bf4b0c669b Refactor mark-dwim tests to share a common background 2013-09-05 18:42:16 +02:00
Maciej Katafiasz 45ed43e1f8 Test edit-lines functionality in 'mc/mark-all-dwim' 2013-09-05 18:22:12 +02:00
Maciej Katafiasz af66635a05 Make 'mc/mark-all-dwim' into 'mc/edit-lines' if prefix arg is passed 2013-09-05 18:16:39 +02:00
Maciej Katafiasz 61388fedef Add 'mark-all-dwim' tests for selection 2013-09-05 18:07:52 +02:00
Maciej Katafiasz 49027c6717 Add basic tests for 'mc/mark-all-dwim' 2013-09-05 17:51:19 +02:00
Maciej Katafiasz 5e879f9b5c Guard against empty search pattern in 'mc/mark-all-in-region', otherwise it will enter an infinite loop 2013-09-05 17:42:36 +02:00
Magnar Sveen 23459589eb Run ecukes tests in --no-win mode
Fixes #108
2013-09-05 14:00:21 +02:00
Magnar Sveen e28090d635 Merge pull request #106 from porterjamesj/patch-1
Update README to note that there is a mode allowing search in multiple-c...
2013-09-03 21:48:25 -07:00
James Porter be7905d9e0 Update README to note that there is a mode allowing search in multiple-cursors. 2013-09-03 21:17:18 -04:00
Maciej Katafiasz a37403178f Add gnu repo to Cask, which is needed for cl-lib on Emacs <24.3 2013-08-30 22:38:37 +02:00
Maciej Katafiasz 45c6cd0be4 Add mc/mark-all-dwim 2013-08-30 22:36:01 +02:00
Magnar Sveen 186cb3b63f Release 1.2.3 2013-08-24 20:39:50 +02:00
Magnar Sveen c94eca57ae Fix broken let binding 2013-08-24 20:39:50 +02:00
Magnar Sveen 725369c445 Merge pull request #97 from knu/fix-mc-mark-pop-doc
Fix the doc string of mc/mark-pop, which was not updated after a copy.
2013-08-20 23:18:36 -07:00
Akinori MUSHA e8d734452e Fix the doc string of mc/mark-pop, which was not updated after a copy. 2013-08-21 12:55:22 +09:00
Magnar Sveen 398cc9e466 Merge pull request #92 from knu/mark_by_logical_lines
mc/mark-lines: Mark by logical lines.
2013-08-15 21:10:47 -07:00
Akinori MUSHA 2186e1b6e5 mc/mark-lines: Mark by logical lines. 2013-08-01 17:00:03 +09:00
9 changed files with 118 additions and 39 deletions
+1
View File
@@ -1,3 +1,4 @@
(source gnu)
(source melpa) (source melpa)
(package-file "multiple-cursors.el") (package-file "multiple-cursors.el")
+3 -2
View File
@@ -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!
+70 -18
View File
@@ -1,31 +1,36 @@
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))
"""
When I go to the end of the word "abc"
And I press "M-f"
And I press "M-$"
And I type "hmm"
Then I should see:
"""
(defun abc (hmm) (message hmm))
(defun def (ghi) (message some-other-ghi))
""" """
Scenario: Mark symbols in defun
When I go to the end of the word "abc"
And I press "M-f"
And I press "M-$"
And I type "hmm"
Then I should see:
"""
(defun abc (hmm) (message hmm))
(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))
""" """
+1
View File
@@ -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
View File
@@ -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
View File
@@ -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))
+1
View File
@@ -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 -1
View File
@@ -1,2 +1,2 @@
(define-package "multiple-cursors" "1.2.3" (define-package "multiple-cursors" "1.3.0"
"Multiple cursors for Emacs.") "Multiple cursors for Emacs.")
+1 -1
View File
@@ -1,2 +1,2 @@
#!/bin/sh -e #!/bin/sh -e
cask exec ecukes "$@" cask exec ecukes "$@" --no-win