diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-30 14:15:54 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-30 14:15:54 +0200 |
commit | b20545f2a718d4f19c3f609fd11c0ca4eff450ce (patch) | |
tree | f6dd2ceae7224b40327a70cc31ff7e29dd06f088 | |
parent | 0b6cf69c038b9af198542edc349ebe8e53a8f847 (diff) | |
download | vim-b20545f2a718d4f19c3f609fd11c0ca4eff450ce.zip |
patch 7.4.1804
Problem: Can't use Vim as MANPAGER.
Solution: Add manpager.vim. (Enno Nagel, closes #491)
-rw-r--r-- | runtime/plugin/manpager.vim | 29 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/runtime/plugin/manpager.vim b/runtime/plugin/manpager.vim new file mode 100644 index 000000000..43b438c4b --- /dev/null +++ b/runtime/plugin/manpager.vim @@ -0,0 +1,29 @@ +" Vim plugin for using Vim as manpager. +" Maintainer: Enno Nagel <ennonagel+vim@gmail.com> +" Last Change: 2016 Apr 30 + +" $MAN_PN is supposed to be set by MANPAGER, see ":help manpager.vim". +if empty($MAN_PN) + finish +endif + +command! -nargs=0 MANPAGER call s:MANPAGER() | delcommand MANPAGER + +function! s:MANPAGER() + let page_pattern = '\v\w+%([-_.]\w+)*' + let sec_pattern = '\v\w+%(\+\w+)*' + let pagesec_pattern = '\v(' . page_pattern . ')\((' . sec_pattern . ')\)' + + if $MAN_PN is '1' + let manpage = matchstr( getline(1), '^' . pagesec_pattern ) + else + let manpage = expand('$MAN_PN') + endif + + let page_sec = matchlist( manpage, '^' . pagesec_pattern . '$') + + bwipe! + + setlocal filetype=man + exe 'Man' page_sec[3] page_sec[1] +endfunction diff --git a/src/version.c b/src/version.c index ff275cf0b..e891af900 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1804, +/**/ 1803, /**/ 1802, |