annotate runtime/plugin/manpager.vim @ 9579:2fb7e008ac9b v7.4.2067

commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 18 22:22:39 2016 +0200 patch 7.4.2067 Problem: Compiler warning for char/char_u conversion. (Tony Mechelynck) Inefficient code. Solution: Use more lines to fill with spaces. (Nikolai Pavlov) Add type cast.
author Christian Brabandt <cb@256bit.org>
date Mon, 18 Jul 2016 22:30:05 +0200
parents 071f9da012fb
children f690da1b3c04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim plugin for using Vim as manpager.
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Maintainer: Enno Nagel <ennonagel+vim@gmail.com>
9097
071f9da012fb commit https://github.com/vim/vim/commit/06d2d38ab7564e1f784b1058a4ef4580cd6d1810
Christian Brabandt <cb@256bit.org>
parents: 9076
diff changeset
3 " Last Change: 2016 May 20
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " $MAN_PN is supposed to be set by MANPAGER, see ":help manpager.vim".
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 if empty($MAN_PN)
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 finish
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endif
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 command! -nargs=0 MANPAGER call s:MANPAGER() | delcommand MANPAGER
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 function! s:MANPAGER()
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 let page_pattern = '\v\w+%([-_.]\w+)*'
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let sec_pattern = '\v\w+%(\+\w+)*'
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let pagesec_pattern = '\v(' . page_pattern . ')\((' . sec_pattern . ')\)'
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if $MAN_PN is '1'
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let manpage = matchstr( getline(1), '^' . pagesec_pattern )
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 else
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 let manpage = expand('$MAN_PN')
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endif
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
9076
9305a1251e51 commit https://github.com/vim/vim/commit/91c4937be15b0b743b6bc495df602c1abbff6b87
Christian Brabandt <cb@256bit.org>
parents: 9037
diff changeset
23 let page_sec = matchlist(tolower(manpage), '^' . pagesec_pattern . '$')
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 bwipe!
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 setlocal filetype=man
9097
071f9da012fb commit https://github.com/vim/vim/commit/06d2d38ab7564e1f784b1058a4ef4580cd6d1810
Christian Brabandt <cb@256bit.org>
parents: 9076
diff changeset
28 exe 'Man' page_sec[2] page_sec[1]
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunction