branch: elpa/multiple-cursors
commit eda9952fc029b28b8ee3f83b5b0b4f1026eac39c
Author: Magnar Sveen <[email protected]>
Commit: Magnar Sveen <[email protected]>
Finally got the tests running. :-)
---
features/mark-multiple-integration.feature | 9 ++++----
features/multiple-cursors-core.feature | 25 ++++++++++++++++++++--
.../step-definitions/multiple-cursors-steps.el | 23 ++++++++++++++------
features/support/env.el | 1 +
multiple-cursors-core.el | 7 +++---
5 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/features/mark-multiple-integration.feature
b/features/mark-multiple-integration.feature
index 4053296..80d5b16 100644
--- a/features/mark-multiple-integration.feature
+++ b/features/mark-multiple-integration.feature
@@ -17,8 +17,9 @@ Feature: Mark multiple integration
When I insert "This text contains the word text twice"
And I select "text"
And I press "C->"
- And I press "C-g"
- And I type "'"
+ And I switch to multiple-cursors mode
+ And I type "("
And I press "M-f"
- And I type "'"
- Then I should see "This 'text' contains the word 'text' twice"
+ And I press "M-f"
+ And I type ")"
+ Then I should see "This (text contains) the word (text twice)"
diff --git a/features/multiple-cursors-core.feature
b/features/multiple-cursors-core.feature
index 63ef45f..b62de30 100644
--- a/features/multiple-cursors-core.feature
+++ b/features/multiple-cursors-core.feature
@@ -5,9 +5,30 @@ Feature: Multiple cursors core
Scenario: Two cursors
Given there is no region selected
- When I insert "This text contains the word text thrice (text)"
+ When I insert "This text contains the word text twice"
+ And I select "text"
+ And I press "C->"
+ And I switch to multiple-cursors mode
+ Then I should have 2 cursors
+
+ Scenario: Three cursors
+ Given there is no region selected
+ When I insert:
+ """
+ This text contains the word text thrice, and
+ one of the instances of the word text is on the second line.
+ """
And I select "text"
And I press "C->"
And I press "C->"
- And I press "C-g"
+ And I switch to multiple-cursors mode
Then I should have 3 cursors
+
+ Scenario: Exiting multiple-cursors mode with return
+ Given there is no region selected
+ When I insert "This text contains the word text twice"
+ And I select "text"
+ And I press "C->"
+ And I switch to multiple-cursors mode
+ And I press "<return>"
+ Then I should have one cursor
diff --git a/features/step-definitions/multiple-cursors-steps.el
b/features/step-definitions/multiple-cursors-steps.el
index 7f750d3..35349f7 100644
--- a/features/step-definitions/multiple-cursors-steps.el
+++ b/features/step-definitions/multiple-cursors-steps.el
@@ -1,16 +1,27 @@
(And "^delete-selection-mode is active$"
(lambda ()
- (delete-selection-mode 1)))
+ (delete-selection-mode 1)))
(defun is-extra-cursor-p (o)
- (message "overlay-type: %S" (overlay-get o 'type))
(eq (overlay-get o 'type) 'additional-cursor))
(defun num-cursors ()
(1+ (count-if 'is-extra-cursor-p
- (overlays-in (point-min) (point-max)))))
+ (overlays-in (point-min) (point-max)))))
(Then "^I should have \\([0-9]+\\) cursors$"
- (lambda (num)
- (assert (eq (string-to-number num) (num-cursors)) nil
- "Expected to have %s cursors, but was %d." num
(num-cursors))))
+ (lambda (num)
+ (let ((actual (num-cursors)))
+ (assert (eq (string-to-number num) actual) nil
+ "Expected to have %s cursors, but was %d." num actual))))
+
+(Then "^I should have one cursor$"
+ (lambda ()
+ (assert (not multiple-cursors-mode) nil
+ "Expected to have one cursor, but multiple-cursors-mode is
still active.")
+ (assert (eq 1 (num-cursors)) nil
+ "Expected to have one cursor, but there are still fake cursor
overlays.")))
+
+(And "^I switch to multiple-cursors mode$"
+ (lambda ()
+ (mc/switch-from-mark-multiple-to-cursors)))
diff --git a/features/support/env.el b/features/support/env.el
index 686073d..a93cac3 100644
--- a/features/support/env.el
+++ b/features/support/env.el
@@ -14,6 +14,7 @@
(require 'ert)
(Before
+ (multiple-cursors-mode 0)
(mm/clear-all)
(global-set-key (kbd "C->") 'mark-next-like-this)
(switch-to-buffer
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 910dfdc..ab9b568 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -144,7 +144,7 @@ cursors."
original-command
(get original-command 'mc--unsupported))
(if (not (memq original-command mc--cmds))
- (when (not (memq original-command mc--cmds-run-once))
+ (when (and original-command (not (memq original-command
mc--cmds-run-once)))
(message "Skipping %S" original-command))
(mc/execute-command-for-all-fake-cursors original-command))))))
@@ -222,12 +222,13 @@ from being executed if in multiple-cursors-mode."
(overlay-put cursor 'kill-ring-yank-pointer
kill-ring-yank-pointer)))))))
;;----------------------------------------------------------------------------------------
-;; Commands to run only once (not yet in use)
+;; Commands to run only once (don't need to message about skipping it)
(setq mc--cmds-run-once '(mark-next-like-this
save-buffer
undo
undo-tree-undo
- undo-tree-redo))
+ undo-tree-redo
+ mc/switch-from-mark-multiple-to-cursors))
;; Commands that should be mirrored by all cursors
(setq mc--cmds '(mc/keyboard-quit