diff --git a/features/multiple-cursors-core.feature b/features/multiple-cursors-core.feature index 0a6e8b9..dd97811 100644 --- a/features/multiple-cursors-core.feature +++ b/features/multiple-cursors-core.feature @@ -57,6 +57,28 @@ Feature: Multiple cursors core And I press "C-!" Then I should see "This aatext contains the word text twice" + Scenario: Multiple supported M-x command (forward-word in this case) + Given I have cursors at "text" in "This text contains the word text twice" + And I type "(" + And I press "M-x forward-word" + And I press "M-x forward-word" + And I type ")" + Then I should see "This (text contains) the word (text twice)" + + Scenario: Unknown M-x command: yes, do for all + Given I have cursors at "text" in "This text contains the word text twice" + And I press "C-SPC" + And I press "M-f" + And I press "M-x upcase-dwim RET y" + Then I should see "This TEXT contains the word TEXT twice" + + Scenario: Unknown M-x command: no, don't do for all + Given I have cursors at "text" in "This text contains the word text twice" + And I press "C-SPC" + And I press "M-f" + And I press "M-x upcase-dwim RET n" + Then I should see "This TEXT contains the word text twice" + Scenario: Undo Given I have cursors at "text" in "This text contains the word text twice" When I press "M-f" diff --git a/features/repeat-command.feature b/features/repeat-command.feature index b49c859..f777c95 100644 --- a/features/repeat-command.feature +++ b/features/repeat-command.feature @@ -8,6 +8,7 @@ Feature: Repeat last interactive command for fake cursors (mc/repeat-command) And I press "RET" And I type "21" And I press "RET" + And I type "n" And I press "C-:" And I press "y" And I execute the action chain @@ -27,6 +28,7 @@ Feature: Repeat last interactive command for fake cursors (mc/repeat-command) Scenario: Disable prompt Given I have cursors at "text" in "This text/0000 contains the word text/1111 thrice (text/2222)" When I set mc/always-repeat-command to t + When I set mc/always-run-for-all to t When I start an action chain And I press "M-x" And I type "zap-to-char" diff --git a/features/support/env.el b/features/support/env.el index 8410ca3..e05985a 100644 --- a/features/support/env.el +++ b/features/support/env.el @@ -45,6 +45,8 @@ (subword-mode 0) (wrap-region-mode 0) (setq set-mark-default-inactive nil) - (deactivate-mark)) + (deactivate-mark) + (setq mc/cmds-to-run-for-all nil) + (setq mc/cmds-to-run-once nil)) (After) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index 628663d..b24ec7e 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -664,6 +664,20 @@ from being executed if in multiple-cursors-mode." (overlay-put cursor 'kill-ring kill-ring) (overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer))))))) +(defadvice execute-extended-command (after execute-extended-command-for-all-cursors () activate) + (when multiple-cursors-mode + (unless (or mc/always-run-for-all + (not (symbolp this-command)) + (memq this-command mc/cmds-to-run-for-all) + (memq this-command mc/cmds-to-run-once) + (memq this-command mc--default-cmds-to-run-for-all) + (memq this-command mc--default-cmds-to-run-once)) + (mc/prompt-for-inclusion-in-whitelist this-command)) + (when (or mc/always-run-for-all + (memq this-command mc/cmds-to-run-for-all) + (memq this-command mc--default-cmds-to-run-for-all)) + (mc/execute-command-for-all-fake-cursors this-command)))) + (defcustom mc/list-file (locate-user-emacs-file ".mc-lists.el") "The position of the file that keeps track of your preferences for running commands with multiple cursors."