mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2026-05-10 01:18:19 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d4979db46 | |||
| f040a33e3c | |||
| 64ffd81491 | |||
| 97da9778fd | |||
| ae0033fe3d | |||
| 5fcc69cc54 |
@@ -119,6 +119,13 @@ Feature: Multiple cursors core
|
||||
And I type "!"
|
||||
Then I should see "This ! contains the word ! twice"
|
||||
|
||||
Scenario: Bound keyboard macros
|
||||
Given I have bound C-! to a keyboard macro that insert "_"
|
||||
And I have cursors at "text" in "This text contains the word text twice"
|
||||
When I press "C-!"
|
||||
When I press "C-!"
|
||||
Then I should see "This __text contains the word __text twice"
|
||||
|
||||
Scenario: Interprogram paste
|
||||
Given I have cursors at "text" in "This text contains the word text twice"
|
||||
When I copy "external" in another program
|
||||
|
||||
@@ -68,6 +68,11 @@
|
||||
(defun mc-test-temp-command-2 () (interactive) (insert ins))
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-command-2))))
|
||||
|
||||
(Given "^I have bound C-! to a keyboard macro that insert \"_\"$"
|
||||
(lambda ()
|
||||
(fset 'mc-test-temp-kmacro "\C-q_")
|
||||
(global-set-key (kbd "C-!") 'mc-test-temp-kmacro)))
|
||||
|
||||
(When "^I go to character \"\\(.+\\)\"$"
|
||||
(lambda (char)
|
||||
(goto-char (point-min))
|
||||
|
||||
@@ -205,7 +205,31 @@ cursor with updated info."
|
||||
(mc/pop-state-from-overlay cursor)
|
||||
(ignore-errors
|
||||
(mc/execute-command cmd)
|
||||
(mc/create-fake-cursor-at-point id)))))))))
|
||||
(mc/create-fake-cursor-at-point id))))))))
|
||||
(mc--reset-read-prompts))
|
||||
|
||||
;; Intercept some reading commands so you won't have to
|
||||
;; answer them for every single cursor
|
||||
|
||||
(defadvice read-char (around mc-support activate)
|
||||
(if (not multiple-cursors-mode)
|
||||
ad-do-it
|
||||
(unless mc--read-char
|
||||
(setq mc--read-char ad-do-it))
|
||||
(setq ad-return-value mc--read-char)))
|
||||
|
||||
(defadvice read-quoted-char (around mc-support activate)
|
||||
(if (not multiple-cursors-mode)
|
||||
ad-do-it
|
||||
(unless mc--read-quoted-char
|
||||
(setq mc--read-quoted-char ad-do-it))
|
||||
(setq ad-return-value mc--read-quoted-char)))
|
||||
|
||||
(defun mc--reset-read-prompts ()
|
||||
(setq mc--read-char nil)
|
||||
(setq mc--read-quoted-char nil))
|
||||
|
||||
(mc--reset-read-prompts)
|
||||
|
||||
(defun mc/fake-cursor-p (o)
|
||||
"Predicate to check if an overlay is a fake cursor"
|
||||
@@ -266,6 +290,14 @@ not be recognized through the command-remapping lookup."
|
||||
this-original-command))))
|
||||
|
||||
(defun mc/execute-this-command-for-all-cursors ()
|
||||
"Wrap around `mc/execute-this-command-for-all-cursors-1' to protect hook."
|
||||
(condition-case error
|
||||
(mc/execute-this-command-for-all-cursors-1)
|
||||
(error
|
||||
(message "[mc] problem in `mc/execute-this-command-for-all-cursors': %s"
|
||||
(error-message-string error)))))
|
||||
|
||||
(defun mc/execute-this-command-for-all-cursors-1 ()
|
||||
"Used with post-command-hook to execute supported commands for all cursors.
|
||||
|
||||
It uses two lists of commands to know what to do: the run-once
|
||||
@@ -274,6 +306,8 @@ it will prompt for the proper action and then save that preference.
|
||||
|
||||
Some commands are so unsupported that they are even prevented for
|
||||
the original cursor, to inform about the lack of support."
|
||||
(unless mc--executing-command-for-fake-cursor
|
||||
|
||||
(if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
|
||||
(multiple-cursors-mode 0)
|
||||
|
||||
@@ -282,6 +316,10 @@ the original cursor, to inform about the lack of support."
|
||||
(command-remapping this-original-command)
|
||||
this-original-command)))
|
||||
|
||||
;; skip keyboard macros, since they will generate actual commands that are
|
||||
;; also run in the command loop - we'll handle those later instead.
|
||||
(when (functionp original-command)
|
||||
|
||||
;; if it's a lambda, we can't know if it's supported or not
|
||||
;; - so go ahead and assume it's ok, because we're just optimistic like that
|
||||
(if (not (symbolp original-command))
|
||||
@@ -298,7 +336,7 @@ the original cursor, to inform about the lack of support."
|
||||
(or (memq original-command mc--default-cmds-to-run-for-all)
|
||||
(memq original-command mc/cmds-to-run-for-all)
|
||||
(mc/prompt-for-inclusion-in-whitelist original-command)))
|
||||
(mc/execute-command-for-all-fake-cursors original-command))))))))
|
||||
(mc/execute-command-for-all-fake-cursors original-command))))))))))
|
||||
|
||||
(defun mc/remove-fake-cursors ()
|
||||
"Remove all fake cursors.
|
||||
@@ -479,6 +517,7 @@ for running commands with multiple cursors.")
|
||||
ido-exit-minibuffer
|
||||
exit-minibuffer
|
||||
minibuffer-complete-and-exit
|
||||
execute-extended-command
|
||||
undo
|
||||
redo
|
||||
undo-tree-undo
|
||||
@@ -516,6 +555,7 @@ for running commands with multiple cursors.")
|
||||
|
||||
(setq mc--default-cmds-to-run-for-all '(mc/keyboard-quit
|
||||
self-insert-command
|
||||
quoted-insert
|
||||
previous-line
|
||||
next-line
|
||||
newline
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
(define-package "multiple-cursors" "1.1.2"
|
||||
(define-package "multiple-cursors" "1.1.3"
|
||||
"Multiple cursors for Emacs.")
|
||||
|
||||
Reference in New Issue
Block a user