[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 351eb6cbb5 1/2: Add multiple-cursors supp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 351eb6cbb5 1/2: Add multiple-cursors support to execute-extended-command |
Date: |
Sat, 24 Dec 2022 07:59:13 -0500 (EST) |
branch: elpa/multiple-cursors
commit 351eb6cbb54f55b37557da03b74aad8fb13867c8
Author: Leo Gaskin <leo.gaskin@le0.gs>
Commit: Magnar Sveen <magnars@gmail.com>
Add multiple-cursors support to execute-extended-command
Also add three new tests for this functionality and adapt some existing
tests as well as the testing harness.
---
features/multiple-cursors-core.feature | 22 ++++++++++++++++++++++
features/repeat-command.feature | 2 ++
features/support/env.el | 4 +++-
multiple-cursors-core.el | 14 ++++++++++++++
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/features/multiple-cursors-core.feature
b/features/multiple-cursors-core.feature
index 0a6e8b9369..dd97811017 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 b49c85971a..f777c95ca5 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 8410ca3ee8..e05985ac2c 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 628663d249..b24ec7eec3 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."