From 2f9147321bbfb794e7e0d9706d937ed2e0b69678 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 26 Jan 2014 17:25:11 +0900 Subject: [PATCH] Move some should_use_ function to helper --- autoload/EasyMotion.vim | 17 +++++------------ autoload/EasyMotion/command_line.vim | 12 ++---------- autoload/EasyMotion/helper.vim | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 0d650a6..e87e1bb 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -1,7 +1,7 @@ " EasyMotion - Vim motions on speed! " " Author: haya14busa -" Last Change: 25 Jan 2014. +" Last Change: 26 Jan 2014. " Source: https://github.com/haya14busa/vim-easymotion " " Original Author: Kim Silkebækken @@ -603,7 +603,7 @@ function! s:convertRegep(input) "{{{ let re = s:convertSmartsign(re, a:input) endif - let case_flag = s:should_use_smartcase(a:input) ? '\c' : '\C' + let case_flag = EasyMotion#helper#should_use_smartcase(a:input) ? '\c' : '\C' let re = case_flag . re return re endfunction "}}} @@ -662,7 +662,7 @@ function! s:should_use_migemo(char) "{{{ " Skip folded line and check if text include multibyte haracters for line in range(first_line, end_line) - if s:is_folded(line) + if EasyMotion#helper#is_folded(line) continue endif @@ -756,13 +756,6 @@ function! s:GetVisualStartPosition(c_pos, v_start, v_end, search_direction) "{{{ endif endfunction "}}} " -- Others ------------------------------ -function! s:is_folded(line) "{{{ - " Return false if g:EasyMotion_skipfoldedline == 1 - " and line is start of folded lines - return foldclosed(a:line) != -1 && - \ (g:EasyMotion_skipfoldedline == 1 || - \ a:line != foldclosed(a:line)) -endfunction "}}} function! s:is_cmdwin() "{{{ return bufname('%') ==# '[Command Line]' endfunction "}}} @@ -1337,7 +1330,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ endif " Skip folded lines {{{ - if s:is_folded(pos[0]) + if EasyMotion#helper#is_folded(pos[0]) if search_direction ==# 'b' keepjumps call cursor(foldclosed(pos[0]-1), 0) else @@ -1379,7 +1372,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ endif " Skip folded lines {{{ - if s:is_folded(pos[0]) + if EasyMotion#helper#is_folded(pos[0]) " Always forward keepjumps call cursor(foldclosedend(pos[0]+1), 0) continue diff --git a/autoload/EasyMotion/command_line.vim b/autoload/EasyMotion/command_line.vim index c887a75..abd49eb 100644 --- a/autoload/EasyMotion/command_line.vim +++ b/autoload/EasyMotion/command_line.vim @@ -2,7 +2,7 @@ " FILE: autoload/EasyMotion/command_line.vim " AUTHOR: haya14busa " Reference: https://github.com/osyo-manga/vim-over -" Last Change: 24 Jan 2014. +" Last Change: 26 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 @@ -70,14 +70,6 @@ endfunction "}}} function! s:after_input() "{{{ call EasyMotion#highlight#delete_highlight() endfunction "}}} -function! s:should_use_smartcase(input) "{{{ - " TODO: - if g:EasyMotion_smartcase == 0 - return 0 - endif - " return 1 if input didn't match upporcase letter - return match(a:input, '\u') == -1 -endfunction "}}} function! s:offscreen_search(re) "{{{ " First: search within visible screen range call s:adjust_screen() @@ -221,7 +213,7 @@ function! EasyMotion#command_line#GetInput(num_strokes, prev, direction) "{{{ " Incremental routine {{{ if a:num_strokes == -1 let re = input - let case_flag = s:should_use_smartcase(input) ? '\c' : '\C' + let case_flag = EasyMotion#helper#should_use_smartcase(re) ? '\c' : '\C' let re .= case_flag if g:EasyMotion_inc_highlight "{{{ call EasyMotion#highlight#delete_highlight('EasyMotionIncSearch') diff --git a/autoload/EasyMotion/helper.vim b/autoload/EasyMotion/helper.vim index 6d8d003..4c06be4 100644 --- a/autoload/EasyMotion/helper.vim +++ b/autoload/EasyMotion/helper.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: autoload/EasyMotion/helper.vim " AUTHOR: haya14busa -" Last Change: 17 Jan 2014. +" Last Change: 25 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 @@ -55,6 +55,21 @@ function! EasyMotion#helper#is_greater_coords(coords1, coords2) "{{{ endif endfunction "}}} +function! EasyMotion#helper#is_folded(line) "{{{ + " Return false if g:EasyMotion_skipfoldedline == 1 + " and line is start of folded lines + return foldclosed(a:line) != -1 && + \ (g:EasyMotion_skipfoldedline == 1 || + \ a:line != foldclosed(a:line)) +endfunction "}}} +function! EasyMotion#helper#should_use_smartcase(input) "{{{ + if g:EasyMotion_smartcase == 0 + return 0 + endif + " return 1 if input didn't match uppercase letter + return match(a:input, '\u') == -1 +endfunction "}}} + " Migemo {{{ function! EasyMotion#helper#load_migemo_dict() "{{{ let enc = &l:encoding