Show
Ignore:
Timestamp:
10/02/07 16:12:51 (16 months ago)
Author:
kana
Message:

lang/vim/surround:
* Revise the code layout.
* Add new header with modification notes.
* Set g:loaded_surround at the last for some error cases.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/vim/surround/trunk/plugin/surround.vim

    r336 r338  
     1" surround.vim - Surrounding text objects 
     2" Author: Tim Pope <vimNOSPAM@tpope.info> 
     3" ModifiedBy: kana <http://nicht.s8.xrea.com> 
     4" BasedOn: Id: surround.vim,v 1.26 2007-07-31 14:20:47 tpope Exp 
     5" License: same as the original one, i.e., same as Vim itself. 
     6" $Id$  "{{{1 
     7" Original Header  "{{{2 
     8" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    19" surround.vim - Surroundings 
    210" Author:       Tim Pope <vimNOSPAM@tpope.info> 
     
    1018" 
    1119" Licensed under the same terms as Vim itself. 
    12  
    13 " ============================================================================ 
     20" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     21" "}}}2 
    1422 
    1523" Exit quickly when: 
     
    1927    finish 
    2028endif 
    21 let g:loaded_surround = 1 
    2229 
    2330let s:cpo_save = &cpo 
    2431set cpo&vim 
    2532 
    26 " Input functions {{{1 
     33 
     34 
     35 
     36" Implementation  "{{{1 
     37" Input functions  "{{{2 
    2738 
    2839function! s:getchar() 
     
    7283endfunction 
    7384 
    74 " }}}1 
    75  
    76 " Wrapping functions {{{1 
     85 
     86" Wrapping functions  "{{{2 
    7787 
    7888function! s:extractbefore(str) 
     
    330340    call setreg(a:reg,new,type) 
    331341endfunction 
    332 " }}}1 
    333  
    334 function! s:insert(...) " {{{1 
     342 
     343 
     344function! s:insert(...)  "{{{2 
    335345    " Optional argument causes the result to appear on 3 lines, not 1 
    336346    "call inputsave() 
     
    378388    let &clipboard = cb_save 
    379389    return "\<Del>" 
    380 endfunction " }}}1 
    381  
    382 function! s:reindent() " {{{1 
     390endfunction 
     391 
     392 
     393function! s:reindent()  "{{{2 
    383394    if exists("b:surround_indent") ? b:surround_indent : (exists("g:surround_indent") && g:surround_indent) 
    384395        silent norm! '[='] 
    385396    endif 
    386 endfunction " }}}1 
    387  
    388 function! s:dosurround(...) "{{{1 
     397endfunction 
     398 
     399 
     400function! s:dosurround(...)  "{{{2 
    389401    " ([target-surrounding-object-char, [new-surrounding-object-char]]) 
    390     " adjust arguments  "{{{2 
     402    " adjust arguments  "{{{3 
    391403    let scount = v:count1 
    392404    let char = (a:0 ? a:1 : s:inputtarget()) 
     
    414426    endif 
    415427 
    416     " save and initialize some values  "{{{2 
     428    " save and initialize some values  "{{{3 
    417429    let cb_save = &clipboard 
    418430    set clipboard-=unnamed 
     
    422434    call setreg('"',"") 
    423435 
    424     " move the target text range into @@, then delete surroudings  "{{{2 
     436    " move the target text range into @@, then delete surroudings  "{{{3 
    425437    let strcount = (scount == 1 ? "" : scount) 
    426438    let user_defined_object = s:get_user_defined_object(char) 
     
    499511    endif 
    500512 
    501     " surround @@ new objects  "{{{2 
     513    " surround @@ new objects  "{{{3 
    502514    call setreg('"',keeper,regtype) 
    503515    if newchar != "" 
     
    505517    endif 
    506518 
    507     " put the result into the original position, then reindent  "{{{2 
     519    " put the result into the original position, then reindent  "{{{3 
    508520    silent exe 'norm! ""'.pcmd.'`[' 
    509521    if removed =~ '\n' || okeeper =~ '\n' || getreg('"') =~ '\n' 
     
    515527    endif 
    516528 
    517     " restore the original value, set some values for later use  "{{{2 
     529    " restore the original value, set some values for later use  "{{{3 
    518530    call setreg('"',removed,regtype) 
    519531    let s:lastdel = removed 
    520532    let &clipboard = cb_save 
    521 endfunction " }}}1 
    522  
    523 function! s:changesurround() " {{{1 
     533endfunction 
     534 
     535 
     536function! s:changesurround()  "{{{2 
    524537    let a = s:inputtarget() 
    525538    if a == "" 
     
    531544    endif 
    532545    call s:dosurround(a,b) 
    533 endfunction " }}}1 
    534  
    535 function! s:opfunc(type,...) " {{{1 
     546endfunction 
     547 
     548 
     549function! s:opfunc(type,...)  "{{{2 
    536550    let char = s:inputreplacement() 
    537551    if char == "" 
     
    588602function! s:opfunc2(arg) 
    589603    call s:opfunc(a:arg,1) 
    590 endfunction " }}}1 
    591  
    592 function! s:closematch(str) " {{{1 
     604endfunction 
     605 
     606 
     607function! s:closematch(str)  "{{{2 
    593608    " Close an open (, {, [, or < on the command line. 
    594609    let tail = matchstr(a:str,'.[^\[\](){}<>]*$') 
     
    604619        return "" 
    605620    endif 
    606 endfunction " }}}1 
     621endfunction 
    607622  
    608 " Misc. functions  "{{{1 
     623 
     624" Misc. functions  "{{{2 
     625 
    609626function! s:search_literally(pattern, flags) 
    610627    return search(s:literalize_pattern(a:pattern), a:flags) 
     
    634651    endif 
    635652endfunction 
    636 "}}}1 
     653 
     654 
     655 
     656 
     657" Key Mappings  "{{{1 
    637658 
    638659nnoremap <silent> <Plug>Dsurround  :<C-U>call <SID>dosurround(<SID>inputtarget())<CR> 
     
    679700endif 
    680701 
     702 
     703 
     704 
     705" Misc.  "{{{1 
     706 
    681707let &cpo = s:cpo_save 
    682708 
     709let g:loaded_surround = 1 
     710 
     711 
     712 
     713 
     714" __END__  "{{{1 
    683715" vim:set ft=vim sw=4 sts=4 et: