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

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

[nongnu] elpa/multiple-cursors 719fe40 119/434: Integrate with rect.el i


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 719fe40 119/434: Integrate with rect.el instead of consolidating/splitting on kill-ring
Date: Sat, 7 Aug 2021 09:20:08 -0400 (EDT)

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

    Integrate with rect.el instead of consolidating/splitting on kill-ring
---
 features/multiple-cursors-core.feature | 27 ++-------------------------
 multiple-cursors-core.el               | 29 +++++------------------------
 2 files changed, 7 insertions(+), 49 deletions(-)

diff --git a/features/multiple-cursors-core.feature 
b/features/multiple-cursors-core.feature
index cba589b..64e3ae6 100644
--- a/features/multiple-cursors-core.feature
+++ b/features/multiple-cursors-core.feature
@@ -115,7 +115,7 @@ Feature: Multiple cursors core
     And I press "C-y"
     Then I should see "This externaltext contains the word externaltext twice"
 
-  Scenario: Consolidated kill-ring after exiting multiple-cursors-mode
+  Scenario: Added to killed-rectangle after exiting multiple-cursors-mode
     Given I have cursors at "text" in "This text contains the word text twice"
     When I press "M-f"
     And I press "C-f"
@@ -124,33 +124,10 @@ Feature: Multiple cursors core
     And I press "M-w"
     And I press "<return>"
     And I press "C-a"
-    And I press "C-y"
     And I press "C-k"
+    And I press "C-x r y"
     Then I should see:
     """
     contains
     twice
     """
-
-  Scenario: Split multiline kill-ring entry over cursors when num lines match
-    When I insert:
-    """
-    a
-    b
-    c
-    """
-    And I go to the front of the word "a"
-    And I press "C-SPC"
-    And I go to the end of the word "c"
-    And I press "M-w"
-    And I go to the end of the word "a"
-    And I press "H-SPC"
-    And I press "C-n"
-    And I press "C-n"
-    And I press "C-y"
-    Then I should see:
-    """
-    aa
-    bb
-    cc
-    """
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index bf45e97..ca88228 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -27,6 +27,8 @@
 
 (eval-when-compile (require 'cl))
 
+(require 'rect)
+
 (defface mc/cursor-face
   '((t (:inverse-video t)))
   "The face used for fake cursors"
@@ -316,31 +318,10 @@ multiple cursors editing.")
      (setq entries (cons (car (overlay-get cursor 'kill-ring)) entries)))
     (reverse entries)))
 
-(defun mc--maybe-consolidate-kill-rings ()
+(defun mc--maybe-set-killed-rectangle ()
   (let ((entries (mc--kill-ring-entries)))
     (unless (mc--all-equal entries)
-      (kill-new (mapconcat 'identity entries "\n")))))
-
-(defun mc--kill-new (entries)
-  (mc/for-each-cursor-ordered
-   (let ((kill-ring (overlay-get cursor 'kill-ring))
-         (kill-ring-yank-pointer (overlay-get cursor 'kill-ring-yank-pointer)))
-     (kill-new (car entries))
-     (setq entries (cdr entries))
-     (overlay-put cursor 'kill-ring kill-ring)
-     (overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer))))
-
-(defun mc--maybe-split-kill-ring ()
-  (let ((entries (mc--kill-ring-entries)))
-    (when (mc--all-equal entries)
-      (let ((lines (split-string (car entries) "\n")))
-        (when (= (mc/num-cursors) (length lines))
-          (mc--kill-new lines))))))
-
-(defadvice yank (before maybe-split-kill-ring activate)
-  (when (and (or multiple-cursors-mode rectangular-region-mode)
-             (not mc--executing-command-for-fake-cursor))
-    (mc--maybe-split-kill-ring)))
+      (setq killed-rectangle entries))))
 
 (define-minor-mode multiple-cursors-mode
   "Mode while multiple cursors are active."
@@ -350,7 +331,7 @@ multiple cursors editing.")
         (add-hook 'post-command-hook 'mc/execute-this-command-for-all-cursors 
t t)
         (run-hooks 'multiple-cursors-mode-enabled-hook))
     (remove-hook 'post-command-hook 'mc/execute-this-command-for-all-cursors t)
-    (mc--maybe-consolidate-kill-rings)
+    (mc--maybe-set-killed-rectangle)
     (mc/remove-fake-cursors)
     (run-hooks 'multiple-cursors-mode-disabled-hook)))
 



reply via email to

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