From 4728a9dcbd769c7df11037d439085f2d58516341 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 17 Jan 2014 15:10:07 +0900 Subject: [PATCH 1/3] Modify condition for multi input find motion --- autoload/EasyMotion/command_line.vim | 8 ++-- plugin/EasyMotion.vim | 20 +++++----- t/easymotion_spec.vim | 60 ++++++++++++++-------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/autoload/EasyMotion/command_line.vim b/autoload/EasyMotion/command_line.vim index e0a24d9..46a2c88 100644 --- a/autoload/EasyMotion/command_line.vim +++ b/autoload/EasyMotion/command_line.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: autoload/EasyMotion/command_line.vim " AUTHOR: haya14busa -" Last Change: 14 Jan 2014. +" Last Change: 17 Jan 2014. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -42,12 +42,12 @@ endfunction " }}} function! EasyMotion#command_line#GetInput(num_strokes, ...) "{{{ let previous_input = a:0 == 1 ? a:1 : '' - let input = '' " repeat a:num_strokes times - let prompt_num = a:num_strokes < 50 ? a:num_strokes : '' + let prompt_num = a:num_strokes != -1 ? a:num_strokes : '' let prompt = prompt_num . g:EasyMotion_prompt - while EasyMotion#helper#strchars(input) < a:num_strokes + while EasyMotion#helper#strchars(input) < a:num_strokes || + \ a:num_strokes == -1 if g:EasyMotion_show_prompt call s:InputPrompt(prompt, input) endif diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 5fd3e40..83b507e 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -139,16 +139,16 @@ call s:find_motion_map_helper({ \ 'tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 0}, \ 'Tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 1}, \ - \ 'fn' : {'fnc': 'S' , 'cnt': 50, 'direction': 0}, - \ 'Fn' : {'fnc': 'S' , 'cnt': 50, 'direction': 1}, - \ 'sn' : {'fnc': 'S' , 'cnt': 50, 'direction': 2}, - \ 'tn' : {'fnc': 'T' , 'cnt': 50, 'direction': 0}, - \ 'Tn' : {'fnc': 'T' , 'cnt': 50, 'direction': 1}, - \ 'fln' : {'fnc': 'SL', 'cnt': 50, 'direction': 0}, - \ 'Fln' : {'fnc': 'SL', 'cnt': 50, 'direction': 1}, - \ 'sln' : {'fnc': 'SL', 'cnt': 50, 'direction': 2}, - \ 'tln' : {'fnc': 'TL', 'cnt': 50, 'direction': 0}, - \ 'Tln' : {'fnc': 'TL', 'cnt': 50, 'direction': 1}, + \ 'fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 0}, + \ 'Fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 1}, + \ 'sn' : {'fnc': 'S' , 'cnt': -1, 'direction': 2}, + \ 'tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 0}, + \ 'Tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 1}, + \ 'fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 0}, + \ 'Fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 1}, + \ 'sln' : {'fnc': 'SL', 'cnt': -1, 'direction': 2}, + \ 'tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 0}, + \ 'Tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 1}, \ }) "}}} diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index d14f3d1..3069394 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -122,45 +122,45 @@ describe 'Default settings' " Multi Char Find Motion: {{{ " sn - Expect maparg('(easymotion-sn)', 'n') ==# ':call EasyMotion#S(50,0,2)' - Expect maparg('(easymotion-sn)', 'o') ==# ':call EasyMotion#S(50,0,2)' - Expect maparg('(easymotion-sn)', 'v') ==# ':call EasyMotion#S(50,1,2)' + Expect maparg('(easymotion-sn)', 'n') ==# ':call EasyMotion#S(-1,0,2)' + Expect maparg('(easymotion-sn)', 'o') ==# ':call EasyMotion#S(-1,0,2)' + Expect maparg('(easymotion-sn)', 'v') ==# ':call EasyMotion#S(-1,1,2)' " fn - Expect maparg('(easymotion-fn)', 'n') ==# ':call EasyMotion#S(50,0,0)' - Expect maparg('(easymotion-fn)', 'o') ==# ':call EasyMotion#S(50,0,0)' - Expect maparg('(easymotion-fn)', 'v') ==# ':call EasyMotion#S(50,1,0)' + Expect maparg('(easymotion-fn)', 'n') ==# ':call EasyMotion#S(-1,0,0)' + Expect maparg('(easymotion-fn)', 'o') ==# ':call EasyMotion#S(-1,0,0)' + Expect maparg('(easymotion-fn)', 'v') ==# ':call EasyMotion#S(-1,1,0)' " Fn - Expect maparg('(easymotion-Fn)', 'n') ==# ':call EasyMotion#S(50,0,1)' - Expect maparg('(easymotion-Fn)', 'o') ==# ':call EasyMotion#S(50,0,1)' - Expect maparg('(easymotion-Fn)', 'v') ==# ':call EasyMotion#S(50,1,1)' + Expect maparg('(easymotion-Fn)', 'n') ==# ':call EasyMotion#S(-1,0,1)' + Expect maparg('(easymotion-Fn)', 'o') ==# ':call EasyMotion#S(-1,0,1)' + Expect maparg('(easymotion-Fn)', 'v') ==# ':call EasyMotion#S(-1,1,1)' " tn - Expect maparg('(easymotion-tn)', 'n') ==# ':call EasyMotion#T(50,0,0)' - Expect maparg('(easymotion-tn)', 'o') ==# ':call EasyMotion#T(50,0,0)' - Expect maparg('(easymotion-tn)', 'v') ==# ':call EasyMotion#T(50,1,0)' + Expect maparg('(easymotion-tn)', 'n') ==# ':call EasyMotion#T(-1,0,0)' + Expect maparg('(easymotion-tn)', 'o') ==# ':call EasyMotion#T(-1,0,0)' + Expect maparg('(easymotion-tn)', 'v') ==# ':call EasyMotion#T(-1,1,0)' " Tn - Expect maparg('(easymotion-Tn)', 'n') ==# ':call EasyMotion#T(50,0,1)' - Expect maparg('(easymotion-Tn)', 'o') ==# ':call EasyMotion#T(50,0,1)' - Expect maparg('(easymotion-Tn)', 'v') ==# ':call EasyMotion#T(50,1,1)' + Expect maparg('(easymotion-Tn)', 'n') ==# ':call EasyMotion#T(-1,0,1)' + Expect maparg('(easymotion-Tn)', 'o') ==# ':call EasyMotion#T(-1,0,1)' + Expect maparg('(easymotion-Tn)', 'v') ==# ':call EasyMotion#T(-1,1,1)' " sln - Expect maparg('(easymotion-sln)', 'n') ==# ':call EasyMotion#SL(50,0,2)' - Expect maparg('(easymotion-sln)', 'o') ==# ':call EasyMotion#SL(50,0,2)' - Expect maparg('(easymotion-sln)', 'v') ==# ':call EasyMotion#SL(50,1,2)' + Expect maparg('(easymotion-sln)', 'n') ==# ':call EasyMotion#SL(-1,0,2)' + Expect maparg('(easymotion-sln)', 'o') ==# ':call EasyMotion#SL(-1,0,2)' + Expect maparg('(easymotion-sln)', 'v') ==# ':call EasyMotion#SL(-1,1,2)' " fln - Expect maparg('(easymotion-fln)', 'n') ==# ':call EasyMotion#SL(50,0,0)' - Expect maparg('(easymotion-fln)', 'o') ==# ':call EasyMotion#SL(50,0,0)' - Expect maparg('(easymotion-fln)', 'v') ==# ':call EasyMotion#SL(50,1,0)' + Expect maparg('(easymotion-fln)', 'n') ==# ':call EasyMotion#SL(-1,0,0)' + Expect maparg('(easymotion-fln)', 'o') ==# ':call EasyMotion#SL(-1,0,0)' + Expect maparg('(easymotion-fln)', 'v') ==# ':call EasyMotion#SL(-1,1,0)' " Fln - Expect maparg('(easymotion-Fln)', 'n') ==# ':call EasyMotion#SL(50,0,1)' - Expect maparg('(easymotion-Fln)', 'o') ==# ':call EasyMotion#SL(50,0,1)' - Expect maparg('(easymotion-Fln)', 'v') ==# ':call EasyMotion#SL(50,1,1)' + Expect maparg('(easymotion-Fln)', 'n') ==# ':call EasyMotion#SL(-1,0,1)' + Expect maparg('(easymotion-Fln)', 'o') ==# ':call EasyMotion#SL(-1,0,1)' + Expect maparg('(easymotion-Fln)', 'v') ==# ':call EasyMotion#SL(-1,1,1)' " tln - Expect maparg('(easymotion-tln)', 'n') ==# ':call EasyMotion#TL(50,0,0)' - Expect maparg('(easymotion-tln)', 'o') ==# ':call EasyMotion#TL(50,0,0)' - Expect maparg('(easymotion-tln)', 'v') ==# ':call EasyMotion#TL(50,1,0)' + Expect maparg('(easymotion-tln)', 'n') ==# ':call EasyMotion#TL(-1,0,0)' + Expect maparg('(easymotion-tln)', 'o') ==# ':call EasyMotion#TL(-1,0,0)' + Expect maparg('(easymotion-tln)', 'v') ==# ':call EasyMotion#TL(-1,1,0)' " Tln - Expect maparg('(easymotion-Tln)', 'n') ==# ':call EasyMotion#TL(50,0,1)' - Expect maparg('(easymotion-Tln)', 'o') ==# ':call EasyMotion#TL(50,0,1)' - Expect maparg('(easymotion-Tln)', 'v') ==# ':call EasyMotion#TL(50,1,1)' + Expect maparg('(easymotion-Tln)', 'n') ==# ':call EasyMotion#TL(-1,0,1)' + Expect maparg('(easymotion-Tln)', 'o') ==# ':call EasyMotion#TL(-1,0,1)' + Expect maparg('(easymotion-Tln)', 'v') ==# ':call EasyMotion#TL(-1,1,1)' "}}} end From 9c0183faa70cee1604d69f204be731f5959e555a Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 17 Jan 2014 15:12:33 +0900 Subject: [PATCH 2/3] Modify prompt message and make it more configurable --- autoload/EasyMotion/command_line.vim | 24 ++++++++++++++++++++---- plugin/EasyMotion.vim | 3 ++- t/easymotion_spec.vim | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/autoload/EasyMotion/command_line.vim b/autoload/EasyMotion/command_line.vim index 46a2c88..fcb534c 100644 --- a/autoload/EasyMotion/command_line.vim +++ b/autoload/EasyMotion/command_line.vim @@ -40,14 +40,30 @@ function! s:Cancell() " {{{ return '' endfunction " }}} +function! s:getPromptMessage(num_strokes) + if a:num_strokes == 1 + let prompt = substitute( + \ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'), + \ '(s)', '', 'g') + elseif a:num_strokes == -1 + let prompt = substitute( + \ substitute(g:EasyMotion_prompt, '{n}\s\{0,1}', '', 'g'), + \ '(s)', 's', 'g') + else + let prompt = substitute( + \ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'), + \ '(s)', 's', 'g') + endif + return prompt +endfunction + function! EasyMotion#command_line#GetInput(num_strokes, ...) "{{{ let previous_input = a:0 == 1 ? a:1 : '' let input = '' - " repeat a:num_strokes times - let prompt_num = a:num_strokes != -1 ? a:num_strokes : '' - let prompt = prompt_num . g:EasyMotion_prompt + let prompt = s:getPromptMessage(a:num_strokes) + while EasyMotion#helper#strchars(input) < a:num_strokes || - \ a:num_strokes == -1 + \ a:num_strokes == -1 if g:EasyMotion_show_prompt call s:InputPrompt(prompt, input) endif diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 83b507e..5ee74be 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -32,7 +32,8 @@ let g:EasyMotion_use_migemo = get(g: , 'EasyMotion_use_migemo' , let g:EasyMotion_use_upper = get(g: , 'EasyMotion_use_upper' , 0) let g:EasyMotion_enter_jump_first = get(g: , 'EasyMotion_enter_jump_first' , 0) let g:EasyMotion_show_prompt = get(g: , 'EasyMotion_show_prompt' , 1) -let g:EasyMotion_prompt = get(g: , 'EasyMotion_prompt' , '> ') +let g:EasyMotion_prompt = + \ get(g: , 'EasyMotion_prompt' , 'Search for {n} character(s): ') let g:EasyMotion_command_line_key_mappings = \ get(g: , 'EasyMotion_command_line_key_mappings' , {}) diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index 3069394..8b96bfc 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -425,7 +425,7 @@ describe 'Default settings' Expect g:EasyMotion_use_upper ==# 0 Expect g:EasyMotion_enter_jump_first ==# 0 Expect g:EasyMotion_show_prompt ==# 1 - Expect g:EasyMotion_prompt ==# '> ' + Expect g:EasyMotion_prompt ==# 'Search for {n} character(s): ' Expect g:EasyMotion_command_line_key_mappings ==# {} " }}} From 916e51e2221aa17d2a214091d504e77510b201bb Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 17 Jan 2014 15:27:36 +0900 Subject: [PATCH 3/3] Update doc: prompt message --- doc/easymotion.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/easymotion.txt b/doc/easymotion.txt index e4e9e4a..be42d49 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -1,4 +1,4 @@ -*easymotion.txt* Version 2.0 Last change:16 Jan 2014. +*easymotion.txt* Version 2.0 Last change:17 Jan 2014. ______ __ ___ __ _ @@ -36,6 +36,7 @@ CONTENTS *easymotion-contents* 4.11.1 Select Line ............. |easymotion-select-line| 4.11.2 Select Phrase ........... |easymotion-select-phrase| 4.12 EasyMotion_enter_jump_first ... |EasyMotion_enter_jump_first| + 4.13 EasyMotion_prompt ............. |EasyMotion_prompt| 5. License ............................ |easymotion-license| 6. Known bugs ......................... |easymotion-known-bugs| 7. Contributing ....................... |easymotion-contributing| @@ -854,6 +855,26 @@ Example: Default: 0 +4.13 Customize command line prompt *EasyMotion_prompt* + *g:EasyMotion_prompt* + + You can customize command line prompt message in find motion. + `{n}` is how many characters you type, and if {n} == 1 `(s)` will be + ignored. + +Sample: +> + let g:EasyMotion_prompt = '{n}>>> ' +< +Default: +> + let g:EasyMotion_prompt = 'Search for {n} character(s): ' +< + This message will be: + |(easymotion-s)| -> 'Search for 1 character: ' + |(easymotion-s2)| -> 'Search for 2 characters: ' + |(easymotion-sn)| -> 'Search for characters: ' + ============================================================================== 5. License *easymotion-license*