Save and restore clipboard option, rather than hack around behavior

This commit is contained in:
Tim Pope 2007-02-11 18:23:19 +00:00
parent c85cef48ca
commit 8a2116a0c1

View File

@ -329,6 +329,7 @@ function! s:insert(...) " {{{1
return "" return ""
endif endif
"call inputsave() "call inputsave()
let cb_save = &clipboard
let reg_save = @@ let reg_save = @@
call setreg('"',"\r",'v') call setreg('"',"\r",'v')
call s:wrapreg('"',char,linemode) call s:wrapreg('"',char,linemode)
@ -342,6 +343,7 @@ function! s:insert(...) " {{{1
endif endif
call search('\r','bW') call search('\r','bW')
let @@ = reg_save let @@ = reg_save
let &clipboard = cb_save
return "\<Del>" return "\<Del>"
endfunction " }}}1 endfunction " }}}1
@ -376,6 +378,8 @@ function! s:dosurround(...) " {{{1
return s:beep() return s:beep()
endif endif
endif endif
let cb_save = &clipboard
set clipboard-=unnamed
let append = "" let append = ""
let original = getreg('"') let original = getreg('"')
let otype = getregtype('"') let otype = getregtype('"')
@ -386,6 +390,7 @@ function! s:dosurround(...) " {{{1
let okeeper = keeper " for reindent below let okeeper = keeper " for reindent below
if keeper == "" if keeper == ""
call setreg('"',original,otype) call setreg('"',original,otype)
let &clipboard = cb_save
return "" return ""
endif endif
let oldline = getline('.') let oldline = getline('.')
@ -446,6 +451,7 @@ function! s:dosurround(...) " {{{1
endif endif
call setreg('"',removed,regtype) call setreg('"',removed,regtype)
let s:lastdel = removed let s:lastdel = removed
let &clipboard = cb_save
endfunction " }}}1 endfunction " }}}1
function! s:changesurround() " {{{1 function! s:changesurround() " {{{1
@ -465,17 +471,13 @@ function! s:opfunc(type,...) " {{{1
if char == "" if char == ""
return s:beep() return s:beep()
endif endif
if &cb =~ 'unnamed' let reg = '"'
let reg = 's'
else
let reg = '"'
endif
let sel_save = &selection let sel_save = &selection
let &selection = "inclusive" let &selection = "inclusive"
let cb_save = &clipboard
set clipboard-=unnamed
let reg_save = getreg(reg) let reg_save = getreg(reg)
let reg_type = getregtype(reg) let reg_type = getregtype(reg)
let def_save = getreg('"')
let def_type = getregtype('"')
"call setreg(reg,"\n","c") "call setreg(reg,"\n","c")
let type = a:type let type = a:type
if a:type == "char" if a:type == "char"
@ -495,6 +497,7 @@ function! s:opfunc(type,...) " {{{1
endif endif
else else
let &selection = sel_save let &selection = sel_save
let &clipboard = cb_save
return s:beep() return s:beep()
endif endif
let keeper = getreg(reg) let keeper = getreg(reg)
@ -512,8 +515,8 @@ function! s:opfunc(type,...) " {{{1
call s:reindent() call s:reindent()
endif endif
call setreg(reg,reg_save,reg_type) call setreg(reg,reg_save,reg_type)
call setreg('"',def_save,def_type)
let &selection = sel_save let &selection = sel_save
let &clipboard = cb_save
endfunction endfunction
function! s:opfunc2(arg) function! s:opfunc2(arg)