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
This commit is contained in:
Jules Tamagnan 2016-05-23 15:43:08 -04:00
parent a508978cd9
commit be149f9121
2 changed files with 30 additions and 2 deletions

View File

@ -17,3 +17,24 @@ Feature: Insert increasing numbers
When I press "C-u H-0" When I press "C-u H-0"
And I press "SPC" And I press "SPC"
Then I should see "This 4 text contains the word 5 text thrice (6 text)" 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)"

View File

@ -31,13 +31,20 @@
;;;###autoload ;;;###autoload
(defun mc/insert-numbers (arg) (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") (interactive "P")
(setq mc--insert-numbers-number (or (and arg (prefix-numeric-value arg)) (setq mc--insert-numbers-number (or (and arg (prefix-numeric-value arg))
0)) mc/insert-numbers-default))
(mc/for-each-cursor-ordered (mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'mc--insert-number-and-increase cursor))) (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) (defvar mc--insert-numbers-number 0)
(defun mc--insert-number-and-increase () (defun mc--insert-number-and-increase ()