Changeset 3577

Show
Ignore:
Timestamp:
12/26/07 02:52:57 (5 years ago)
Author:
kana
Message:

dotfiles/vim/kana:
* Merge the following changes from my local repository.

r1162@colinux: kana | 2007-12-25 06:20:22 +0900
vim/dot.vimrc:

  • s:KeysToInsertOneCharacter(): Add missing 'echohl None' to restore the
    highlight for :echo.

r1163@colinux: kana | 2007-12-26 01:27:46 +0900
vim/dot.vim/doc/scratch.txt:

  • BUGS: Improve the sentence on :edit problem.

r1164@colinux: kana | 2007-12-26 02:15:06 +0900
vim/dot.vim/autoload/scratch.vim:

  • scratch#evaluate_linewise(), scratch#evaluate():
    New arg adjust_cursorp.
    Update all callers.
    Update documents.

r1165@colinux: kana | 2007-12-26 02:30:38 +0900
vim/dot.vim/plugin/scratch.vim:

  • :ScratchEvaluate?: Add [!] to control cursor adjustment.
  • <Plug>(scratch-evaluate!): New.
  • Rename the {lhs} of all mappings.
    Update all users.

r1166@colinux: kana | 2007-12-26 02:40:19 +0900
vim/dot.vim/doc/scratch.txt:

  • BUGS: Update some items.
