comparison vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/changes.vim @ 7:86e0ac713642

Re-added the latest ctrlp.vim plugin. The ctrlp.vim commit was e61e7d5b801ade5fcefeab3aca75c1f37d54bdf1.
author Brian Neal <bgneal@gmail.com>
date Sun, 29 Apr 2012 16:20:31 -0500
parents
children
comparison
equal deleted inserted replaced
6:ff60fbc930de 7:86e0ac713642
1 " =============================================================================
2 " File: autoload/ctrlp/changes.vim
3 " Description: Change list extension
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
6
7 " Init {{{1
8 if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
9 fini
10 en
11 let g:loaded_ctrlp_changes = 1
12
13 cal add(g:ctrlp_ext_vars, {
14 \ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
15 \ 'accept': 'ctrlp#changes#accept',
16 \ 'lname': 'changes',
17 \ 'sname': 'chs',
18 \ 'exit': 'ctrlp#changes#exit()',
19 \ 'type': 'tabe',
20 \ 'sort': 0,
21 \ 'nolim': 1,
22 \ })
23
24 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
25 " Utilities {{{1
26 fu! s:changelist(bufnr)
27 sil! exe 'noa hid b' a:bufnr
28 redi => result
29 sil! changes
30 redi END
31 retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
32 endf
33
34 fu! s:process(clines, ...)
35 let [clines, evas] = [[], []]
36 for each in a:clines
37 let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
38 if !empty(parts)
39 if parts[3] == '' | let parts[3] = ' ' | en
40 cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
41 en
42 endfo
43 retu reverse(filter(clines, 'count(clines, v:val) == 1'))
44 endf
45
46 fu! s:syntax()
47 if !ctrlp#nosy()
48 cal ctrlp#hicheck('CtrlPBufName', 'Directory')
49 cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
50 sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
51 sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
52 en
53 endf
54 " Public {{{1
55 fu! ctrlp#changes#init(original_bufnr, bufnr)
56 let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
57 let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
58 cal filter(bufs, 'v:val > 0')
59 let [swb, &swb] = [&swb, '']
60 let lines = []
61 for each in bufs
62 let fnamet = fnamemodify(bufname(each), ':t')
63 cal extend(lines, s:process(s:changelist(each), each, fnamet))
64 endfo
65 sil! exe 'noa hid b' a:original_bufnr
66 let &swb = swb
67 cal ctrlp#syntax()
68 cal s:syntax()
69 retu lines
70 endf
71
72 fu! ctrlp#changes#accept(mode, str)
73 let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
74 if info == [] | retu | en
75 let bufnr = str2nr(get(info, 1))
76 if bufnr
77 cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'))
78 cal cursor(get(info, 2), get(info, 3))
79 sil! norm! zvzz
80 en
81 endf
82
83 fu! ctrlp#changes#cmd(mode, ...)
84 let s:clmode = a:mode
85 if a:0 && !empty(a:1)
86 let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
87 en
88 retu s:id
89 endf
90
91 fu! ctrlp#changes#exit()
92 unl! s:clmode s:bufnr
93 endf
94 "}}}
95
96 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2