[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors c18aa84 002/434: Separate kill-ring for e
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors c18aa84 002/434: Separate kill-ring for each cursor. |
Date: |
Sat, 7 Aug 2021 09:19:43 -0400 (EDT) |
branch: elpa/multiple-cursors
commit c18aa846b656ec6bad47b4e24ae71ae99f0d7f56
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Separate kill-ring for each cursor.
---
multiple-cursors.el | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/multiple-cursors.el b/multiple-cursors.el
index e6aded8..bbc0bce 100644
--- a/multiple-cursors.el
+++ b/multiple-cursors.el
@@ -21,16 +21,17 @@
(defun mc/add-cursor-at-point ()
(let ((overlay (mc/make-cursor-overlay-at-point)))
(overlay-put overlay 'type 'additional-cursor)
+ (overlay-put overlay 'kill-ring kill-ring)
(overlay-put overlay 'priority 100)))
(setq mc--cmds '(self-insert-command
previous-line
next-line
newline
- right-char
- right-word
- left-char
- left-word
+ right-char forward-char
+ right-word forward-word
+ left-char backward-char
+ left-word backward-word
yank
kill-word
kill-region-or-backward-word
@@ -41,18 +42,34 @@
move-end-of-line-or-next-line
move-start-of-line-or-prev-line))
-(defun mc/execute-this-command-for-all-cursors ()
- (if (not (memq this-original-command mc--cmds))
- (message "Skipping %S" this-original-command)
+(setq mc--unsupported-cmds '(yank-pop))
+
+;; todo: macro-ify and iterate over mc--unsupported-cmds
+(defadvice yank-pop (around yank-pop-unsupported-advice activate)
+ "yank-pop isn't supported with multiple cursors"
+ (unless multiple-cursors-mode
+ ad-do-it))
+
+(defun mc/execute-command-for-all-cursors (cmd)
+ (let ((current-kill-ring kill-ring))
(save-excursion
(mapc #'(lambda (o)
(when (eq (overlay-get o 'type) 'additional-cursor)
(goto-char (overlay-start o))
+ (setq kill-ring (overlay-get o 'kill-ring))
(delete-overlay o)
(ignore-errors
- (call-interactively this-original-command)
+ (call-interactively cmd)
(mc/add-cursor-at-point))))
- (overlays-in (point-min) (point-max))))))
+ (overlays-in (point-min) (point-max))))
+ (setq kill-ring current-kill-ring)))
+
+(defun mc/execute-this-command-for-all-cursors ()
+ (if (memq this-original-command mc--unsupported-cmds)
+ (message "%S is not supported with multiple cursors"
this-original-command)
+ (if (not (memq this-original-command mc--cmds))
+ (message "Skipping %S" this-original-command)
+ (mc/execute-command-for-all-cursors this-original-command))))
(defun mc/remove-additional-cursors ()
(mapc #'(lambda (o)
@@ -75,8 +92,10 @@
(mc/remove-additional-cursors))
(t (add-hook 'post-command-hook
'mc/execute-this-command-for-all-cursors t t))))
-(defun mc/edit-ends-of-lines ()
+(defun mc/add-multiple-cursors-to-region-lines ()
(interactive)
+ (when (not (use-region-p))
+ (error "Mark a set of lines first."))
(mc/remove-additional-cursors)
(let* ((point-line (line-number-at-pos))
(mark-line (save-excursion (exchange-point-and-mark)
(line-number-at-pos)))
@@ -84,11 +103,21 @@
(navigation-func (if (< point-line mark-line) 'previous-line
'next-line)))
(exchange-point-and-mark)
(while (not (eq (line-number-at-pos) point-line))
- (end-of-line)
(mc/add-cursor-at-point)
(funcall navigation-func))
- (end-of-line)
(deactivate-mark)
(multiple-cursors-mode)))
+(defun mc/edit-ends-of-lines ()
+ (interactive)
+ (mc/add-multiple-cursors-to-region-lines)
+ (mc/execute-command-for-all-cursors 'end-of-line)
+ (end-of-line))
+
+(defun mc/edit-beginnings-of-lines ()
+ (interactive)
+ (mc/add-multiple-cursors-to-region-lines)
+ (mc/execute-command-for-all-cursors 'beginning-of-line)
+ (beginning-of-line))
+
(provide 'multiple-cursors)
- [nongnu] branch elpa/multiple-cursors created (now 616fbdd), ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 224f919 008/434: Explicitly depend on mark-multiple., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e44f45f 019/434: More white-listing in multiple-cursors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b28e8f9 023/434: Update test to fix missing step definition., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a682c15 027/434: Disable regions first with C-g, then multiple-cursors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 13668a9 001/434: initial commit, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c18aa84 002/434: Separate kill-ring for each cursor.,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 0d40ea1 003/434: Updated readme., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 18f7f1a 010/434: More white-listed commands for multiple cursors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cf82088 014/434: Add backward-list to white-list., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 26d0e52 015/434: Add more commands to white-list., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 5e64246 025/434: Move todo to own file., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e0ffd9c 026/434: Disable marker when done with it, for performance reasons., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9938aca 028/434: Save er/history for each cursor, to be able to contract., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dfe8a2d 029/434: Slight optimisation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6c0e16e 033/434: More things to do., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 07a4411 036/434: More things to do., ELPA Syncer, 2021/08/07