[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 1075270 407/434: Added mc/interactive-rep
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 1075270 407/434: Added mc/interactive-repeating-commands (#303) |
Date: |
Sat, 7 Aug 2021 09:21:10 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 10752700084595bb24712c27ba70a2326302e45b
Author: bb2020 <bb2020@users.noreply.github.com>
Commit: Jules Tamangan <jtamagnan@gmail.com>
Added mc/interactive-repeating-commands (#303)
* Added mc/interactive-repeating-commands
* simplify mc/interactive-repeating-commands
* simplify mc/interactive-repeating-commands
* removed mc/interactive-repeating-commands
* added mc/repeat-command
* rebound mc/repeat-command
* blacklisted repeat-complex-command
* added mc/always-repeat-command
* added mc/repeat-command tests
---
features/repeat-command.feature | 37 +++++++++++++++++++++++++++++++++++++
multiple-cursors-core.el | 22 +++++++++++++++++++++-
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/features/repeat-command.feature b/features/repeat-command.feature
new file mode 100644
index 0000000..b49c859
--- /dev/null
+++ b/features/repeat-command.feature
@@ -0,0 +1,37 @@
+Feature: Repeat last interactive command for fake cursors (mc/repeat-command)
+
+ Scenario: Clone insert-char from M-x
+ Given I have cursors at "text" in "This text contains the word text thrice
(text)"
+ When I start an action chain
+ When I press "M-x"
+ And I type "insert-char"
+ And I press "RET"
+ And I type "21"
+ And I press "RET"
+ And I press "C-:"
+ And I press "y"
+ And I execute the action chain
+ Then I should see "This !text contains the word !text thrice (!text)"
+
+ Scenario: Clone insert-char from M-:
+ Given I have cursors at "text" in "This text contains the word text thrice
(text)"
+ When I start an action chain
+ When I press "M-:"
+ And I type "(insert-char (+ 40 2))"
+ And I press "RET"
+ And I press "C-:"
+ And I press "y"
+ And I execute the action chain
+ Then I should see "This *text contains the word *text thrice (*text)"
+
+ 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 start an action chain
+ And I press "M-x"
+ And I type "zap-to-char"
+ And I press "RET"
+ And I press "/"
+ And I press "C-:"
+ And I execute the action chain
+ Then I should see "This 0000 contains the word 1111 thrice (2222)"
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index a60c9db..d448617 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -330,6 +330,11 @@ cursor with updated info."
:type '(boolean)
:group 'multiple-cursors)
+(defcustom mc/always-repeat-command nil
+ "Disables confirmation for `mc/repeat-command' command."
+ :type '(boolean)
+ :group 'multiple-cursors)
+
(defun mc/prompt-for-inclusion-in-whitelist (original-command)
"Asks the user, then adds the command either to the once-list or the
all-list."
(let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command))))
@@ -442,6 +447,17 @@ you should disable multiple-cursors-mode."
(multiple-cursors-mode 0)
(deactivate-mark)))
+(defun mc/repeat-command ()
+ "Run last command from `command-history' for every fake cursor."
+ (interactive)
+ (when (or mc/always-repeat-command
+ (y-or-n-p (format "[mc] repeat complex command: %s? " (caar
command-history))))
+ (mc/execute-command-for-all-fake-cursors
+ (lambda () (interactive)
+ (cl-letf (((symbol-function 'read-from-minibuffer)
+ (lambda (p &optional i k r h d m) (read i))))
+ (repeat-complex-command 0))))))
+
(defvar mc/keymap nil
"Keymap while multiple cursors are active.
Main goal of the keymap is to rebind C-g and <return> to conclude
@@ -450,6 +466,7 @@ multiple cursors editing.")
(setq mc/keymap (make-sparse-keymap))
(define-key mc/keymap (kbd "C-g") 'mc/keyboard-quit)
(define-key mc/keymap (kbd "<return>") 'multiple-cursors-mode)
+ (define-key mc/keymap (kbd "C-:") 'mc/repeat-command)
(when (fboundp 'phi-search)
(define-key mc/keymap (kbd "C-s") 'phi-search))
(when (fboundp 'phi-search-backward)
@@ -657,6 +674,7 @@ for running commands with multiple cursors."
mc/skip-to-previous-like-this
rrm/switch-to-multiple-cursors
mc-hide-unmatched-lines-mode
+ mc/repeat-command
hum/keyboard-quit
hum/unhide-invisible-overlays
save-buffer
@@ -665,6 +683,7 @@ for running commands with multiple cursors."
exit-minibuffer
minibuffer-complete-and-exit
execute-extended-command
+ eval-expression
undo
redo
undo-tree-undo
@@ -698,7 +717,8 @@ for running commands with multiple cursors."
windmove-left
windmove-right
windmove-up
- windmove-down))
+ windmove-down
+ repeat-complex-command))
(defvar mc--default-cmds-to-run-for-all nil
"Default set of commands that should be mirrored by all cursors")
- [nongnu] elpa/multiple-cursors 66ceb0b 246/434: Revert cursor specific pre- & post-command-hooks, (continued)
- [nongnu] elpa/multiple-cursors 66ceb0b 246/434: Revert cursor specific pre- & post-command-hooks, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 725369c 253/434: Merge pull request #97 from knu/fix-mc-mark-pop-doc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bbbe90d 349/434: Minor changes mark-next-like-this-word and readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dd07bc5 351/434: Merge pull request #228 from jtamagnan/mark-next-like-this-word, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 8297f1f 363/434: Merge pull request #241 from YoungFrog/fix-#230, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 3112e61 377/434: When cursor-type is bar, mc/cursors appear as bars, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 8413969 383/434: Merge pull request #253 from jtamagnan/fake-bar-cursor, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors ddbe3ae 396/434: Merge pull request #278 from shlomme/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d2766bc 400/434: tips and tricks: add note about <return> and newlines; if it is not default, let it at least be more discoverable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 0e49fec 410/434: Merge pull request #326 from pstray/issue325, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 1075270 407/434: Added mc/interactive-repeating-commands (#303),
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 038815b 414/434: Make "no more matches found." user-error, fix #218, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d27870d 421/434: Load mc/list-file as late as possible, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fc6a6a7 422/434: Merge pull request #355 from flatwhatson/lazy-list-file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7763f4f 429/434: Load mc-cycle-cursors and mc-hide-unmatched-lines-mode after loading multiple-cursors-core, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a9d7764 431/434: Add option to disable bar-style fake cursors (#367), ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 616fbdd 434/434: Document existing functions in Readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7ab8a8c 067/434: Better support for undo., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 608ceb4 069/434: Disable multiple-cursors-mode if there's only one cursor (the real one)., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 61280ae 100/434: autoload integration for package.el compatibility, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d82e252 106/434: Don't let fake cursors scroll the buffer, ELPA Syncer, 2021/08/07