Merge branch 'handle/scrolloff' into master

This commit is contained in:
haya14busa 2014-02-21 18:50:21 +09:00
commit 0a35207598
3 changed files with 44 additions and 38 deletions

View File

@ -340,44 +340,25 @@ function! s:Prompt(message) " {{{
echohl None
endfunction " }}}
" -- Save & Restore values ---------------
function! s:VarReset(var, ...) " {{{
if ! exists('s:var_reset')
let s:var_reset = {}
endif
if a:0 == 0 && has_key(s:var_reset, a:var)
" Reset var to original value
" setbufbar( or bufname): '' or '%' can be used for the current buffer
call setbufvar("", a:var, s:var_reset[a:var])
elseif a:0 == 1
" Save original value and set new var value
let new_value = a:0 == 1 ? a:1 : ''
" Store original value
let s:var_reset[a:var] = getbufvar("", a:var)
" Set new var value
call setbufvar("", a:var, new_value)
endif
endfunction " }}}
function! s:SaveValue() "{{{
call s:VarReset('&scrolloff', 0)
call s:VarReset('&modified', 0)
call s:VarReset('&modifiable', 1)
call s:VarReset('&readonly', 0)
call s:VarReset('&spell', 0)
call s:VarReset('&virtualedit', '')
call s:VarReset('&foldmethod', 'manual')
if ! s:current.is_search
call EasyMotion#helper#VarReset('&scrolloff', 0)
endif
call EasyMotion#helper#VarReset('&modified', 0)
call EasyMotion#helper#VarReset('&modifiable', 1)
call EasyMotion#helper#VarReset('&readonly', 0)
call EasyMotion#helper#VarReset('&spell', 0)
call EasyMotion#helper#VarReset('&virtualedit', '')
call EasyMotion#helper#VarReset('&foldmethod', 'manual')
endfunction "}}}
function! s:RestoreValue() "{{{
call s:VarReset('&scrolloff')
call s:VarReset('&modified')
call s:VarReset('&modifiable')
call s:VarReset('&readonly')
call s:VarReset('&spell')
call s:VarReset('&virtualedit')
call s:VarReset('&foldmethod')
call EasyMotion#helper#VarReset('&scrolloff')
call EasyMotion#helper#VarReset('&modified')
call EasyMotion#helper#VarReset('&modifiable')
call EasyMotion#helper#VarReset('&readonly')
call EasyMotion#helper#VarReset('&spell')
call EasyMotion#helper#VarReset('&virtualedit')
call EasyMotion#helper#VarReset('&foldmethod')
endfunction "}}}
function! s:turn_off_hl_error() "{{{
let s:error_hl = EasyMotion#highlight#capture('Error')

View File

@ -2,7 +2,7 @@
" FILE: autoload/EasyMotion/command_line.vim
" AUTHOR: haya14busa
" Reference: https://github.com/osyo-manga/vim-over
" Last Change: 17 Feb 2014.
" Last Change: 21 Feb 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
@ -129,6 +129,7 @@ endfunction
function! s:search.on_enter(cmdline) "{{{
if s:num_strokes == -1
call EasyMotion#highlight#delete_highlight()
call EasyMotion#helper#VarReset('&scrolloff', 0)
if g:EasyMotion_do_shade
call EasyMotion#highlight#add_highlight('\_.*',
\ g:EasyMotion_hl_group_shade)
@ -138,7 +139,9 @@ function! s:search.on_enter(cmdline) "{{{
endif
endfunction "}}}
function! s:search.on_leave(cmdline) "{{{
if s:num_strokes == -1
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_search)
endif
endfunction "}}}
function! s:search.on_char(cmdline) "{{{
if s:num_strokes == -1
@ -192,6 +195,7 @@ endfunction "}}}
" Helper:
function! s:Cancell() " {{{
call EasyMotion#highlight#delete_highlight()
call EasyMotion#helper#VarReset('&scrolloff')
keepjumps call setpos('.', s:save_orig_pos)
echo 'EasyMotion: Cancelled'
return ''

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: autoload/EasyMotion/helper.vim
" AUTHOR: haya14busa
" Last Change: 13 Feb 2014.
" Last Change: 16 Feb 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
@ -98,6 +98,27 @@ function! EasyMotion#helper#silent_feedkeys(expr, name, ...) "{{{
call feedkeys(printf("\<Plug>(%s)", name))
endif
endfunction "}}}
function! EasyMotion#helper#VarReset(var, ...) "{{{
if ! exists('s:var_reset')
let s:var_reset = {}
endif
if a:0 == 0 && has_key(s:var_reset, a:var)
" Reset var to original value
" setbufbar( or bufname): '' or '%' can be used for the current buffer
call setbufvar("", a:var, s:var_reset[a:var])
elseif a:0 == 1
" Save original value and set new var value
let new_value = a:0 == 1 ? a:1 : ''
" Store original value
let s:var_reset[a:var] = getbufvar("", a:var)
" Set new var value
call setbufvar("", a:var, new_value)
endif
endfunction "}}}
" Migemo {{{
function! EasyMotion#helper#load_migemo_dict() "{{{