emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/multiple-cursors 97da977 141/434: Intercept some reading c


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 97da977 141/434: Intercept some reading commands
Date: Sat, 7 Aug 2021 09:20:13 -0400 (EDT)

branch: elpa/multiple-cursors
commit 97da9778fdb7c6e59cbb5ab038a46a437736b777
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Intercept some reading commands
    
     - so you won't have to answer them for every single cursor
    
    Fixes #15
---
 features/multiple-cursors-core.feature             |  7 ++++++
 .../step-definitions/multiple-cursors-steps.el     |  5 +++++
 multiple-cursors-core.el                           | 26 +++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/features/multiple-cursors-core.feature 
b/features/multiple-cursors-core.feature
index 718e17f..a889b9c 100644
--- a/features/multiple-cursors-core.feature
+++ b/features/multiple-cursors-core.feature
@@ -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
diff --git a/features/step-definitions/multiple-cursors-steps.el 
b/features/step-definitions/multiple-cursors-steps.el
index b634460..900eeed 100644
--- a/features/step-definitions/multiple-cursors-steps.el
+++ b/features/step-definitions/multiple-cursors-steps.el
@@ -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))
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 59a145f..56caab0 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]