annotate runtime/ftplugin/pdf.vim @ 4133:36fd800b8c6c v7.3.819

updated for version 7.3.819 Problem: Compiling without +eval and with Python isn't working. Solution: Add the eval feature when building with Python.
author Bram Moolenaar <bram@vim.org>
date Thu, 14 Feb 2013 22:11:39 +0100
parents 82b5078be2dd
children 7c7432a53a6c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1621
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
1 " Vim filetype plugin file
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
2 " Language: PDF
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
4 " Last Change: 2007 Dec 16
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
5
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
6 if exists("b:did_ftplugin")
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
7 finish
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
8 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
9 let b:did_ftplugin = 1
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
10
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
11 setlocal commentstring=%%s
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
12 setlocal comments=:%
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
13 let b:undo_ftplugin = "setlocal cms< com< | unlet! b:match_words"
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
14
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
15 if exists("g:loaded_matchit")
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
16 let b:match_words = '\<\%(\d\+\s\+\d\+\s\+\)obj\>:\<endobj\>,\<stream$:\<endstream\>,\<xref\>:\<trailer\>,<<:>>'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
17 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
18
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
19 if exists("g:no_plugin_maps") || exists("g:no_pdf_maps") || v:version < 700
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
20 finish
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
21 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
22
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
23 if !exists("b:pdf_tagstack")
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
24 let b:pdf_tagstack = []
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
25 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
26
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
27 let b:undo_ftplugin .= " | silent! nunmap <buffer> <C-]> | silent! nunmap <buffer> <C-T>"
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
28 nnoremap <silent><buffer> <C-]> :call <SID>Tag()<CR>
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
29 " Inline, so the error from an empty tag stack will be simple.
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
30 nnoremap <silent><buffer> <C-T> :if len(b:pdf_tagstack) > 0 <Bar> call setpos('.',remove(b:pdf_tagstack, -1)) <Bar> else <Bar> exe "norm! \<Lt>C-T>" <Bar> endif<CR>
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
31
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
32 function! s:Tag()
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
33 call add(b:pdf_tagstack,getpos('.'))
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
34 if getline('.') =~ '^\d\+$' && getline(line('.')-1) == 'startxref'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
35 return s:dodigits(getline('.'))
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
36 elseif getline('.') =~ '/Prev\s\+\d\+\>\%(\s\+\d\)\@!' && expand("<cword>") =~ '^\d\+$'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
37 return s:dodigits(expand("<cword>"))
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
38 elseif getline('.') =~ '^\d\{10\} \d\{5\} '
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
39 return s:dodigits(matchstr(getline('.'),'^\d\+'))
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
40 else
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
41 let line = getline(".")
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
42 let lastend = 0
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
43 let pat = '\<\d\+\s\+\d\+\s\+R\>'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
44 while lastend >= 0
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
45 let beg = match(line,'\C'.pat,lastend)
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
46 let end = matchend(line,'\C'.pat,lastend)
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
47 if beg < col(".") && end >= col(".")
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
48 return s:doobject(matchstr(line,'\C'.pat,lastend))
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
49 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
50 let lastend = end
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
51 endwhile
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
52 return s:notag()
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
53 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
54 endfunction
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
55
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
56 function! s:doobject(string)
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
57 let first = matchstr(a:string,'^\s*\zs\d\+')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
58 let second = matchstr(a:string,'^\s*\d\+\s\+\zs\d\+')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
59 norm! m'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
60 if first != '' && second != ''
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
61 let oldline = line('.')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
62 let oldcol = col('.')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
63 1
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
64 if !search('^\s*'.first.'\s\+'.second.'\s\+obj\>')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
65 exe oldline
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
66 exe 'norm! '.oldcol.'|'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
67 return s:notag()
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
68 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
69 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
70 endfunction
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
71
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
72 function! s:dodigits(digits)
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
73 let digits = 0 + substitute(a:digits,'^0*','','')
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
74 norm! m'
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
75 if digits <= 0
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
76 norm! 1go
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
77 else
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
78 " Go one character before the destination and advance. This method
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
79 " lands us after a newline rather than before, if that is our target.
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
80 exe "goto ".(digits)."|norm! 1 "
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
81 endif
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
82 endfunction
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
83
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
84 function! s:notag()
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
85 silent! call remove(b:pdf_tagstack,-1)
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
86 echohl ErrorMsg
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
87 echo "E426: tag not found"
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
88 echohl NONE
82b5078be2dd updated for version 7.2a
vimboss
parents:
diff changeset
89 endfunction