From be149f9121840561b7a2df17a7a3b1838a1b1f4c Mon Sep 17 00:00:00 2001 From: Jules Tamagnan Date: Mon, 23 May 2016 15:43:08 -0400 Subject: [PATCH] Create customizable mc/insert-numbers-default This commit fulfills the feature request from #248 and creates a customizable variable called mc/insert-numbers-default which is the starting value for mc/insert-numbers if no arg is passed --- features/insert-numbers.feature | 21 +++++++++++++++++++++ mc-separate-operations.el | 11 +++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/features/insert-numbers.feature b/features/insert-numbers.feature index 59db91f..191150e 100644 --- a/features/insert-numbers.feature +++ b/features/insert-numbers.feature @@ -17,3 +17,24 @@ Feature: Insert increasing numbers When I press "C-u H-0" And I press "SPC" Then I should see "This 4 text contains the word 5 text thrice (6 text)" + + Scenario: Three cursors, 0-1-2, default + Given I have cursors at "text" in "This text contains the word text thrice (text)" + When I set mc/insert-numbers-default to 1 + And I press "H-0" + And I press "SPC" + Then I should see "This 1 text contains the word 2 text thrice (3 text)" + + Scenario: Three cursors, 9-10-11, default + Given I have cursors at "text" in "This text contains the word text thrice (text)" + When I set mc/insert-numbers-default to 1 + And I press "C-9 H-0" + And I press "SPC" + Then I should see "This 9 text contains the word 10 text thrice (11 text)" + + Scenario: Three cursors, 9-10-11, default + Given I have cursors at "text" in "This text contains the word text thrice (text)" + When I set mc/insert-numbers-default to 1 + And I press "C-u H-0" + And I press "SPC" + Then I should see "This 4 text contains the word 5 text thrice (6 text)" diff --git a/mc-separate-operations.el b/mc-separate-operations.el index ca6e8d8..ca10775 100644 --- a/mc-separate-operations.el +++ b/mc-separate-operations.el @@ -31,13 +31,20 @@ ;;;###autoload (defun mc/insert-numbers (arg) - "Insert increasing numbers for each cursor, starting at 0 or ARG." + "Insert increasing numbers for each cursor, starting at +`mc/insert-numbers-default' or ARG." (interactive "P") (setq mc--insert-numbers-number (or (and arg (prefix-numeric-value arg)) - 0)) + mc/insert-numbers-default)) (mc/for-each-cursor-ordered (mc/execute-command-for-fake-cursor 'mc--insert-number-and-increase cursor))) +(defcustom mc/insert-numbers-default 0 + "The default number at which to start counting for +`mc/insert-numbers'" + :type 'integer + :group 'multiple-cursors) + (defvar mc--insert-numbers-number 0) (defun mc--insert-number-and-increase ()