Location:
dotfiles/vim/kana
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • dotfiles/vim/kana/dot.vim/autoload/scratch.vim

    r3550 r3577  
    8585 
    8686 
    87 function! scratch#evaluate_linewise(line1, line2)  "{{{2 
     87function! scratch#evaluate_linewise(line1, line2, adjust_cursorp)  "{{{2 
    8888  let bufnr = bufnr('') 
    8989  call scratch#evaluate([bufnr, a:line1, 1, 0], 
    90      \                  [bufnr, a:line2, len(getline(a:line2)), 0]) 
     90     \                  [bufnr, a:line2, len(getline(a:line2)), 0], 
     91     \                  a:adjust_cursorp) 
    9192endfunction 
    9293 
     
    9495 
    9596 
    96 function! scratch#evaluate(range_head, range_tail)  "{{{2 
     97function! scratch#evaluate(range_head, range_tail, adjust_cursorp)  "{{{2 
     98  " Yank the script. 
     99  let original_pos = getpos('.') 
    97100  let original_reg_a = @a 
    98   let original_pos = getpos('.') 
    99101    call setpos('.', a:range_head) 
    100102    normal! v 
     
    102104    silent normal! "ay 
    103105    let script = @a 
    104   call setpos('.', original_pos) 
    105106  let @a = original_reg_a 
    106107 
     108  " Evaluate it. 
    107109  execute script 
     110 
     111  if a:adjust_cursorp 
     112    " Move to the next line of the script (add new line if necessary). 
     113    call setpos('.', a:range_tail) 
     114    if line('.') == line('$') 
     115      put ='' 
     116    else 
     117      normal! + 
     118    endif 
     119  else 
     120    call setpos('.', original_pos) 
     121  endif 
    108122endfunction 
    109123 
  • dotfiles/vim/kana/dot.vim/doc/scratch.txt

    r3550 r3577  
    5454        Close a window that shows the scratch buffer if able. 
    5555 
    56 :[range]ScratchEvaluate                                 *:ScratchEvaluate* 
    57         Evaluate/Execute the [range] as a Vim script. 
     56:[range]ScratchEvaluate[!]                              *:ScratchEvaluate* 
     57        Evaluate the [range] as a Vim script. 
    5858        The default [range] is the current line. 
     59        Without [!], the cursor will be moved to the next line of the script 
     60        after evaluating.  If there is no line to move, new blank line will be 
     61        appended then the cursor will be moved to the new line. 
     62        With [!], such adjustment will not be done. 
    5963 
    6064 
     
    7074        The return value is not defined. 
    7175 
    72 scratch#evaluate_linewise({line1}, {line2})       *scratch#evaluate_linewise()* 
     76                                                  *scratch#evaluate_linewise()* 
     77scratch#evaluate_linewise({line1}, {line2}, {adjust-cursorp}) 
    7378        Function version of |:ScratchEvaluate|. 
     79        If {adjust-cursorp} is true, the cursor position will be adjusted as 
     80        same as |:ScratchEvaluate|.  If {adjust-cursorp} is false, such 
     81        adjustment will not be done. 
    7482        The return value is not defined. 
    7583 
    76 scratch#evaluate({pos1}, {pos2})                        *scratch#evaluate()* 
     84scratch#evaluate({pos1}, {pos2}, {adjust-cursorp})      *scratch#evaluate()* 
    7785        Same as |scratch#evaluate_linewise()|, but this takes the range of the 
    7886        script to be evaluated as {pos1} and {pos2}, which are same as the 
     
    8694GLOBAL MAPPINGS ~ 
    8795 
    88 <Plug>scratch-open                                      *<Plug>scratch-open* 
     96<Plug>(scratch-open)                                    *<Plug>(scratch-open)* 
    8997        Do |:ScratchOpen|. 
    9098 
    91 <Plug>scratch-close                                     *<Plug>scratch-close* 
     99<Plug>(scratch-close)                                   *<Plug>(scratch-close)* 
    92100        Do |:ScratchClose|. 
    93101 
    94 <Plug>scratch-evaluate                                *<Plug>scratch-evaluate* 
    95         Do |:ScratchEvaluate|. 
     102<Plug>(scratch-evaluate)                             *<Plug>(scratch-evaluate)* 
     103        Do |:ScratchEvaluate| without [!]. 
     104 
     105<Plug>(scratch-evaluate!)                           *<Plug>(scratch-evaluate!)* 
     106        Do |:ScratchEvaluate| with [!]. 
    96107 
    97108SCRATCH BUFFER-LOCAL MAPPINGS ~ 
     
    158169BUGS                                            *scratch-bugs* 
    159170 
    160 - When |:edit| is executed on the scratch buffer, the content of the scratch 
    161   buffer will be cleared. 
     171- Don't do |:edit|, |:bunload| or |:bdelete| on the scratch buffer.  The 
     172  content of the scratch buffer and/or other information (e.g., mappings) will 
     173  be cleared. 
     174  If you did it accidentally, do |:bwipeout| then |:ScratchOpen| to recreate 
     175  the scratch buffer. 
    162176 
    163177- |:ScratchOpen| - To create the scratch buffer, the current buffer will be 
    164   hidden temporary. 
     178  hidden temporary.  This behavior may cause some problems. 
    165179 
    166 - |:ScratchEvaluate| - Cursor adjustment is not good. 
    167  
    168 - |:ScratchEvaluate| - Should this be able to evaluate any programming 
    169   language other than Vim script? 
     180- |:ScratchEvaluate| - Is it useful to evaluate any programming language other 
     181  than Vim script? 
    170182 
    171183 
  • dotfiles/vim/kana/dot.vim/plugin/scratch.vim

    r3550 r3577  
    2020command! -bar -nargs=0 ScratchOpen  call scratch#open() 
    2121command! -bar -nargs=0 ScratchClose  call scratch#close() 
    22 command! -bar -nargs=0 -range ScratchEvaluate 
    23       \ call scratch#evaluate_linewise(<line1>, <line2>) 
     22command! -bang -bar -nargs=0 -range ScratchEvaluate 
     23      \ call scratch#evaluate_linewise(<line1>, <line2>, '<bang>' != '!') 
    2424 
    2525 
    26 noremap <silent> <Plug>scratch-open  :<C-u>ScratchOpen<Return> 
    27 noremap <silent> <Plug>scratch-close  :<C-u>ScratchClose<Return> 
    28 noremap <silent> <Plug>scratch-evaluate  :ScratchEvaluate<Return> 
     26noremap <silent> <Plug>(scratch-open)  :<C-u>ScratchOpen<Return> 
     27noremap <silent> <Plug>(scratch-close)  :<C-u>ScratchClose<Return> 
     28noremap <silent> <Plug>(scratch-evaluate)  :ScratchEvaluate<Return> 
     29noremap <silent> <Plug>(scratch-evaluate!)  :ScratchEvaluate!<Return> 
    2930 
    3031 
  • dotfiles/vim/kana/dot.vimrc

    r3550 r3577  
    400400  echohl ModeMsg 
    401401  echo '-- INSERT (one char) --' 
     402  echohl None 
    402403  return nr2char(getchar()) . "\<Esc>" 
    403404endfunction 
     
    14811482" scratch  "{{{2 
    14821483 
    1483 nnoremap <Leader>s  :<C-u>ScratchOpen<Return> 
     1484nmap <Leader>s  <Plug>(scratch-open) 
    14841485 
    14851486 
     
    14871488" But I don't use it in the scratch buffer, so it should be overridden. 
    14881489autocmd MyAutoCmd User PluginScratchInitializeAfter 
    1489       \ map <buffer> <C-m>  <Plug>scratch-evaluate 
     1490      \ map <buffer> <C-m>  <Plug>(scratch-evaluate) 
    14901491 
    14911492