From fcbb7a4df99eb37c2fe7589c3a8ac1dcbe953395 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 09:24:19 +0200 Subject: [PATCH 01/12] Make mc/cycle-forward and mc/cycle-backward loop around by default. Instead of erroring if there is no next (respectively previous) cursor mc/cycle-forward (respectively mc/cycle-backward) will just loop back to the first (respectively last) cursor. --- mc-cycle-cursors.el | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index f70a96a..2aaade0 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -54,23 +54,31 @@ (setq prev cursor)))) prev)) -(defun mc/cycle-forward () - (interactive) +(defun mc/cycle-forward (&optional error-if-no-next-cursor) + (interactive (list prefix-arg)) (let ((next-cursor (mc/next-cursor-after-point))) - (unless next-cursor + (cond + (next-cursor + (mc/create-fake-cursor-at-point) + (mc/pop-state-from-overlay next-cursor) + (recenter)) + (error-if-no-next-cursor (error "We're already at the last cursor")) - (mc/create-fake-cursor-at-point) - (mc/pop-state-from-overlay next-cursor) - (recenter))) + (t + (mc/cycle-backward t))))) -(defun mc/cycle-backward () - (interactive) +(defun mc/cycle-backward (&optional error-if-no-previous-cursor) + (interactive (list prefix-arg)) (let ((prev-cursor (mc/prev-cursor-before-point))) - (unless prev-cursor + (cond + (prev-cursor + (mc/create-fake-cursor-at-point) + (mc/pop-state-from-overlay prev-cursor) + (recenter)) + (error-if-no-previous-cursor (error "We're already at the first cursor")) - (mc/create-fake-cursor-at-point) - (mc/pop-state-from-overlay prev-cursor) - (recenter))) + (t + (mc/cycle-forward t))))) (define-key mc/keymap (kbd "C-v") 'mc/cycle-forward) (define-key mc/keymap (kbd "M-v") 'mc/cycle-backward) From 876937bfa3d2d341434a6913cdff1060eb25bd48 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 10:04:22 +0200 Subject: [PATCH 02/12] Use (interactive "P") instead of the weird (but equivalent) (interactive (list prefix-arg)) --- mc-cycle-cursors.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index 2aaade0..643f00e 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -55,7 +55,7 @@ prev)) (defun mc/cycle-forward (&optional error-if-no-next-cursor) - (interactive (list prefix-arg)) + (interactive "P") (let ((next-cursor (mc/next-cursor-after-point))) (cond (next-cursor @@ -68,7 +68,7 @@ (mc/cycle-backward t))))) (defun mc/cycle-backward (&optional error-if-no-previous-cursor) - (interactive (list prefix-arg)) + (interactive "P") (let ((prev-cursor (mc/prev-cursor-before-point))) (cond (prev-cursor From 3f20fc15a74262eefad3bd95bd0504435f7bbe49 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 11:15:22 +0200 Subject: [PATCH 03/12] When no region is active mc/mark-next-like-this and mc/mark-previous-like-this should create a cursor one like up (or down). Added the functions mc/mark-next-lines and mc/mark-previous-lines which create cursors one line above and below point. Refactored common mc/mark-previous-like-this and mc/mark-next-like-this functionality into mc/mark-more-like-this. Changed mc/mark-next-like-this and mc/mark-more-like-this to call mc/mark-next-lines and mc/mark-previous-lines when there is no active region (instead of erroring). --- mc-mark-more.el | 111 +++++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/mc-mark-more.el b/mc-mark-more.el index 883fb1e..8dd4bc6 100644 --- a/mc-mark-more.el +++ b/mc-mark-more.el @@ -79,34 +79,54 @@ (mc/cursor-end cursor)))) strings)) +(defun mc/maybe-multiple-cursors-mode () + "Enable multiple-cursors-mode if there is more than one currently active cursor." + (if (> (mc/num-cursors) 1) + (multiple-cursors-mode 1) + (multiple-cursors-mode 0))) + +(defun mc/mark-more-like-this (skip-last direction) + (let ((case-fold-search nil) + (re (regexp-opt (mc/region-strings))) + (point-out-of-order (ecase direction + (forwards (< (point) (mark))) + (backwards (not (< (point) (mark)))))) + (furthest-cursor (ecase direction + (forwards (mc/furthest-cursor-after-point)) + (backwards (mc/furthest-cursor-before-point)))) + (start-char (ecase direction + (forwards (mc/furthest-region-end)) + (backwards (mc/first-region-start)))) + (search-function (ecase direction + (forwards 'search-forward-regexp) + (backwards 'search-backward-regexp))) + (match-point-getter (ecase direction + (forwards 'match-beginning) + (backwards 'match-end)))) + (mc/save-excursion + (goto-char start-char) + (when skip-last + (mc/remove-fake-cursor furthest-cursor)) + (if (funcall search-function re nil t) + (progn + (push-mark (funcall match-point-getter 0)) + (when point-out-of-order + (exchange-point-and-mark)) + (mc/create-fake-cursor-at-point)) + (error "no more matches found."))))) + ;;;###autoload (defun mc/mark-next-like-this (arg) "Find and mark the next part of the buffer matching the currently active region With negative ARG, delete the last one instead. With zero ARG, skip the last one and mark next." (interactive "p") - (unless (region-active-p) - (error "Mark a region to match first.")) - (when (< arg 0) - (mc/remove-fake-cursor (mc/furthest-cursor-after-point))) - (when (>= arg 0) - (let ((case-fold-search nil) - (point-first (< (point) (mark))) - (re (regexp-opt (mc/region-strings))) - (furthest-cursor (mc/furthest-cursor-after-point))) - (mc/save-excursion - (goto-char (mc/furthest-region-end)) - (when (= arg 0) - (mc/remove-fake-cursor furthest-cursor)) - (if (search-forward-regexp re nil t) - (progn - (push-mark (match-beginning 0)) - (when point-first (exchange-point-and-mark)) - (mc/create-fake-cursor-at-point)) - (error "no more found forward"))))) - (if (> (mc/num-cursors) 1) - (multiple-cursors-mode 1) - (multiple-cursors-mode 0))) + (if (region-active-p) + (if (< arg 0) + (mc/remove-fake-cursor (mc/furthest-cursor-after-point)) + (mc/mark-more-like-this (= arg 0) 'forwards)) + (mc/mark-lines arg 'forwards)) + (mc/maybe-multiple-cursors-mode)) ;;;###autoload (defun mc/mark-previous-like-this (arg) @@ -114,28 +134,31 @@ With zero ARG, skip the last one and mark next." With negative ARG, delete the last one instead. With zero ARG, skip the last one and mark next." (interactive "p") - (unless (region-active-p) - (error "Mark a region to match first.")) - (when (< arg 0) - (mc/remove-fake-cursor (mc/furthest-cursor-before-point))) - (when (>= arg 0) - (let ((case-fold-search nil) - (point-first (< (point) (mark))) - (re (regexp-opt (mc/region-strings))) - (furthest-cursor (mc/furthest-cursor-before-point))) - (mc/save-excursion - (goto-char (mc/first-region-start)) - (when (= arg 0) - (mc/remove-fake-cursor furthest-cursor)) - (if (search-backward-regexp re nil t) - (progn - (push-mark (match-end 0)) - (unless point-first (exchange-point-and-mark)) - (mc/create-fake-cursor-at-point)) - (error "no more found backward"))))) - (if (> (mc/num-cursors) 1) - (multiple-cursors-mode 1) - (multiple-cursors-mode 0))) + (if (region-active-p) + (if (< arg 0) + (mc/remove-fake-cursor (mc/furthest-cursor-before-point)) + (mc/mark-more-like-this (= arg 0) 'backwards)) + (mc/mark-lines arg 'backwards)) + (mc/maybe-multiple-cursors-mode)) + +(defun mc/mark-lines (num-lines direction) + (dotimes (i num-lines) + (mc/create-fake-cursor-at-point) + (ecase direction + (forwards (next-line 1 nil)) + (backwards (previous-line 1 nil))))) + +;;;###autoload +(defun mc/mark-next-lines (arg) + (interactive "p") + (mc/mark-lines arg 'forwards) + (mc/maybe-multiple-cursors-mode)) + +;;;###autoload +(defun mc/mark-previous-lines (arg) + (interactive "p") + (mc/mark-lines arg 'backwards) + (mc/maybe-multiple-cursors-mode)) ;;;###autoload (defun mc/unmark-next-like-this (arg) From 9ac7675c78a3e0dbc4d54896429a73022d22760a Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 13:36:45 +0200 Subject: [PATCH 04/12] Added tests for mc/cycle-forward and mc/cycle-backward with their new looping behaviour --- features/multiple-cursors-core.feature | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/multiple-cursors-core.feature b/features/multiple-cursors-core.feature index 46d14bf..8d8fb65 100644 --- a/features/multiple-cursors-core.feature +++ b/features/multiple-cursors-core.feature @@ -158,3 +158,17 @@ Feature: Multiple cursors core contains twice """ + + Scenario: Looping forwards around cursors + Given I have cursors at "_" in "1_34567_9" + And I press "C-v" + And I press "C-v" + And I press "C-v" + Then the cursor should be at point "8" + + Scenario: Looping backwards around cursors + Given I have cursors at "_" in "1_34567_9" + And I press "M-v" + And I press "M-v" + Then the cursor should be at point "2" + From 80ebdbb35b3c304a1297239fcbbc74eee2938bd2 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 13:37:40 +0200 Subject: [PATCH 05/12] Added test for mc/mark-(next|previous)-like-this when there is no active region. --- features/mark-more.feature | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/features/mark-more.feature b/features/mark-more.feature index 189b22c..c8cd3ff 100644 --- a/features/mark-more.feature +++ b/features/mark-more.feature @@ -94,3 +94,22 @@ Feature: Marking multiple parts of the buffer And I type "more" Then I should have 2 cursors And I should see "Here's more, more and text" + + Scenario: Marking without an active region + When I insert: + """ + aaa + bbb + ccc + """ + And I go to the front of the word "bbb" + And I press "C->" + And I type "_" + Then I should have 2 cursors + And I should see: + """ + aaa + _bbb + _ccc + """ + From 324d9354b5bba9f354dde16717f74e8420db72e6 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 13:38:47 +0200 Subject: [PATCH 06/12] Split macro mc/for-each-fake-cursor into a function returning all the cursor overlays and a macro to loop over this list. --- multiple-cursors-core.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index 387f7ea..b2576e9 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -49,12 +49,16 @@ (setq buffer-undo-list ;; otherwise add a function to activate this cursor (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list))))) +(defun mc/all-fake-cursors (&optional start end) + (remove-if-not (lambda (overlay) + (mc/fake-cursor-p overlay)) + (overlays-in (or start (point-min)) + (or end (point-max))))) + (defmacro mc/for-each-fake-cursor (&rest forms) "Runs the body for each fake cursor, bound to the name cursor" - `(mapc #'(lambda (cursor) - (when (mc/fake-cursor-p cursor) - ,@forms)) - (overlays-in (point-min) (point-max)))) + `(mapc #'(lambda (cursor) ,@forms) + (mc/all-fake-cursors))) (defmacro mc/save-excursion (&rest forms) "Saves and restores all the state that multiple-cursors cares about." From e4adefc04eb7486b56c08d99584a9e4edeba52df Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Wed, 10 Oct 2012 13:39:28 +0200 Subject: [PATCH 07/12] Fix issues with mc/cycle-(backward|forward) where the cycling was dependent on not having an active mark. This patch also adds two utility functions mc/first-cursor-after and mc/last-cursor-before. --- mc-cycle-cursors.el | 80 +++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index 643f00e..8c3f1a9 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -54,31 +54,63 @@ (setq prev cursor)))) prev)) -(defun mc/cycle-forward (&optional error-if-no-next-cursor) - (interactive "P") - (let ((next-cursor (mc/next-cursor-after-point))) - (cond - (next-cursor - (mc/create-fake-cursor-at-point) - (mc/pop-state-from-overlay next-cursor) - (recenter)) - (error-if-no-next-cursor - (error "We're already at the last cursor")) - (t - (mc/cycle-backward t))))) +(defcustom mc/cycle-looping-behaviour 'continue + "What to do if asked to cycle beyond the last cursor or before the first cursor." + :type '(radio (const :tag "Loop around to beginning/end of document." continue) + (const :tag "Warn and then loop around." warn) + (const :tag "Signal an error." error))) -(defun mc/cycle-backward (&optional error-if-no-previous-cursor) - (interactive "P") - (let ((prev-cursor (mc/prev-cursor-before-point))) - (cond - (prev-cursor - (mc/create-fake-cursor-at-point) - (mc/pop-state-from-overlay prev-cursor) - (recenter)) - (error-if-no-previous-cursor - (error "We're already at the first cursor")) - (t - (mc/cycle-forward t))))) +(defun mc/handle-loop-condition (error-message) + (ecase mc/cycle-looping-behaviour + (error (error error-message)) + (warn (message error-message)) + (continue nil))) + +(defun mc/cycle (next-cursor fallback-cursor loop-message) + (when (null next-cursor) + (mc/handle-loop-condition loop-message) + (setf next-cursor fallback-cursor)) + (mc/create-fake-cursor-at-point) + (mc/pop-state-from-overlay next-cursor) + (recenter)) + +(defun extreme (sequence predicate &optional key) + "Returns the most predicate-y element of sequence; equivalent +to (first (sort sequence text)). The extreme of the empty list is +always nil." + (let ((extreme (first sequence))) + (dolist (i (rest sequence)) + (when (funcall predicate + (funcall (or key 'identity) i) + (funcall (or key 'identity) extreme)) + (setf extreme i))) + extreme)) + +(defun mc/first-cursor-after (point) + "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." + (extreme (remove-if (lambda (cursor) + (< (mc/cursor-beg cursor) point)) + (mc/all-fake-cursors)) + '< 'mc/cursor-beg)) + +(defun mc/last-cursor-before (point) + "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." + (extreme (remove-if (lambda (cursor) + (> (mc/cursor-end cursor) point)) + (mc/all-fake-cursors)) + '> 'mc/cursor-end)) + +(defun mc/cycle-forward () + (interactive) + (mc/cycle (mc/next-cursor-after-point) + (mc/first-cursor-after (point-min)) + "We're already at the last cursor.")) + +(defun mc/cycle-backward () + (interactive) + (mc/cycle (mc/prev-cursor-before-point) + (mc/last-cursor-before (point-max)) + "We're already at the last cursor")) (define-key mc/keymap (kbd "C-v") 'mc/cycle-forward) (define-key mc/keymap (kbd "M-v") 'mc/cycle-backward) From a8b632386d3a59e944c7a44ad6e62f00296dba75 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Fri, 12 Oct 2012 16:27:39 +0200 Subject: [PATCH 08/12] Remove superfluous lambda. Caught by magnars (https://github.com/magnars/multiple-cursors.el/pull/23#commitcomment-1983191) --- multiple-cursors-core.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index b2576e9..3874231 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -50,8 +50,7 @@ (cons (cons 'apply (cons 'activate-cursor-for-undo (list id))) buffer-undo-list))))) (defun mc/all-fake-cursors (&optional start end) - (remove-if-not (lambda (overlay) - (mc/fake-cursor-p overlay)) + (remove-if-not 'mc/fake-cursor-p (overlays-in (or start (point-min)) (or end (point-max))))) From 19b1a83925ba3831e3db3b153dfaf886cdc30376 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Fri, 12 Oct 2012 16:51:01 +0200 Subject: [PATCH 09/12] Refactor mc/first-cursor-after and mc/last-cursor-before to not use extreme. Sometimes imperative code is more readable. Suggested by magnars (https://github.com/magnars/multiple-cursors.el/pull/23#commitcomment-1983268) --- mc-cycle-cursors.el | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index 8c3f1a9..9dea266 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -66,6 +66,24 @@ (warn (message error-message)) (continue nil))) +(defun mc/first-cursor-after (point) + "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." + (let* ((cursors (mc/all-fake-cursors)) + (cursors-after-point (remove-if (lambda (cursor) + (< (mc/cursor-beg cursor) point)) + cursors)) + (cursors-in-order (sort* cursors-after-point '< :key 'mc/cursor-beg))) + (first cursors-in-order))) + +(defun mc/last-cursor-before (point) + "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." + (let* ((cursors (mc/all-fake-cursors)) + (cursors-before-point (remove-if (lambda (cursor) + (> (mc/cursor-end cursor) point)) + cursors)) + (cursors-in-order (sort* cursors-before-point '> :key 'mc/cursor-end))) + (first cursors-in-order))) + (defun mc/cycle (next-cursor fallback-cursor loop-message) (when (null next-cursor) (mc/handle-loop-condition loop-message) @@ -74,32 +92,6 @@ (mc/pop-state-from-overlay next-cursor) (recenter)) -(defun extreme (sequence predicate &optional key) - "Returns the most predicate-y element of sequence; equivalent -to (first (sort sequence text)). The extreme of the empty list is -always nil." - (let ((extreme (first sequence))) - (dolist (i (rest sequence)) - (when (funcall predicate - (funcall (or key 'identity) i) - (funcall (or key 'identity) extreme)) - (setf extreme i))) - extreme)) - -(defun mc/first-cursor-after (point) - "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." - (extreme (remove-if (lambda (cursor) - (< (mc/cursor-beg cursor) point)) - (mc/all-fake-cursors)) - '< 'mc/cursor-beg)) - -(defun mc/last-cursor-before (point) - "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." - (extreme (remove-if (lambda (cursor) - (> (mc/cursor-end cursor) point)) - (mc/all-fake-cursors)) - '> 'mc/cursor-end)) - (defun mc/cycle-forward () (interactive) (mc/cycle (mc/next-cursor-after-point) From 038c9a7f03116f016a129981cdaa4094d89bedd8 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Fri, 12 Oct 2012 16:56:01 +0200 Subject: [PATCH 10/12] Added stop as a possible value for mc/cycle-looping-behaviour. Simply disables looping (no warning either). --- mc-cycle-cursors.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index 9dea266..3fe44bd 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -58,13 +58,15 @@ "What to do if asked to cycle beyond the last cursor or before the first cursor." :type '(radio (const :tag "Loop around to beginning/end of document." continue) (const :tag "Warn and then loop around." warn) - (const :tag "Signal an error." error))) + (const :tag "Signal an error." error) + (const :tag "Don't loop." stop))) (defun mc/handle-loop-condition (error-message) (ecase mc/cycle-looping-behaviour (error (error error-message)) (warn (message error-message)) - (continue nil))) + (continue 'continue) + (stop 'stop))) (defun mc/first-cursor-after (point) "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." @@ -84,9 +86,10 @@ (cursors-in-order (sort* cursors-before-point '> :key 'mc/cursor-end))) (first cursors-in-order))) -(defun mc/cycle (next-cursor fallback-cursor loop-message) +(defun* mc/cycle (next-cursor fallback-cursor loop-message) (when (null next-cursor) - (mc/handle-loop-condition loop-message) + (when (eql 'stop (mc/handle-loop-condition loop-message)) + (return-from mc/cycle nil)) (setf next-cursor fallback-cursor)) (mc/create-fake-cursor-at-point) (mc/pop-state-from-overlay next-cursor) From 1ec78e195f8cf9e0ee2a4e706269499f90dea263 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Fri, 12 Oct 2012 17:04:36 +0200 Subject: [PATCH 11/12] Don't let mc/mark-lines create 'double' cursors. Previously using mc/mark-lines in a fowards/backwards/forwards combination would cause multiple cursors to be placed at the same point of the same line. This is not useful behaviour. Noted while implementing magnars suggestion: https://github.com/magnars/multiple-cursors.el/pull/23#commitcomment-1983183 --- features/mark-more.feature | 19 +++++++++++++++++++ mc-mark-more.el | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/features/mark-more.feature b/features/mark-more.feature index c8cd3ff..8ca86f7 100644 --- a/features/mark-more.feature +++ b/features/mark-more.feature @@ -113,3 +113,22 @@ Feature: Marking multiple parts of the buffer _ccc """ + Scenario: Increasing number of cursors without an active region + When I insert: + """ + aaa + bbb + ccc + """ + And I go to the front of the word "bbb" + And I press "C->" + And I press "C-<" + And i press "C-f" + And I type "_" + Then I should have 3 cursors + And I should see: + """ + a_aa + b_bb + c_cc + """ diff --git a/mc-mark-more.el b/mc-mark-more.el index 8dd4bc6..7d722b0 100644 --- a/mc-mark-more.el +++ b/mc-mark-more.el @@ -145,8 +145,10 @@ With zero ARG, skip the last one and mark next." (dotimes (i num-lines) (mc/create-fake-cursor-at-point) (ecase direction - (forwards (next-line 1 nil)) - (backwards (previous-line 1 nil))))) + (forwards (loop do (next-line 1 nil) + while (mc/all-fake-cursors (point) (1+ (point))))) + (backwards (loop do (previous-line 1 nil) + while (mc/all-fake-cursors (point) (1+ (point)))))))) ;;;###autoload (defun mc/mark-next-lines (arg) From 2818d9e7ef2d55a404234ecdef8797b06f0520d2 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Fri, 12 Oct 2012 17:07:55 +0200 Subject: [PATCH 12/12] Rename mc/(first|last)-cursor-(before|after)-point to mention that they operate on fake cursors --- mc-cycle-cursors.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mc-cycle-cursors.el b/mc-cycle-cursors.el index 3fe44bd..46d7426 100644 --- a/mc-cycle-cursors.el +++ b/mc-cycle-cursors.el @@ -30,7 +30,7 @@ (eval-when-compile (require 'cl)) -(defun mc/next-cursor-after-point () +(defun mc/next-fake-cursor-after-point () (let ((pos (point)) (next-pos (point-max)) next) @@ -42,7 +42,7 @@ (setq next cursor)))) next)) -(defun mc/prev-cursor-before-point () +(defun mc/prev-fake-cursor-before-point () (let ((pos (point)) (prev-pos (point-min)) prev) @@ -68,7 +68,7 @@ (continue 'continue) (stop 'stop))) -(defun mc/first-cursor-after (point) +(defun mc/first-fake-cursor-after (point) "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." (let* ((cursors (mc/all-fake-cursors)) (cursors-after-point (remove-if (lambda (cursor) @@ -77,7 +77,7 @@ (cursors-in-order (sort* cursors-after-point '< :key 'mc/cursor-beg))) (first cursors-in-order))) -(defun mc/last-cursor-before (point) +(defun mc/last-fake-cursor-before (point) "Very similar to mc/furthest-cursor-before-point, but ignores (mark) and (point)." (let* ((cursors (mc/all-fake-cursors)) (cursors-before-point (remove-if (lambda (cursor) @@ -97,14 +97,14 @@ (defun mc/cycle-forward () (interactive) - (mc/cycle (mc/next-cursor-after-point) - (mc/first-cursor-after (point-min)) + (mc/cycle (mc/next-fake-cursor-after-point) + (mc/first-fake-cursor-after (point-min)) "We're already at the last cursor.")) (defun mc/cycle-backward () (interactive) - (mc/cycle (mc/prev-cursor-before-point) - (mc/last-cursor-before (point-max)) + (mc/cycle (mc/prev-fake-cursor-before-point) + (mc/last-fake-cursor-before (point-max)) "We're already at the last cursor")) (define-key mc/keymap (kbd "C-v") 'mc/cycle-forward)